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

Side by Side Diff: sitescripts/notifications/parser.py

Issue 29327106: Issue 3048 - Mark inactive notifications instead of removing them (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « no previous file | sitescripts/notifications/test/notification.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 with tarfile.open(mode="r:", fileobj=StringIO(data)) as archive: 111 with tarfile.open(mode="r:", fileobj=StringIO(data)) as archive:
112 for fileinfo in archive: 112 for fileinfo in archive:
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 "inactive" in notification: 121 if not "inactive" in notification:
122 continue 122 current_time = datetime.datetime.now()
123 current_time = datetime.datetime.now() 123 start = notification.pop("start", current_time)
124 start = notification.pop("start", None) 124 end = notification.pop("end", current_time)
125 if start is not None and current_time < start: 125 if not start <= current_time <= end:
126 continue 126 notification["inactive"] = True
127 end = notification.pop("end", None)
128 if end is not None and current_time > end:
129 continue
130 notifications.append(notification) 127 notifications.append(notification)
131 except: 128 except:
132 traceback.print_exc() 129 traceback.print_exc()
133 return notifications 130 return notifications
OLDNEW
« no previous file with comments | « no previous file | sitescripts/notifications/test/notification.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld