Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 found = False | 186 found = False |
187 for key in group: | 187 for key in group: |
188 if self._data[key] != None: | 188 if self._data[key] != None: |
189 found = True | 189 found = True |
190 if not found: | 190 if not found: |
191 str = ", ".join(group) | 191 str = ", ".join(group) |
192 warn('None of the attributes %s present in %s' % (str, path)) | 192 warn('None of the attributes %s present in %s' % (str, path)) |
193 | 193 |
194 if len(self.variants) == 0: | 194 if len(self.variants) == 0: |
195 warn('No list locations given in %s' % (path)) | 195 warn('No list locations given in %s' % (path)) |
196 if self.type not in ['ads', 'anti-adblock', 'other', 'malware', 'social', 'p rivacy']: | 196 if self.type not in ('ads', 'anti-adblock', 'other', 'malware', 'social', 'p rivacy'): |
197 warn('Unknown type given in %s' % (path)) | 197 warn('Unknown type given in %s' % (path)) |
198 if self.digest != 'daily' and self.digest != 'weekly': | 198 if self.digest != 'daily' and self.digest != 'weekly': |
199 warn('Unknown digest frequency given in %s' % (path)) | 199 warn('Unknown digest frequency given in %s' % (path)) |
200 if not self.digestDay[0:3].lower() in weekdays: | 200 if not self.digestDay[0:3].lower() in weekdays: |
201 warn('Unknown digest day given in %s' % (path)) | 201 warn('Unknown digest day given in %s' % (path)) |
202 self.digestDay = 'wed' | 202 self.digestDay = 'wed' |
203 self.digestDay = weekdays[self.digestDay[0:3].lower()] | 203 self.digestDay = weekdays[self.digestDay[0:3].lower()] |
204 if self.recommendation != None and self.type == 'ads' and (self.languages == None or not re.search(r'\S', self.languages)): | 204 if self.recommendation is not None and self.type == 'ads' and not (self.lang uages and self.languages.strip()): |
Sebastian Noack
2015/08/31 11:41:06
not re.search(r'\S', self.languages)
.. is equiva
Sebastian Noack
2015/08/31 11:41:06
Also please use |is None| or |is not None| instead
Thomas Greiner
2015/08/31 15:27:47
Done but I kept the "not" to achieve the same resu
Thomas Greiner
2015/08/31 15:27:47
Done.
| |
205 warn('Recommendation without languages in %s' % (path)) | 205 warn('Recommendation without languages in %s' % (path)) |
206 if len(self.supplements) == 0: | 206 if len(self.supplements) == 0: |
207 for [name, url, complete] in self.variants: | 207 for [name, url, complete] in self.variants: |
208 if complete: | 208 if complete: |
209 warn('Variant marked as complete for non-supplemental subscription in %s' % (path)) | 209 warn('Variant marked as complete for non-supplemental subscription in %s' % (path)) |
210 break | 210 break |
211 | 211 |
212 self.variants.sort(key=lambda variant: (self.recommendation == variant) * 2 + variant[2], reverse=True) | 212 self.variants.sort(key=lambda variant: (self.recommendation == variant) * 2 + variant[2], reverse=True) |
213 | 213 |
214 def parse_file(path, data): | 214 def parse_file(path, data): |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 | 251 |
252 def getFallbackData(): | 252 def getFallbackData(): |
253 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) | 253 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) |
254 redirectdata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul t', os.path.join(repo, 'redirects')]) | 254 redirectdata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defaul t', os.path.join(repo, 'redirects')]) |
255 gonedata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'gone')]) | 255 gonedata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default', os.path.join(repo, 'gone')]) |
256 return (redirectdata, gonedata) | 256 return (redirectdata, gonedata) |
257 | 257 |
258 def _validate_URL(url): | 258 def _validate_URL(url): |
259 parse_result = urlparse(url) | 259 parse_result = urlparse(url) |
260 return parse_result.scheme in ('http', 'https') and parse_result.netloc != '' | 260 return parse_result.scheme in ('http', 'https') and parse_result.netloc != '' |
LEFT | RIGHT |