Browse Source

- recoll.py PEPped up

frankdelange 6 years ago
parent
commit
06d1618220
1 changed files with 11 additions and 7 deletions
  1. 11
    7
      searx/engines/recoll.py

+ 11
- 7
searx/engines/recoll.py View File

20
 search_dir = ''
20
 search_dir = ''
21
 dl_prefix = None
21
 dl_prefix = None
22
 
22
 
23
+
23
 def get_time_range(time_range):
24
 def get_time_range(time_range):
24
     sw = {
25
     sw = {
25
-	    'day' : 1,
26
-	    'week': 7,
27
-	    'month': 30,
28
-	    'year': 365
26
+        'day': 1,
27
+        'week': 7,
28
+        'month': 30,
29
+        'year': 365
29
     }
30
     }
30
 
31
 
31
-    offset = sw.get(time_range,0)
32
+    offset = sw.get(time_range, 0)
32
     if not offset:
33
     if not offset:
33
-	    return ''
34
+        return ''
34
 
35
 
35
     return (date.today()-timedelta(days=offset)).isoformat()
36
     return (date.today()-timedelta(days=offset)).isoformat()
36
 
37
 
38
+
37
 # do search-request
39
 # do search-request
38
 def request(query, params):
40
 def request(query, params):
39
     search_after = get_time_range(params['time_range'])
41
     search_after = get_time_range(params['time_range'])
40
     search_url = base_url + 'json?query={query}&page={page}&after={after}&dir={dir}&highlight=0'
42
     search_url = base_url + 'json?query={query}&page={page}&after={after}&dir={dir}&highlight=0'
41
 
43
 
42
-    params['url'] = search_url.format(query=urlencode({'q': query}), page=params['pageno'], after=search_after, dir=search_dir)
44
+    params['url'] = search_url.format(query=urlencode({'q': query}), page=params['pageno'],
45
+                                      after=search_after, dir=search_dir)
43
 
46
 
44
     return params
47
     return params
45
 
48
 
49
+
46
 # get response from search-request
50
 # get response from search-request
47
 def response(resp):
51
 def response(resp):
48
     results = []
52
     results = []