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

Side by Side Diff: sitescripts/management/bin/generateNotifications.py

Issue 6582297721569280: Issue 2275 - Parse notification groups (Closed)
Patch Set: Rebased Created April 15, 2015, 9:26 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/parser.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,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import codecs 18 import codecs
19 import json 19 import json
20 import time 20 import time
21 21
22 from sitescripts.notifications.parser import load_notifications 22 from sitescripts.notifications.parser import load_notifications
23 from sitescripts.utils import get_config, setupStderr 23 from sitescripts.utils import get_config, setupStderr
24 24
25 def generate_notifications(path): 25 def generate_notifications(path):
26 notifications = load_notifications() 26 notifications = load_notifications()
27 # Ignoring notifications with variants here - we can only process those in a
28 # URL handler.
29 notifications = [x for x in notifications if "variants" in x]
27 output = { 30 output = {
28 "notifications": notifications, 31 "notifications": notifications,
29 "version": time.strftime("%Y%m%d%H%M", time.gmtime()) 32 "version": time.strftime("%Y%m%d%H%M", time.gmtime())
30 } 33 }
31 with codecs.open(path, "wb", encoding="utf-8") as file: 34 with codecs.open(path, "wb", encoding="utf-8") as file:
32 json.dump(output, file, ensure_ascii=False, indent=2, 35 json.dump(output, file, ensure_ascii=False, indent=2,
33 separators=(',', ': '), sort_keys=True) 36 separators=(',', ': '), sort_keys=True)
34 37
35 if __name__ == "__main__": 38 if __name__ == "__main__":
36 setupStderr() 39 setupStderr()
37 output = get_config().get("notifications", "output") 40 output = get_config().get("notifications", "output")
38 generate_notifications(output) 41 generate_notifications(output)
OLDNEW
« no previous file with comments | « no previous file | sitescripts/notifications/parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld