Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/notifications/parser.py

Issue 29327106: Issue 3048 - Mark inactive notifications instead of removing them (Closed)
Left Patch Set: Created Sept. 10, 2015, 11:25 a.m.
Right Patch Set: Simplify range selection and inactive check Created Sept. 11, 2015, 7:03 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | sitescripts/notifications/test/notification.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 name = fileinfo.name 113 name = fileinfo.name
114 if name.startswith("./"): 114 if name.startswith("./"):
115 name = name[2:] 115 name = name[2:]
116 116
117 if fileinfo.type == tarfile.REGTYPE: 117 if fileinfo.type == tarfile.REGTYPE:
118 data = codecs.getreader("utf8")(archive.extractfile(fileinfo)) 118 data = codecs.getreader("utf8")(archive.extractfile(fileinfo))
119 try: 119 try:
120 notification = _parse_notification(data, name) 120 notification = _parse_notification(data, name)
121 if not "inactive" in notification: 121 if not "inactive" in notification:
122 current_time = datetime.datetime.now() 122 current_time = datetime.datetime.now()
123 start = notification.pop("start", None) 123 start = notification.pop("start", current_time)
124 end = notification.pop("end", None) 124 end = notification.pop("end", current_time)
125 if ((start is not None and current_time < start) or 125 if not start <= current_time <= end:
126 (end is not None and current_time > end)):
Sebastian Noack 2015/09/10 13:29:20 I think I found a way to simplify that logic: s
Felix Dahlke 2015/09/11 07:04:43 Indeed, that's much better - done.
127 notification["inactive"] = True 126 notification["inactive"] = True
128 notifications.append(notification) 127 notifications.append(notification)
129 except: 128 except:
130 traceback.print_exc() 129 traceback.print_exc()
131 return notifications 130 return notifications
LEFTRIGHT

Powered by Google App Engine
This is Rietveld