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

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

Issue 29344600: Noissue - Got rid of E129, E704, E712, E731 and F821 errors (Closed)
Patch Set: Created May 26, 2016, 12:49 p.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 | « sitescripts/extensions/bin/updateUpdateManifests.py ('k') | sitescripts/reports/utils.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-2016 Eyeo GmbH 4 # Copyright (C) 2006-2016 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 else: 89 else:
90 current["targets"] = [target] 90 current["targets"] = [target]
91 elif key == "sample" and is_variant: 91 elif key == "sample" and is_variant:
92 current["sample"] = float(value) 92 current["sample"] = float(value)
93 elif key in ["start", "end"]: 93 elif key in ["start", "end"]:
94 current[key] = datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M") 94 current[key] = datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M")
95 else: 95 else:
96 raise Exception("Unknown parameter '%s' in file '%s'" % (key, name)) 96 raise Exception("Unknown parameter '%s' in file '%s'" % (key, name))
97 97
98 for text_key in ("title", "message"): 98 for text_key in ("title", "message"):
99 def has_default_locale(variant): return "en-US" in variant[text_key] 99 def has_default_locale(variant):
100 if (not has_default_locale(notification) and 100 return "en-US" in variant[text_key]
101 not all(map(has_default_locale, notification.get("variants", [])))): 101 if not has_default_locale(notification):
102 raise Exception("No %s for en-US (default language) in file '%s'" % 102 variants = notification.get("variants", [])
103 (text_key, name)) 103 if not all(map(has_default_locale, variants)):
104 raise Exception("No %s for en-US (default language) "
105 "in file '%s'" % (text_key, name))
104 return notification 106 return notification
105 107
106 108
107 def load_notifications(): 109 def load_notifications():
108 repo = get_config().get("notifications", "repository") 110 repo = get_config().get("notifications", "repository")
109 command = ["hg", "-R", repo, "archive", "-r", "default", "-t", "tar", 111 command = ["hg", "-R", repo, "archive", "-r", "default", "-t", "tar",
110 "-p", ".", "-X", os.path.join(repo, ".hg_archival.txt"), "-"] 112 "-p", ".", "-X", os.path.join(repo, ".hg_archival.txt"), "-"]
111 data = subprocess.check_output(command) 113 data = subprocess.check_output(command)
112 114
113 notifications = [] 115 notifications = []
(...skipping 10 matching lines...) Expand all
124 if not "inactive" in notification: 126 if not "inactive" in notification:
125 current_time = datetime.datetime.now() 127 current_time = datetime.datetime.now()
126 start = notification.pop("start", current_time) 128 start = notification.pop("start", current_time)
127 end = notification.pop("end", current_time) 129 end = notification.pop("end", current_time)
128 if not start <= current_time <= end: 130 if not start <= current_time <= end:
129 notification["inactive"] = True 131 notification["inactive"] = True
130 notifications.append(notification) 132 notifications.append(notification)
131 except: 133 except:
132 traceback.print_exc() 134 traceback.print_exc()
133 return notifications 135 return notifications
OLDNEW
« no previous file with comments | « sitescripts/extensions/bin/updateUpdateManifests.py ('k') | sitescripts/reports/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld