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

Side by Side Diff: sitescripts/reports/bin/mailDigests.py

Issue 29670635: Issue 5844 - Remove redundant parentheses in abpssembly (Closed) Base URL: https://hg.adblockplus.org/abpssembly/
Patch Set: Created Jan. 16, 2018, 5:58 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/notifications/parser.py ('k') | sitescripts/reports/bin/parseNewReports.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 groups = {} 105 groups = {}
106 for report in selectedReports: 106 for report in selectedReports:
107 if report['site'] in groups: 107 if report['site'] in groups:
108 groups[report['site']]['reports'].append(report) 108 groups[report['site']]['reports'].append(report)
109 groups[report['site']]['weight'] += report['weight'] 109 groups[report['site']]['weight'] += report['weight']
110 else: 110 else:
111 groups[report['site']] = {'name': report['site'], 'reports': [re port], 'weight': report['weight'], 'dumpAll': False} 111 groups[report['site']] = {'name': report['site'], 'reports': [re port], 'weight': report['weight'], 'dumpAll': False}
112 112
113 miscGroup = {'name': 'Misc', 'reports': [], 'weight': None, 'dumpAll': T rue} 113 miscGroup = {'name': 'Misc', 'reports': [], 'weight': None, 'dumpAll': T rue}
114 for (site, group) in groups.items(): 114 for site, group in groups.items():
115 if len(group['reports']) == 1: 115 if len(group['reports']) == 1:
116 miscGroup['reports'].append(group['reports'][0]) 116 miscGroup['reports'].append(group['reports'][0])
117 del groups[site] 117 del groups[site]
118 118
119 if len(miscGroup['reports']) > 0: 119 if len(miscGroup['reports']) > 0:
120 groups[miscGroup['name']] = miscGroup 120 groups[miscGroup['name']] = miscGroup
121 121
122 groups = groups.values() 122 groups = groups.values()
123 groups.sort(lambda a, b: -cmp(a['weight'], b['weight'])) 123 groups.sort(lambda a, b: -cmp(a['weight'], b['weight']))
124 for group in groups: 124 for group in groups:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return weight 166 return weight
167 167
168 168
169 if __name__ == '__main__': 169 if __name__ == '__main__':
170 setupStderr() 170 setupStderr()
171 171
172 if len(sys.argv) < 2: 172 if len(sys.argv) < 2:
173 raise Exception('No interval specified') 173 raise Exception('No interval specified')
174 174
175 interval = sys.argv[1] 175 interval = sys.argv[1]
176 if not (interval in ['all', 'week', 'day']): 176 if interval not in ['all', 'week', 'day']:
177 raise Exception('Invalid interval') 177 raise Exception('Invalid interval')
178 178
179 if interval == 'week' and len(sys.argv) < 3: 179 if interval == 'week' and len(sys.argv) < 3:
180 raise Exception('No weekday specified') 180 raise Exception('No weekday specified')
181 weekDay = int(sys.argv[2]) if interval == 'week' else -1 181 weekDay = int(sys.argv[2]) if interval == 'week' else -1
182 182
183 currentTime = time() 183 currentTime = time()
184 startTime = 0 184 startTime = 0
185 if interval == 'week': 185 if interval == 'week':
186 startTime = currentTime - 7 * 24 * 60 * 60 186 startTime = currentTime - 7 * 24 * 60 * 60
187 elif interval == 'day': 187 elif interval == 'day':
188 startTime = currentTime - 24 * 60 * 60 188 startTime = currentTime - 24 * 60 * 60
189 189
190 fakeSubscription = {'url': 'https://fake.adblockplus.org', 'name': get_confi g().get('reports', 'defaultSubscriptionName'), 'email': get_config().get('report s', 'defaultSubscriptionRecipient')} 190 fakeSubscription = {'url': 'https://fake.adblockplus.org', 'name': get_confi g().get('reports', 'defaultSubscriptionName'), 'email': get_config().get('report s', 'defaultSubscriptionRecipient')}
191 subscriptions, subscriptionList = loadSubscriptions() 191 subscriptions, subscriptionList = loadSubscriptions()
192 subscriptionList.append(fakeSubscription) 192 subscriptionList.append(fakeSubscription)
193 reports = scanReports() 193 reports = scanReports()
194 sendNotifications(reports) 194 sendNotifications(reports)
OLDNEW
« no previous file with comments | « sitescripts/notifications/parser.py ('k') | sitescripts/reports/bin/parseNewReports.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld