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

Delta Between Two Patch Sets: sitescripts/subscriptions/subscriptionParser.py

Issue 29670611: Issue 5844 - Remove redundant parentheses in sitescripts and abpsembly (Closed) Base URL: https://hg.adblockplus.org/sitescripts/
Left Patch Set: Created Jan. 16, 2018, 5:28 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/subscriptions/knownIssuesParser.py ('k') | sitescripts/subscriptions/web/fallback.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 regexp = re.compile(r'\s*\[((?:\w+,)*\w+)\]$') 145 regexp = re.compile(r'\s*\[((?:\w+,)*\w+)\]$')
146 match = re.search(regexp, value) 146 match = re.search(regexp, value)
147 if match: 147 if match:
148 value = re.sub(regexp, r'', value) 148 value = re.sub(regexp, r'', value)
149 for keyword in match.group(1).split(','): 149 for keyword in match.group(1).split(','):
150 keyword = keyword.lower() 150 keyword = keyword.lower()
151 if keyword in keywords: 151 if keyword in keywords:
152 keywords[keyword] = True 152 keywords[keyword] = True
153 else: 153 else:
154 warn('Unknown keyword %s given for attribute %s in %s' % (keyword, key, path)) 154 warn('Unknown keyword %s given for attribute %s in %s' % (keyword, key, path))
155 name, url = (self.name, value) 155 name, url = self.name, value
Sebastian Noack 2018/01/17 01:43:51 I wonder whether we should omit the parantheses wh
Vasily Kuznetsov 2018/01/18 10:46:07 If parentheses are not needed for line breaking (a
rosie 2018/01/25 16:13:48 Done.
Sebastian Noack 2018/01/25 18:15:00 Mind also doing the same change below?
rosie 2018/01/25 19:03:39 Done.
156 if key == 'variant': 156 if key == 'variant':
157 match = re.search(r'(.+?)\s+(\S+)$', value) 157 match = re.search(r'(.+?)\s+(\S+)$', value)
158 if match: 158 if match:
159 name, url = (match.group(1), match.group(2)) 159 name, url = match.group(1), match.group(2)
160 else: 160 else:
161 warn('Invalid variant format in %s, no name given?' % path) 161 warn('Invalid variant format in %s, no name given?' % path)
162 if not _validate_URL(url): 162 if not _validate_URL(url):
163 warn('Invalid list URL %s given in %s' % (url, path)) 163 warn('Invalid list URL %s given in %s' % (url, path))
164 self.variants.append([name, url, keywords['complete']]) 164 self.variants.append([name, url, keywords['complete']])
165 if keywords['recommendation']: 165 if keywords['recommendation']:
166 self._data['recommendation'] = self._data['variants'][-1 ] 166 self._data['recommendation'] = self._data['variants'][-1 ]
167 self._data['catchall'] = keywords['catchall'] 167 self._data['catchall'] = keywords['catchall']
168 168
169 elif key == 'deprecated' or key == 'unavailable': 169 elif key == 'deprecated' or key == 'unavailable':
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 def getFallbackData(): 265 def getFallbackData():
266 repo = os.path.abspath(get_config().get('subscriptions', 'repository')) 266 repo = os.path.abspath(get_config().get('subscriptions', 'repository'))
267 redirectdata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defa ult', os.path.join(repo, 'redirects')]) 267 redirectdata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'defa ult', os.path.join(repo, 'redirects')])
268 gonedata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default' , os.path.join(repo, 'gone')]) 268 gonedata = subprocess.check_output(['hg', '-R', repo, 'cat', '-r', 'default' , os.path.join(repo, 'gone')])
269 return (redirectdata, gonedata) 269 return (redirectdata, gonedata)
270 270
271 271
272 def _validate_URL(url): 272 def _validate_URL(url):
273 parse_result = urlparse(url) 273 parse_result = urlparse(url)
274 return parse_result.scheme in ('http', 'https') and parse_result.netloc != ' ' 274 return parse_result.scheme in ('http', 'https') and parse_result.netloc != ' '
LEFTRIGHT

Powered by Google App Engine
This is Rietveld