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

Unified Diff: sitescripts/notifications/parser.py

Issue 29321041: Issue 2707 - Support start/end notification parameters (Closed)
Patch Set: Created June 23, 2015, 3:01 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sitescripts/notifications/test/parser.py » ('j') | sitescripts/notifications/test/parser.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/notifications/parser.py
===================================================================
--- a/sitescripts/notifications/parser.py
+++ b/sitescripts/notifications/parser.py
@@ -16,6 +16,8 @@
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
import codecs
+import datetime
+import dateutil.parser
Sebastian Noack 2015/06/23 15:41:36 Nit: Third party module imports go below corelib i
Felix Dahlke 2015/06/23 15:51:43 Oh, didn't even realise it's third party... Done.
import os
import re
import subprocess
@@ -87,6 +89,8 @@
current["targets"] = [target]
elif key == "sample" and is_variant:
current["sample"] = float(value)
+ elif key in ["start", "end"]:
+ current[key] = dateutil.parser.parse(value)
Sebastian Noack 2015/06/23 15:41:36 I wonder why we don't simply use a more simply for
Felix Dahlke 2015/06/23 15:51:43 Now that I know that dateutil is third party, it'd
Sebastian Noack 2015/06/23 15:58:38 IIRC, the initial idea was to serve one static fil
Wladimir Palant 2015/06/23 17:24:00 I don't think the idea was ever having this checke
Felix Dahlke 2015/06/24 07:53:16 I really don't think we want to parse ISO 8601 our
else:
raise Exception("Unknown parameter '%s' in file '%s'" % (key, name))
@@ -118,6 +122,11 @@
notification = _parse_notification(data, name)
if "inactive" in notification:
continue
+ current_time = datetime.datetime.now()
+ if "start" in notification and current_time < notification["start"]:
+ continue
+ if "end" in notification and current_time > notification["end"]:
+ continue
notifications.append(notification)
except:
traceback.print_exc()
« no previous file with comments | « no previous file | sitescripts/notifications/test/parser.py » ('j') | sitescripts/notifications/test/parser.py » ('J')

Powered by Google App Engine
This is Rietveld