on master help sign in
[fix] pep8 compatibilty
commitbd22e9a3363090a5e4f851670b0650349a528749 authorAdam Tauber <asciimoo@gmail.com> dateMon 18 Jan 2016, 12:47 (11 years ago) parent6a158ca
18 files changed+30−29
manage.sh+4−1 requirements-dev.txt+1−1 searx/autocomplete.py+2−4 searx/engines/blekko_images.py+1−1 searx/engines/btdigg.py+1−1 searx/engines/deviantart.py+1−1 searx/engines/digg.py+1−1 searx/engines/faroo.py+1−1 searx/engines/searchcode_code.py+2−2 searx/engines/searchcode_doc.py+2−2 searx/engines/stackoverflow.py+1−1 searx/engines/startpage.py+4−4 searx/engines/wikidata.py+2−2 searx/engines/www1x.py+1−1 searx/engines/xpath.py+2−2 searx/engines/yandex.py+1−1 searx/plugins/https_rewrite.py+2−2 searx/poolrequests.py+1−1
manage.sh+4−1
@@ -16,7 +16,10 @@ update_dev_packages() {
1616
1717pep8_check() {
1818 echo '[!] Running pep8 check'
19− pep8 --max-line-length=120 "$SEARX_DIR" "$BASE_DIR/tests"
19+ # ignored rules:
20+ # E402 module level import not at top of file
21+ # W503 line break before binary operator
22+ pep8 --max-line-length=120 --ignore "E402,W503" "$SEARX_DIR" "$BASE_DIR/tests"
2023}
2124
2225unit_tests() {
requirements-dev.txt+1−1
@@ -1,7 +1,7 @@
11babel==2.2.0
2−flake8==2.5.1
32mock==1.0.1
43nose2[coverage-plugin]
4+pep8==1.7.0
55plone.testing==4.0.15
66robotframework-selenium2library==1.7.4
77robotsuite==1.7.0
searx/autocomplete.py+2−4
@@ -114,8 +114,7 @@ def dbpedia(query):
114114 # dbpedia autocompleter, no HTTPS
115115 autocomplete_url = 'http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?'
116116
117− response = get(autocomplete_url
118− + urlencode(dict(QueryString=query)))
117+ response = get(autocomplete_url + urlencode(dict(QueryString=query)))
119118
120119 results = []
121120
@@ -141,8 +140,7 @@ def google(query):
141140 # google autocompleter
142141 autocomplete_url = 'https://suggestqueries.google.com/complete/search?client=toolbar&'
143142
144− response = get(autocomplete_url
145− + urlencode(dict(q=query)))
143+ response = get(autocomplete_url + urlencode(dict(q=query)))
146144
147145 results = []
148146
searx/engines/blekko_images.py+1−1
@@ -37,7 +37,7 @@ def request(query, params):
3737 c=c)
3838
3939 if params['pageno'] != 1:
40− params['url'] += '&page={pageno}'.format(pageno=(params['pageno']-1))
40+ params['url'] += '&page={pageno}'.format(pageno=(params['pageno'] - 1))
4141
4242 # let Blekko know we wan't have profiling
4343 params['cookies']['tag_lesslogging'] = '1'
searx/engines/btdigg.py+1−1
@@ -29,7 +29,7 @@ search_url = url + '/search?q={search_term}&p={pageno}'
2929# do search-request
3030def request(query, params):
3131 params['url'] = search_url.format(search_term=quote(query),
32− pageno=params['pageno']-1)
32+ pageno=params['pageno'] - 1)
3333
3434 return params
3535
searx/engines/deviantart.py+1−1
@@ -24,7 +24,7 @@ paging = True
2424
2525# search-url
2626base_url = 'https://www.deviantart.com/'
27−search_url = base_url+'browse/all/?offset={offset}&{query}'
27+search_url = base_url + 'browse/all/?offset={offset}&{query}'
2828
2929
3030# do search-request
searx/engines/digg.py+1−1
@@ -22,7 +22,7 @@ paging = True
2222
2323# search-url
2424base_url = 'https://digg.com/'
25−search_url = base_url+'api/search/{query}.json?position={position}&format=html'
25+search_url = base_url + 'api/search/{query}.json?position={position}&format=html'
2626
2727# specific xpath variables
2828results_xpath = '//article'
searx/engines/faroo.py+1−1
@@ -88,7 +88,7 @@ def response(resp):
8888 for result in search_res['results']:
8989 if result['news']:
9090 # timestamp (milliseconds since 1970)
91− publishedDate = datetime.datetime.fromtimestamp(result['date']/1000.0) # noqa
91+ publishedDate = datetime.datetime.fromtimestamp(result['date'] / 1000.0) # noqa
9292
9393 # append news result
9494 results.append({'url': result['url'],
searx/engines/searchcode_code.py+2−2
@@ -20,7 +20,7 @@ paging = True
2020
2121# search-url
2222url = 'https://searchcode.com/'
23−search_url = url+'api/codesearch_I/?{query}&p={pageno}'
23+search_url = url + 'api/codesearch_I/?{query}&p={pageno}'
2424
2525# special code-endings which are not recognised by the file ending
2626code_endings = {'cs': 'c#',
@@ -32,7 +32,7 @@ code_endings = {'cs': 'c#',
3232# do search-request
3333def request(query, params):
3434 params['url'] = search_url.format(query=urlencode({'q': query}),
35− pageno=params['pageno']-1)
35+ pageno=params['pageno'] - 1)
3636
3737 # Disable SSL verification
3838 # error: (60) SSL certificate problem: unable to get local issuer
searx/engines/searchcode_doc.py+2−2
@@ -19,13 +19,13 @@ paging = True
1919
2020# search-url
2121url = 'https://searchcode.com/'
22−search_url = url+'api/search_IV/?{query}&p={pageno}'
22+search_url = url + 'api/search_IV/?{query}&p={pageno}'
2323
2424
2525# do search-request
2626def request(query, params):
2727 params['url'] = search_url.format(query=urlencode({'q': query}),
28− pageno=params['pageno']-1)
28+ pageno=params['pageno'] - 1)
2929
3030 # Disable SSL verification
3131 # error: (60) SSL certificate problem: unable to get local issuer
searx/engines/stackoverflow.py+1−1
@@ -22,7 +22,7 @@ paging = True
2222
2323# search-url
2424url = 'https://stackoverflow.com/'
25−search_url = url+'search?{query}&page={pageno}'
25+search_url = url + 'search?{query}&page={pageno}'
2626
2727# specific xpath variables
2828results_xpath = '//div[contains(@class,"question-summary")]'
searx/engines/startpage.py+4−4
@@ -90,8 +90,8 @@ def response(resp):
9090
9191 # check if search result starts with something like: "2 Sep 2014 ... "
9292 if re.match("^([1-9]|[1-2][0-9]|3[0-1]) [A-Z][a-z]{2} [0-9]{4} \.\.\. ", content):
93− date_pos = content.find('...')+4
94− date_string = content[0:date_pos-5]
93+ date_pos = content.find('...') + 4
94+ date_string = content[0:date_pos - 5]
9595 published_date = parser.parse(date_string, dayfirst=True)
9696
9797 # fix content string
@@ -99,8 +99,8 @@ def response(resp):
9999
100100 # check if search result starts with something like: "5 days ago ... "
101101 elif re.match("^[0-9]+ days? ago \.\.\. ", content):
102− date_pos = content.find('...')+4
103− date_string = content[0:date_pos-5]
102+ date_pos = content.find('...') + 4
103+ date_string = content[0:date_pos - 5]
104104
105105 # calculate datetime
106106 published_date = datetime.now() - timedelta(days=int(re.match(r'\d+', date_string).group()))
searx/engines/wikidata.py+2−2
@@ -295,7 +295,7 @@ def get_geolink(claims, propertyName, defaultValue=''):
295295 if precision < 0.0003:
296296 zoom = 19
297297 else:
298− zoom = int(15 - precision*8.8322 + precision*precision*0.625447)
298+ zoom = int(15 - precision * 8.8322 + precision * precision * 0.625447)
299299
300300 url = url_map\
301301 .replace('{latitude}', str(value.get('latitude', 0)))\
@@ -318,6 +318,6 @@ def get_wikilink(result, wikiid):
318318
319319def get_wiki_firstlanguage(result, wikipatternid):
320320 for k in result.get('sitelinks', {}).keys():
321− if k.endswith(wikipatternid) and len(k) == (2+len(wikipatternid)):
321+ if k.endswith(wikipatternid) and len(k) == (2 + len(wikipatternid)):
322322 return k[0:2]
323323 return None
searx/engines/www1x.py+1−1
@@ -22,7 +22,7 @@ paging = False
2222
2323# search-url
2424base_url = 'https://1x.com'
25−search_url = base_url+'/backend/search.php?{query}'
25+search_url = base_url + '/backend/search.php?{query}'
2626
2727
2828# do search-request
searx/engines/xpath.py+2−2
@@ -43,7 +43,7 @@ def extract_url(xpath_results, search_url):
4343 if url.startswith('//'):
4444 # add http or https to this kind of url //example.com/
4545 parsed_search_url = urlparse(search_url)
46− url = parsed_search_url.scheme+url
46+ url = parsed_search_url.scheme + url
4747 elif url.startswith('/'):
4848 # fix relative url to the search engine
4949 url = urljoin(search_url, url)
@@ -69,7 +69,7 @@ def normalize_url(url):
6969 p = parsed_url.path
7070 mark = p.find('/**')
7171 if mark != -1:
72− return unquote(p[mark+3:]).decode('utf-8')
72+ return unquote(p[mark + 3:]).decode('utf-8')
7373
7474 return url
7575
searx/engines/yandex.py+1−1
@@ -38,7 +38,7 @@ content_xpath = './/div[@class="serp-item__text"]//text()'
3838def request(query, params):
3939 lang = params['language'].split('_')[0]
4040 host = base_url.format(tld=language_map.get(lang) or default_tld)
41− params['url'] = host + search_url.format(page=params['pageno']-1,
41+ params['url'] = host + search_url.format(page=params['pageno'] - 1,
4242 query=urlencode({'text': query}))
4343 return params
4444
searx/plugins/https_rewrite.py+2−2
@@ -103,10 +103,10 @@ def load_single_https_ruleset(rules_path):
103103 # into a valid python regex group
104104 rule_from = ruleset.attrib['from'].replace('$', '\\')
105105 if rule_from.endswith('\\'):
106− rule_from = rule_from[:-1]+'$'
106+ rule_from = rule_from[:-1] + '$'
107107 rule_to = ruleset.attrib['to'].replace('$', '\\')
108108 if rule_to.endswith('\\'):
109− rule_to = rule_to[:-1]+'$'
109+ rule_to = rule_to[:-1] + '$'
110110
111111 # TODO, not working yet because of the hack above,
112112 # currently doing that in webapp.py
searx/poolrequests.py+1−1
@@ -92,7 +92,7 @@ def head(url, **kwargs):
9292 return request('head', url, **kwargs)
9393
9494
95−def post(url, data=None, **kwargs):
95+def post(url, data=None, **kwargs):
9696 return request('post', url, data=data, **kwargs)
9797
9898