on master help sign in
[fix] openstreetmap - fix some minor whitespace & indentation issues
eabdf1bMarkus Heiser
searx/engines/openstreetmap.py+37−46
@@ -1,8 +1,8 @@
1# SPDX-License-Identifier: AGPL-3.0-or-later
1# SPDX-License-Identifier: AGPL-3.0-or-later
2−"""
3− OpenStreetMap (Map)
4−"""
5# lint: pylint
2# lint: pylint
3+"""OpenStreetMap (Map)
4+
5+"""
6# pylint: disable=missing-function-docstring
6# pylint: disable=missing-function-docstring
7
7
8import re
8import re
@@ -151,16 +151,13 @@ def response(resp):
151 user_language = resp.search_params['language']
151 user_language = resp.search_params['language']
152
152
153 if resp.search_params['route']:
153 if resp.search_params['route']:
154− results.append(
154+ results.append({
155− {
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()),
158− }
157+ })
159− )
160
158
161 fetch_wikidata(nominatim_json, user_language)
159 fetch_wikidata(nominatim_json, user_language)
162
160
163− # parse results
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)
166
163
@@ -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)
175
172
176− # append result
177− results.append(
173+ results.append({
178− {
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
186+ ),
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'],
195− }
192+ })
196− )
197
193
198− # return results
199 return results
194 return results
200
195
201
196
@@ -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({
357− {
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,
361− }
355+ })
362− )
363 link_keys.add(k)
356 link_keys.add(k)
364 return links, link_keys
357 return links, link_keys
365
358
@@ -379,13 +372,11 @@ def get_data(result, user_language, ignore_keys):
379 continue
372 continue
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({
383− {
384− 'label': k_label,
376+ 'label': k_label,
385− 'key': k,
377+ 'key': k,
386− 'value': v,
378+ 'value': v,
387− }
379+ })
388− )
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
391
382
searx/static/themes/simple/less/style.less−3
@@ -325,9 +325,6 @@ article.result-images[data-vim-selected]::before {
325 text-align: left;
325 text-align: left;
326 }
326 }
327 }
327 }
328−
329−
330−
331}
328}
332
329
333.torrent_result {
330.torrent_result {
searx/templates/oscar/result_templates/map.html+1−1
@@ -59,7 +59,7 @@
59 <span><a class="text-info btn-collapse collapsed searx_init_map cursor-pointer disabled_if_nojs" data-toggle="collapse" data-target="#result-map-{{ index }}" data-leaflet-target="osm-map-{{ index }}" data-map-lon="{{ result.longitude }}" data-map-lat="{{ result.latitude }}" {% if result.boundingbox %}data-map-boundingbox='{{ result.boundingbox|tojson|safe }}'{% endif %} {% if result.geojson %}data-map-geojson='{{ result.geojson|tojson|safe }}'{% endif %} data-btn-text-collapsed="{{ _('show map') }}" data-btn-text-not-collapsed="{{ _('hide map') }}">{{ icon('globe') }} {{ _('show map') }}</a></span>
59 <span><a class="text-info btn-collapse collapsed searx_init_map cursor-pointer disabled_if_nojs" data-toggle="collapse" data-target="#result-map-{{ index }}" data-leaflet-target="osm-map-{{ index }}" data-map-lon="{{ result.longitude }}" data-map-lat="{{ result.latitude }}" {% if result.boundingbox %}data-map-boundingbox='{{ result.boundingbox|tojson|safe }}'{% endif %} {% if result.geojson %}data-map-geojson='{{ result.geojson|tojson|safe }}'{% endif %} data-btn-text-collapsed="{{ _('show map') }}" data-btn-text-not-collapsed="{{ _('hide map') }}">{{ icon('globe') }} {{ _('show map') }}</a></span>
60 {%- endif -%}
60 {%- endif -%}
61 </p>
61 </p>
62−
62+
63 </div>
63 </div>
64
64
65{%- if (result.latitude and result.longitude) or result.boundingbox -%}
65{%- if (result.latitude and result.longitude) or result.boundingbox -%}