Browse Source

[fix] pep8

Thomas Pointhuber 10 years ago
parent
commit
91f9973227
2 changed files with 24 additions and 16 deletions
  1. 7
    4
      searx/engines/mediawiki.py
  2. 17
    12
      searx/engines/yacy.py

+ 7
- 4
searx/engines/mediawiki.py View File

@@ -28,15 +28,17 @@ search_url = base_url + 'w/api.php?action=query'\
28 28
                                  '&srprop=timestamp'\
29 29
                                  '&format=json'\
30 30
                                  '&sroffset={offset}'\
31
-                                 '&srlimit={limit}'
31
+                                 '&srlimit={limit}'     # noqa
32 32
 
33 33
 
34 34
 # do search-request
35 35
 def request(query, params):
36 36
     offset = (params['pageno'] - 1) * number_of_results
37
+
37 38
     string_args = dict(query=urlencode({'srsearch': query}),
38
-                        offset=offset,
39
-                        limit=number_of_results)
39
+                       offset=offset,
40
+                       limit=number_of_results)
41
+
40 42
     format_strings = list(Formatter().parse(base_url))
41 43
 
42 44
     if params['language'] == 'all':
@@ -67,7 +69,8 @@ def response(resp):
67 69
 
68 70
     # parse results
69 71
     for result in search_results['query']['search']:
70
-        url = base_url.format(language=resp.search_params['language']) + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8'))
72
+        url = base_url.format(language=resp.search_params['language']) +\
73
+            'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8'))
71 74
 
72 75
         # append result
73 76
         results.append({'url': url,

+ 17
- 12
searx/engines/yacy.py View File

@@ -24,7 +24,11 @@ number_of_results = 5
24 24
 
25 25
 # search-url
26 26
 base_url = 'http://localhost:8090'
27
-search_url = '/yacysearch.json?{query}&startRecord={offset}&maximumRecords={limit}&contentdom={search_type}&resource=global'
27
+search_url = '/yacysearch.json?{query}'\
28
+                             '&startRecord={offset}'\
29
+                             '&maximumRecords={limit}'\
30
+                             '&contentdom={search_type}'\
31
+                             '&resource=global'             # noqa
28 32
 
29 33
 # yacy specific type-definitions
30 34
 search_types = {'general': 'text',
@@ -39,10 +43,11 @@ def request(query, params):
39 43
     offset = (params['pageno'] - 1) * number_of_results
40 44
     search_type = search_types.get(params['category'], '0')
41 45
 
42
-    params['url'] = base_url + search_url.format(query=urlencode({'query': query}),
43
-                                                 offset=offset,
44
-                                                 limit=number_of_results,
45
-                                                 search_type=search_type)
46
+    params['url'] = base_url +\
47
+        search_url.format(query=urlencode({'query': query}),
48
+                          offset=offset,
49
+                          limit=number_of_results,
50
+                          search_type=search_type)
46 51
 
47 52
     # add language tag if specified
48 53
     if params['language'] != 'all':
@@ -70,19 +75,19 @@ def response(resp):
70 75
 
71 76
             # append result
72 77
             results.append({'url': result['link'],
73
-                        'title': result['title'],
74
-                        'content': result['description'],
75
-                        'publishedDate': publishedDate})
78
+                            'title': result['title'],
79
+                            'content': result['description'],
80
+                            'publishedDate': publishedDate})
76 81
 
77 82
     elif resp.search_params['category'] == 'images':
78 83
         # parse image results
79 84
         for result in search_results:
80 85
             # append result
81 86
             results.append({'url': result['url'],
82
-                        'title': result['title'],
83
-                        'content': '',
84
-                        'img_src': result['image'],
85
-                        'template': 'images.html'})
87
+                            'title': result['title'],
88
+                            'content': '',
89
+                            'img_src': result['image'],
90
+                            'template': 'images.html'})
86 91
 
87 92
     #TODO parse video, audio and file results
88 93