From 9ed3ee2bebf2f159d4231d9aad9df53aea6db90a Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Mon, 16 Nov 2020 09:41:02 +0100 Subject: [PATCH] [mod] wikidata: WDGeoAttribute class: doesn't change the method signature of get_str --- searx/engines/wikidata.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py index 3d8daca5..539ce5ad 100644 --- a/searx/engines/wikidata.py +++ b/searx/engines/wikidata.py @@ -23,7 +23,7 @@ from searx.data import WIKIDATA_UNITS from searx.poolrequests import post, get from searx.utils import match_language, searx_useragent, get_string_replaces_function from searx.external_urls import get_external_url, get_earth_coordinates_url, area_to_osm_zoom -from searx.engines.wikipedia import _fetch_supported_languages, supported_languages_url # NOQA +from searx.engines.wikipedia import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import logger = logger.getChild('wikidata') @@ -228,7 +228,7 @@ def get_results(attribute_result, attributes, language): # Should use normalized value p:P2046/psn:P2046/wikibase:quantityAmount area = attribute_result.get('P2046') osm_zoom = area_to_osm_zoom(area) if area else 19 - url = attribute.get_str(attribute_result, language, osm_zoom=osm_zoom) + url = attribute.get_geo_url(attribute_result, osm_zoom=osm_zoom) if url: infobox_urls.append({'title': attribute.get_label(language), 'url': url, @@ -546,7 +546,14 @@ class WDGeoAttribute(WDAttribute): def get_group_by(self): return self.get_select() - def get_str(self, result, language, osm_zoom=19): + def get_str(self, result, language): + latitude = result.get(self.name + 'Lat') + longitude = result.get(self.name + 'Long') + if latitude and longitude: + return latitude + ' ' + longitude + return None + + def get_geo_url(self, result, osm_zoom=19): latitude = result.get(self.name + 'Lat') longitude = result.get(self.name + 'Long') if latitude and longitude: