@@ -1,8 +1,8 @@
1# SPDX-License-Identifier: AGPL-3.0-or-later
1# SPDX-License-Identifier: AGPL-3.0-or-later
5# lint: pylint
2# lint: pylint
6# pylint: disable=missing-function-docstring
6# pylint: disable=missing-function-docstring
@@ -151,16 +151,13 @@ def response(resp):
151 user_language = resp.search_params['language']
151 user_language = resp.search_params['language']
153 if resp.search_params['route']:
153 if resp.search_params['route']:
154− results.append(
154+ results.append({
156− 'answer': gettext('Get directions'),
155+ 'answer': gettext('Get directions'),
157− 'url': route_url.format(*resp.search_params['route'].groups()),
156+ 'url': route_url.format(*resp.search_params['route'].groups()),
161 fetch_wikidata(nominatim_json, user_language)
159 fetch_wikidata(nominatim_json, user_language)
164 for result in nominatim_json:
161 for result in nominatim_json:
165 title, address = get_title_address(result)
162 title, address = get_title_address(result)
@@ -173,29 +170,27 @@ def response(resp):
173 links, link_keys = get_links(result, user_language)
170 links, link_keys = get_links(result, user_language)
174 data = get_data(result, user_language, link_keys)
171 data = get_data(result, user_language, link_keys)
177− results.append(
173+ results.append({
179− 'template': 'map.html',
174+ 'template': 'map.html',
180− 'title': title,
175+ 'title': title,
181− 'address': address,
176+ 'address': address,
182− 'address_label': get_key_label('addr', user_language),
177+ 'address_label': get_key_label('addr', user_language),
183− 'url': url,
178+ 'url': url,
184− 'osm': osm,
179+ 'osm': osm,
185− 'geojson': geojson,
180+ 'geojson': geojson,
186− 'img_src': img_src,
181+ 'img_src': img_src,
187− 'links': links,
182+ 'links': links,
188− 'data': data,
183+ 'data': data,
184+ 'type': get_tag_label(
189− 'type': get_tag_label(result.get('category'), result.get('type', ''), user_language),
185+ result.get('category'), result.get('type', ''), user_language
190− 'type_icon': result.get('icon'),
187+ 'type_icon': result.get('icon'),
191− 'content': '',
188+ 'content': '',
192− 'longitude': result['lon'],
189+ 'longitude': result['lon'],
193− 'latitude': result['lat'],
190+ 'latitude': result['lat'],
194− 'boundingbox': result['boundingbox'],
191+ 'boundingbox': result['boundingbox'],
199 return results
194 return results
@@ -353,13 +348,11 @@ def get_links(result, user_language):
353 url, url_label = mapping_function(raw_value)
348 url, url_label = mapping_function(raw_value)
354 if url.startswith('https://wikidata.org'):
349 if url.startswith('https://wikidata.org'):
355 url_label = result.get('wikidata', {}).get('itemLabel') or url_label
350 url_label = result.get('wikidata', {}).get('itemLabel') or url_label
356− links.append(
351+ links.append({
358− 'label': get_key_label(k, user_language),
352+ 'label': get_key_label(k, user_language),
359− 'url': url,
353+ 'url': url,
360− 'url_label': url_label,
354+ 'url_label': url_label,
363 link_keys.add(k)
356 link_keys.add(k)
364 return links, link_keys
357 return links, link_keys
@@ -379,13 +372,11 @@ def get_data(result, user_language, ignore_keys):
380 k_label = get_key_label(k, user_language)
373 k_label = get_key_label(k, user_language)
381 if k_label:
374 if k_label:
382− data.append(
375+ data.append({
384− 'label': k_label,
376+ 'label': k_label,
385− 'key': k,
377+ 'key': k,
386− 'value': v,
378+ 'value': v,
389 data.sort(key=lambda entry: (get_key_rank(entry['key']), entry['label']))
380 data.sort(key=lambda entry: (get_key_rank(entry['key']), entry['label']))
390 return data
381 return data