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

Side by Side Diff: abp/filters/sources.py

Issue 29933555: Noissue - fix coding style and adjust linting config (Closed) Base URL: https://hg.adblockplus.org/python-abp
Patch Set: Created Nov. 1, 2018, 11:21 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 iterable of str 162 iterable of str
163 Lines of the file. 163 Lines of the file.
164 164
165 """ 165 """
166 url = '{}:{}'.format(self.protocol, path_in_source) 166 url = '{}:{}'.format(self.protocol, path_in_source)
167 try: 167 try:
168 response = urlopen(url) 168 response = urlopen(url)
169 info = response.info() 169 info = response.info()
170 # info.getparam became info.get_param in Python 3 so we'll 170 # info.getparam became info.get_param in Python 3 so we'll
171 # try both. 171 # try both.
172 get_param = (getattr(info, 'get_param', None) or 172 get_param = (getattr(info, 'get_param', None)
173 getattr(info, 'getparam', None)) 173 or getattr(info, 'getparam', None))
174 encoding = get_param('charset') or self.default_encoding 174 encoding = get_param('charset') or self.default_encoding
175 for line in response: 175 for line in response:
176 yield line.decode(encoding).rstrip() 176 yield line.decode(encoding).rstrip()
177 except HTTPError as err: 177 except HTTPError as err:
178 if err.code == 404: 178 if err.code == 404:
179 raise NotFound("HTTP 404 Not found: '{}:{}'" 179 raise NotFound("HTTP 404 Not found: '{}:{}'"
180 .format(self.protocol, path_in_source)) 180 .format(self.protocol, path_in_source))
181 raise err 181 raise err
OLDNEW
« no previous file with comments | « abp/filters/parser.py ('k') | tests/test_diff_script.py » ('j') | tests/test_diff_script.py » ('J')

Powered by Google App Engine
This is Rietveld