diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2021-12-27 09:26:22 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2021-12-27 09:26:22 +0100 |
commit | 3d96a9839a12649874b6d4cf9466bd3616b0a03c (patch) | |
tree | e7d54d1e345b1e792d538ddc250f4827bb2fd9b9 /searx/engines/pubmed.py | |
parent | fcdc2c2cd26e24c2aa3f064d93cee3e29dc2a30c (diff) | |
download | searxng-3d96a9839a12649874b6d4cf9466bd3616b0a03c.tar.gz searxng-3d96a9839a12649874b6d4cf9466bd3616b0a03c.zip |
[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>
Diffstat (limited to 'searx/engines/pubmed.py')
-rw-r--r-- | searx/engines/pubmed.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/searx/engines/pubmed.py b/searx/engines/pubmed.py index 5d88d398e..27444ae24 100644 --- a/searx/engines/pubmed.py +++ b/searx/engines/pubmed.py @@ -15,7 +15,7 @@ about = { "wikidata_id": 'Q1540899', "official_api_documentation": { 'url': 'https://www.ncbi.nlm.nih.gov/home/develop/api/', - 'comment': 'More info on api: https://www.ncbi.nlm.nih.gov/books/NBK25501/' + 'comment': 'More info on api: https://www.ncbi.nlm.nih.gov/books/NBK25501/', }, "use_official_api": True, "require_api_key": False, @@ -24,8 +24,9 @@ about = { categories = ['science'] -base_url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi'\ - + '?db=pubmed&{query}&retstart={offset}&retmax={hits}' +base_url = ( + 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi' + '?db=pubmed&{query}&retstart={offset}&retmax={hits}' +) # engine dependent config number_of_results = 10 @@ -36,9 +37,7 @@ def request(query, params): # basic search offset = (params['pageno'] - 1) * number_of_results - string_args = dict(query=urlencode({'term': query}), - offset=offset, - hits=number_of_results) + string_args = dict(query=urlencode({'term': query}), offset=offset, hits=number_of_results) params['url'] = base_url.format(**string_args) @@ -49,8 +48,9 @@ def response(resp): results = [] # First retrieve notice of each result - pubmed_retrieve_api_url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?'\ - + 'db=pubmed&retmode=xml&id={pmids_string}' + pubmed_retrieve_api_url = ( + 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?' + 'db=pubmed&retmode=xml&id={pmids_string}' + ) pmids_results = etree.XML(resp.content) pmids = pmids_results.xpath('//eSearchResult/IdList/Id') @@ -88,14 +88,17 @@ def response(resp): content = content[0:300] + "..." # TODO: center snippet on query term - res_dict = {'url': url, - 'title': title, - 'content': content} + res_dict = {'url': url, 'title': title, 'content': content} try: - publishedDate = datetime.strptime(entry.xpath('.//DateCreated/Year')[0].text - + '-' + entry.xpath('.//DateCreated/Month')[0].text - + '-' + entry.xpath('.//DateCreated/Day')[0].text, '%Y-%m-%d') + publishedDate = datetime.strptime( + entry.xpath('.//DateCreated/Year')[0].text + + '-' + + entry.xpath('.//DateCreated/Month')[0].text + + '-' + + entry.xpath('.//DateCreated/Day')[0].text, + '%Y-%m-%d', + ) res_dict['publishedDate'] = publishedDate except: pass |