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

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

Issue 29670611: Issue 5844 - Remove redundant parentheses in sitescripts and abpsembly (Closed) Base URL: https://hg.adblockplus.org/sitescripts/
Patch Set: Fixed one more case of redundant parentheses Created Jan. 25, 2018, 7:03 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/formmail/web/formmail2.py ('k') | sitescripts/reports/bin/mailDigests.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 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 12 matching lines...) Expand all
23 from StringIO import StringIO 23 from StringIO import StringIO
24 24
25 from sitescripts.utils import get_config 25 from sitescripts.utils import get_config
26 26
27 27
28 def _parse_targetspec(value, name): 28 def _parse_targetspec(value, name):
29 target = {} 29 target = {}
30 30
31 items = [ 31 items = [
32 (r'^(extension|application|platform)(=)(.+)$', { 32 (r'^(extension|application|platform)(=)(.+)$', {
33 '=': (lambda k, v: {k: v}), 33 '=': lambda k, v: {k: v},
34 }), 34 }),
35 (r'^(extension|application|platform)Version(=|\>=|\<=)(.+)$', { 35 (r'^(extension|application|platform)Version(=|\>=|\<=)(.+)$', {
36 '>=': (lambda k, v: {k + 'MinVersion': v}), 36 '>=': lambda k, v: {k + 'MinVersion': v},
37 '<=': (lambda k, v: {k + 'MaxVersion': v}), 37 '<=': lambda k, v: {k + 'MaxVersion': v},
38 '=': (lambda k, v: {k + 'MinVersion': v, k + 'MaxVersion': v}), 38 '=': lambda k, v: {k + 'MinVersion': v, k + 'MaxVersion': v},
39 }), 39 }),
40 (r'^(blockedTotal)(=|\>=|\<=)(\d+)$', { 40 (r'^(blockedTotal)(=|\>=|\<=)(\d+)$', {
41 '>=': (lambda k, v: {k + 'Min': int(v)}), 41 '>=': lambda k, v: {k + 'Min': int(v)},
42 '<=': (lambda k, v: {k + 'Max': int(v)}), 42 '<=': lambda k, v: {k + 'Max': int(v)},
43 '=': (lambda k, v: {k + 'Min': int(v), k + 'Max': int(v)}), 43 '=': lambda k, v: {k + 'Min': int(v), k + 'Max': int(v)},
44 }), 44 }),
45 (r'^(locales)(=)([\w\-,]+)$', { 45 (r'^(locales)(=)([\w\-,]+)$', {
46 '=': (lambda k, v: {k: v.split(',')}), 46 '=': lambda k, v: {k: v.split(',')},
47 }), 47 }),
48 ] 48 ]
49 49
50 try: 50 try:
51 for spec in value.split(): 51 for spec in value.split():
52 for regx, ops in items: 52 for regx, ops in items:
53 m = re.search(regx, spec) 53 m = re.search(regx, spec)
54 if m: 54 if m:
55 key, op, value = m.groups() 55 key, op, value = m.groups()
56 target.update(ops[op](key, value)) 56 target.update(ops[op](key, value))
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if not 'inactive' in notification: 148 if not 'inactive' in notification:
149 current_time = datetime.datetime.now() 149 current_time = datetime.datetime.now()
150 start = notification.pop('start', current_time) 150 start = notification.pop('start', current_time)
151 end = notification.pop('end', current_time) 151 end = notification.pop('end', current_time)
152 if not start <= current_time <= end: 152 if not start <= current_time <= end:
153 notification['inactive'] = True 153 notification['inactive'] = True
154 notifications.append(notification) 154 notifications.append(notification)
155 except: 155 except:
156 traceback.print_exc() 156 traceback.print_exc()
157 return notifications 157 return notifications
OLDNEW
« no previous file with comments | « sitescripts/formmail/web/formmail2.py ('k') | sitescripts/reports/bin/mailDigests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld