on master help sign in
[fix] pep8 compatibility
commitb0fd71b7b3463864e6c60156610d383af2ac9709 authorAdam Tauber <asciimoo@gmail.com> dateSun 19 Oct 2014, 12:18 (12 years ago) parent28fed5d
2 files changed+22−18
searx/engines/yahoo_news.py+7−6 searx/https_rewrite.py+15−12
searx/engines/yahoo_news.py+7−6
@@ -1,8 +1,9 @@
1−## Yahoo (News)
2−#
1+# Yahoo (News)
2+#
33# @website https://news.yahoo.com
4−# @provide-api yes (https://developer.yahoo.com/boss/search/), $0.80/1000 queries
5−#
4+# @provide-api yes (https://developer.yahoo.com/boss/search/)
5+# $0.80/1000 queries
6+#
67# @using-api no (because pricing)
78# @results HTML (using search portal)
89# @stable no (HTML can change)
@@ -22,7 +23,7 @@ paging = True
2223language_support = True
2324
2425# search-url
25−search_url = 'https://news.search.yahoo.com/search?{query}&b={offset}&fl=1&vl=lang_{lang}'
26+search_url = 'https://news.search.yahoo.com/search?{query}&b={offset}&fl=1&vl=lang_{lang}' # noqa
2627
2728# specific xpath variables
2829results_xpath = '//div[@class="res"]'
@@ -41,7 +42,7 @@ def request(query, params):
4142 language = 'en'
4243 else:
4344 language = params['language'].split('_')[0]
44−
45+
4546 params['url'] = search_url.format(offset=offset,
4647 query=urlencode({'p': query}),
4748 lang=language)
searx/https_rewrite.py+15−12
@@ -45,11 +45,9 @@ def load_single_https_ruleset(filepath):
4545 # get root node
4646 root = tree.getroot()
4747
48− #print(etree.tostring(tree))
49−
5048 # check if root is a node with the name ruleset
5149 # TODO improve parsing
52− if root.tag != 'ruleset':
50+ if root.tag != 'ruleset':
5351 return ()
5452
5553 # check if rule is deactivated by default
@@ -68,36 +66,39 @@ def load_single_https_ruleset(filepath):
6866 for ruleset in root:
6967 # this child define a target
7068 if ruleset.tag == 'target':
71− # check if required tags available
69+ # check if required tags available
7270 if not ruleset.attrib.get('host'):
7371 continue
7472
7573 # convert host-rule to valid regex
76− host = ruleset.attrib.get('host').replace('.', '\.').replace('*', '.*')
74+ host = ruleset.attrib.get('host')\
75+ .replace('.', '\.').replace('*', '.*')
7776
7877 # append to host list
7978 hosts.append(host)
8079
8180 # this child define a rule
8281 elif ruleset.tag == 'rule':
83− # check if required tags available
82+ # check if required tags available
8483 if not ruleset.attrib.get('from')\
8584 or not ruleset.attrib.get('to'):
8685 continue
8786
88− # TODO hack, which convert a javascript regex group into a valid python regex group
87+ # TODO hack, which convert a javascript regex group
88+ # into a valid python regex group
8989 rule_from = ruleset.attrib.get('from').replace('$', '\\')
9090 rule_to = ruleset.attrib.get('to').replace('$', '\\')
9191
92− # TODO, not working yet because of the hack above, currently doing that in webapp.py
93− #rule_from_rgx = re.compile(rule_from, re.I)
92+ # TODO, not working yet because of the hack above,
93+ # currently doing that in webapp.py
94+ # rule_from_rgx = re.compile(rule_from, re.I)
9495
9596 # append rule
9697 rules.append((rule_from, rule_to))
9798
9899 # this child define an exclusion
99100 elif ruleset.tag == 'exclusion':
100− # check if required tags available
101+ # check if required tags available
101102 if not ruleset.attrib.get('pattern'):
102103 continue
103104
@@ -124,7 +125,9 @@ def load_https_rules(rules_path):
124125 rules_path += '/'
125126
126127 # search all xml files which are stored in the https rule directory
127− xml_files = [ join(rules_path,f) for f in listdir(rules_path) if isfile(join(rules_path,f)) and f[-4:] == '.xml' ]
128+ xml_files = [join(rules_path, f)
129+ for f in listdir(rules_path)
130+ if isfile(join(rules_path, f)) and f[-4:] == '.xml']
128131
129132 # load xml-files
130133 for ruleset_file in xml_files:
@@ -137,5 +140,5 @@ def load_https_rules(rules_path):
137140
138141 # append ruleset
139142 https_rules.append(ruleset)
140−
143+
141144 print(' * {n} https-rules loaded'.format(n=len(https_rules)))