@@ -1,8 +1,8 @@
11# SPDX-License-Identifier: AGPL-3.0-or-later
2−"""
3− OpenStreetMap (Map)
4−"""
52# lint: pylint
3+"""OpenStreetMap (Map)
4+
5+"""
66# pylint: disable=missing-function-docstring
77
88import re
@@ -151,16 +151,13 @@ def response(resp):
151151 user_language = resp.search_params['language']
152152
153153 if resp.search_params['route']:
154− results.append(
155− {
156− 'answer': gettext('Get directions'),
157− 'url': route_url.format(*resp.search_params['route'].groups()),
158− }
159− )
154+ results.append({
155+ 'answer': gettext('Get directions'),
156+ 'url': route_url.format(*resp.search_params['route'].groups()),
157+ })
160158
161159 fetch_wikidata(nominatim_json, user_language)
162160
163− # parse results
164161 for result in nominatim_json:
165162 title, address = get_title_address(result)
166163
@@ -173,29 +170,27 @@ def response(resp):
173170 links, link_keys = get_links(result, user_language)
174171 data = get_data(result, user_language, link_keys)
175172
176− # append result
177− results.append(
178− {
179− 'template': 'map.html',
180− 'title': title,
181− 'address': address,
182− 'address_label': get_key_label('addr', user_language),
183− 'url': url,
184− 'osm': osm,
185− 'geojson': geojson,
186− 'img_src': img_src,
187− 'links': links,
188− 'data': data,
189− 'type': get_tag_label(result.get('category'), result.get('type', ''), user_language),
190− 'type_icon': result.get('icon'),
191− 'content': '',
192− 'longitude': result['lon'],
193− 'latitude': result['lat'],
194− 'boundingbox': result['boundingbox'],
195− }
196− )
173+ results.append({
174+ 'template': 'map.html',
175+ 'title': title,
176+ 'address': address,
177+ 'address_label': get_key_label('addr', user_language),
178+ 'url': url,
179+ 'osm': osm,
180+ 'geojson': geojson,
181+ 'img_src': img_src,
182+ 'links': links,
183+ 'data': data,
184+ 'type': get_tag_label(
185+ result.get('category'), result.get('type', ''), user_language
186+ ),
187+ 'type_icon': result.get('icon'),
188+ 'content': '',
189+ 'longitude': result['lon'],
190+ 'latitude': result['lat'],
191+ 'boundingbox': result['boundingbox'],
192+ })
197193
198− # return results
199194 return results
200195
201196
@@ -353,13 +348,11 @@ def get_links(result, user_language):
353348 url, url_label = mapping_function(raw_value)
354349 if url.startswith('https://wikidata.org'):
355350 url_label = result.get('wikidata', {}).get('itemLabel') or url_label
356− links.append(
357− {
358− 'label': get_key_label(k, user_language),
359− 'url': url,
360− 'url_label': url_label,
361− }
362− )
351+ links.append({
352+ 'label': get_key_label(k, user_language),
353+ 'url': url,
354+ 'url_label': url_label,
355+ })
363356 link_keys.add(k)
364357 return links, link_keys
365358
@@ -379,13 +372,11 @@ def get_data(result, user_language, ignore_keys):
379372 continue
380373 k_label = get_key_label(k, user_language)
381374 if k_label:
382− data.append(
383− {
384− 'label': k_label,
385− 'key': k,
386− 'value': v,
387− }
388− )
375+ data.append({
376+ 'label': k_label,
377+ 'key': k,
378+ 'value': v,
379+ })
389380 data.sort(key=lambda entry: (get_key_rank(entry['key']), entry['label']))
390381 return data
391382