mirror of
https://github.com/ilyakooo0/searx.git
synced 2024-12-01 17:02:21 +03:00
[fix] minor style fixes after picking open street map changes
This commit is contained in:
parent
42db73348a
commit
53c4031f96
@ -22,10 +22,12 @@ from pathlib import Path
|
|||||||
|
|
||||||
data_dir = Path(__file__).parent
|
data_dir = Path(__file__).parent
|
||||||
|
|
||||||
|
|
||||||
def _load(filename):
|
def _load(filename):
|
||||||
with open(data_dir / filename, encoding='utf-8') as f:
|
with open(data_dir / filename, encoding='utf-8') as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
||||||
|
|
||||||
def ahmia_blacklist_loader():
|
def ahmia_blacklist_loader():
|
||||||
"""Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
|
"""Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
|
||||||
names. The MD5 values are fetched by::
|
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:
|
with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f:
|
||||||
return f.read().split()
|
return f.read().split()
|
||||||
|
|
||||||
|
|
||||||
ENGINES_LANGUAGES = _load('engines_languages.json')
|
ENGINES_LANGUAGES = _load('engines_languages.json')
|
||||||
CURRENCIES = _load('currencies.json')
|
CURRENCIES = _load('currencies.json')
|
||||||
USER_AGENTS = _load('useragents.json')
|
USER_AGENTS = _load('useragents.json')
|
||||||
|
@ -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_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'
|
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 (.+)')
|
route_re = re.compile('(?:from )?(.+) to (.+)')
|
||||||
|
|
||||||
wikidata_image_sparql = """
|
wikidata_image_sparql = """
|
||||||
@ -60,7 +60,7 @@ where {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ORDER by ?item
|
ORDER by ?item
|
||||||
"""
|
""" # NOQA
|
||||||
|
|
||||||
|
|
||||||
# key value that are link: mapping functions
|
# key value that are link: mapping functions
|
||||||
@ -70,7 +70,7 @@ ORDER by ?item
|
|||||||
def value_to_https_link(value):
|
def value_to_https_link(value):
|
||||||
http = 'http://'
|
http = 'http://'
|
||||||
if value.startswith(http):
|
if value.startswith(http):
|
||||||
value = 'https://' + value[len(http) :]
|
value = 'https://' + value[len(http):]
|
||||||
return (value, value)
|
return (value, value)
|
||||||
|
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ def response(resp):
|
|||||||
results.append({
|
results.append({
|
||||||
'answer': gettext('Get directions'),
|
'answer': gettext('Get directions'),
|
||||||
'url': route_url.format(*resp.search_params['route'].groups()),
|
'url': route_url.format(*resp.search_params['route'].groups()),
|
||||||
})
|
})
|
||||||
|
|
||||||
fetch_wikidata(nominatim_json, user_language)
|
fetch_wikidata(nominatim_json, user_language)
|
||||||
|
|
||||||
@ -269,9 +269,9 @@ def get_title_address(result):
|
|||||||
# https://github.com/osm-search/Nominatim/issues/1662
|
# https://github.com/osm-search/Nominatim/issues/1662
|
||||||
address_name = address_raw.get('address29')
|
address_name = address_raw.get('address29')
|
||||||
else:
|
else:
|
||||||
address_name = address_raw.get(result['category'])
|
address_name = address_raw.get(result['category'])
|
||||||
elif result['type'] in address_raw:
|
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
|
# add rest of adressdata, if something is already found
|
||||||
if address_name:
|
if address_name:
|
||||||
|
Loading…
Reference in New Issue
Block a user