summaryrefslogtreecommitdiff
path: root/searx/engines/wikidata.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-11-16 09:41:02 +0100
committerAlexandre Flament <alex@al-f.net>2020-12-01 15:21:17 +0100
commit9ed3ee2bebf2f159d4231d9aad9df53aea6db90a (patch)
treef14b2dc0855e3de3df2608ad59acc0b27ceabde1 /searx/engines/wikidata.py
parent3cfef61123c789a238a4548dbf4b578e3e3ce0ba (diff)
downloadsearxng-9ed3ee2bebf2f159d4231d9aad9df53aea6db90a.tar.gz
searxng-9ed3ee2bebf2f159d4231d9aad9df53aea6db90a.zip
[mod] wikidata: WDGeoAttribute class: doesn't change the method signature of get_str
Diffstat (limited to 'searx/engines/wikidata.py')
-rw-r--r--searx/engines/wikidata.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py
index 3d8daca5d..539ce5ad4 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: