From 53c4031f962b23bbaedce2498e0cf1c3f31a7bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mi=20V=C3=A1nyi?= Date: Sat, 2 Oct 2021 15:05:03 +0200 Subject: [PATCH] [fix] minor style fixes after picking open street map changes --- searx/data/__init__.py | 3 +++ searx/engines/openstreetmap.py | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/searx/data/__init__.py b/searx/data/__init__.py index 0f40355e..3d158d3d 100644 --- a/searx/data/__init__.py +++ b/searx/data/__init__.py @@ -22,10 +22,12 @@ from pathlib import Path data_dir = Path(__file__).parent + def _load(filename): with open(data_dir / filename, encoding='utf-8') as f: return json.load(f) + def ahmia_blacklist_loader(): """Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion names. The MD5 values are fetched by:: @@ -38,6 +40,7 @@ def ahmia_blacklist_loader(): with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f: return f.read().split() + ENGINES_LANGUAGES = _load('engines_languages.json') CURRENCIES = _load('currencies.json') USER_AGENTS = _load('useragents.json') diff --git a/searx/engines/openstreetmap.py b/searx/engines/openstreetmap.py index 6920356c..541272d4 100644 --- a/searx/engines/openstreetmap.py +++ b/searx/engines/openstreetmap.py @@ -37,7 +37,7 @@ search_string = 'search?{query}&polygon_geojson=1&format=jsonv2&addressdetails=1 result_id_url = 'https://openstreetmap.org/{osm_type}/{osm_id}' result_lat_lon_url = 'https://www.openstreetmap.org/?mlat={lat}&mlon={lon}&zoom={zoom}&layers=M' -route_url = 'https://graphhopper.com/maps/?point={}&point={}&locale=en-US&vehicle=car&weighting=fastest&turn_costs=true&use_miles=false&layer=Omniscale' # pylint: disable=line-too-long +route_url = 'https://graphhopper.com/maps/?point={}&point={}&locale=en-US&vehicle=car&weighting=fastest&turn_costs=true&use_miles=false&layer=Omniscale' # NOQA route_re = re.compile('(?:from )?(.+) to (.+)') wikidata_image_sparql = """ @@ -60,7 +60,7 @@ where { } } ORDER by ?item -""" +""" # NOQA # key value that are link: mapping functions @@ -70,7 +70,7 @@ ORDER by ?item def value_to_https_link(value): http = 'http://' if value.startswith(http): - value = 'https://' + value[len(http) :] + value = 'https://' + value[len(http):] return (value, value) @@ -154,7 +154,7 @@ def response(resp): results.append({ 'answer': gettext('Get directions'), 'url': route_url.format(*resp.search_params['route'].groups()), - }) + }) fetch_wikidata(nominatim_json, user_language) @@ -269,9 +269,9 @@ def get_title_address(result): # https://github.com/osm-search/Nominatim/issues/1662 address_name = address_raw.get('address29') else: - address_name = address_raw.get(result['category']) + address_name = address_raw.get(result['category']) elif result['type'] in address_raw: - address_name = address_raw.get(result['type']) + address_name = address_raw.get(result['type']) # add rest of adressdata, if something is already found if address_name: