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: Created April 11, 2015, 9:27 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 | « no previous file | sitescripts/notifications/parser.py » ('j') | sitescripts/notifications/parser.py » ('J')
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 20
21 from sitescripts.notifications.parser import load_notifications 21 from sitescripts.notifications.parser import load_notifications
22 from sitescripts.utils import get_config, setupStderr 22 from sitescripts.utils import get_config, setupStderr
23 23
24 def generate_notifications(path): 24 def generate_notifications(path):
25 notifications = load_notifications() 25 notifications = load_notifications()
26 # Ignoring notifications with variants here - we can only process those in a
27 # URL handler.
28 notifications["notifications"] = \
29 filter(lambda notification: not "variants" in notification,
Sebastian Noack 2015/04/13 09:04:37 1. list comprehension > callback 2. |x not in y| >
Felix Dahlke 2015/04/15 08:53:43 Done.
30 notifications["notifications"])
26 with codecs.open(path, "wb", encoding="utf-8") as file: 31 with codecs.open(path, "wb", encoding="utf-8") as file:
27 json.dump(notifications, file, ensure_ascii=False, indent=2, 32 json.dump(notifications, file, ensure_ascii=False, indent=2,
28 separators=(',', ': '), sort_keys=True) 33 separators=(',', ': '), sort_keys=True)
29 34
30 if __name__ == "__main__": 35 if __name__ == "__main__":
31 setupStderr() 36 setupStderr()
32 output = get_config().get("notifications", "output") 37 output = get_config().get("notifications", "output")
33 generate_notifications(output) 38 generate_notifications(output)
OLDNEW
« no previous file with comments | « no previous file | sitescripts/notifications/parser.py » ('j') | sitescripts/notifications/parser.py » ('J')

Powered by Google App Engine
This is Rietveld