mirror of
https://github.com/searxng/searxng.git
synced 2025-07-12 15:59:21 +02:00
[format.python] initial formatting of the python code
This patch was generated by black [1]:: make format.python [1] https://github.com/psf/black Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
fcdc2c2cd2
commit
3d96a9839a
184 changed files with 2800 additions and 2836 deletions
|
@ -28,22 +28,24 @@ api_key = 'unset'
|
|||
base_url = 'https://core.ac.uk:443/api-v2/search/'
|
||||
search_string = '{query}?page={page}&pageSize={nb_per_page}&apiKey={apikey}'
|
||||
|
||||
|
||||
def request(query, params):
|
||||
|
||||
if api_key == 'unset':
|
||||
raise SearxEngineAPIException('missing CORE API key')
|
||||
|
||||
search_path = search_string.format(
|
||||
query = urlencode({'q': query}),
|
||||
nb_per_page = nb_per_page,
|
||||
page = params['pageno'],
|
||||
apikey = api_key,
|
||||
query=urlencode({'q': query}),
|
||||
nb_per_page=nb_per_page,
|
||||
page=params['pageno'],
|
||||
apikey=api_key,
|
||||
)
|
||||
params['url'] = base_url + search_path
|
||||
|
||||
logger.debug("query_url --> %s", params['url'])
|
||||
return params
|
||||
|
||||
|
||||
def response(resp):
|
||||
results = []
|
||||
json_data = loads(resp.text)
|
||||
|
@ -52,7 +54,7 @@ def response(resp):
|
|||
|
||||
source = result['_source']
|
||||
time = source['publishedDate'] or source['depositedDate']
|
||||
if time :
|
||||
if time:
|
||||
date = datetime.fromtimestamp(time / 1000)
|
||||
else:
|
||||
date = None
|
||||
|
@ -66,12 +68,14 @@ def response(resp):
|
|||
metadata.append(source['doi'])
|
||||
metadata = ' / '.join(metadata)
|
||||
|
||||
results.append({
|
||||
'url': source['urls'][0].replace('http://', 'https://', 1),
|
||||
'title': source['title'],
|
||||
'content': source['description'],
|
||||
'publishedDate': date,
|
||||
'metadata' : metadata,
|
||||
})
|
||||
results.append(
|
||||
{
|
||||
'url': source['urls'][0].replace('http://', 'https://', 1),
|
||||
'title': source['title'],
|
||||
'content': source['description'],
|
||||
'publishedDate': date,
|
||||
'metadata': metadata,
|
||||
}
|
||||
)
|
||||
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue