summaryrefslogtreecommitdiff
path: root/searxng_extra/update
diff options
context:
space:
mode:
Diffstat (limited to 'searxng_extra/update')
-rwxr-xr-xsearxng_extra/update/update_wikidata_units.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/searxng_extra/update/update_wikidata_units.py b/searxng_extra/update/update_wikidata_units.py
index f384df749..96326874a 100755
--- a/searxng_extra/update/update_wikidata_units.py
+++ b/searxng_extra/update/update_wikidata_units.py
@@ -51,16 +51,18 @@ WHERE
ORDER BY ?item DESC(?rank) ?symbol
"""
-_wikidata_url = "https://www.wikidata.org/entity/"
-
def get_data():
results = collections.OrderedDict()
response = wikidata.send_wikidata_query(SARQL_REQUEST)
for unit in response['results']['bindings']:
- name = unit['item']['value'].replace(_wikidata_url, '')
+
symbol = unit['symbol']['value']
- si_name = unit.get('tosiUnit', {}).get('value', '').replace(_wikidata_url, '')
+ name = unit['item']['value'].rsplit('/', 1)[1]
+ si_name = unit.get('tosiUnit', {}).get('value', '')
+ if si_name:
+ si_name = si_name.rsplit('/', 1)[1]
+
to_si_factor = unit.get('tosi', {}).get('value', '')
if name not in results:
# ignore duplicate: always use the first one