searx/data/engines_languages.json: sort json file (no content change)

To get meaningfull diffs, the json file has to be sorted.  Before applying any
further content patch, the json file needs a inital sort (without changing any
content).

Sorted by::

  import sys, json

  with open('engines_languages.json') as f:
      j = json.load(f)

  with open('engines_languages.json', 'w') as f:
      json.dump(j, f, indent=2, sort_keys=True)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2020-03-01 07:56:46 +01:00
parent 2f6f9665a9
commit 40843fe95a
3 changed files with 27508 additions and 27492 deletions

View File

@ -27,6 +27,7 @@ help:
@echo ' uninstall - uninstall (./local)' @echo ' uninstall - uninstall (./local)'
@echo ' gh-pages - build docs & deploy on gh-pages branch' @echo ' gh-pages - build docs & deploy on gh-pages branch'
@echo ' clean - drop builds and environments' @echo ' clean - drop builds and environments'
@echo ' project - re-build generic files of the searx project'
@echo '' @echo ''
@$(MAKE) -s -f utils/makefile.include make-help @$(MAKE) -s -f utils/makefile.include make-help
@echo '' @echo ''
@ -67,6 +68,18 @@ docs-live: pyenvinstall sphinx-live
$(GH_PAGES):: $(GH_PAGES)::
@echo "doc available at --> $(DOCS_URL)" @echo "doc available at --> $(DOCS_URL)"
# update project files
# --------------------
PHONY += project engines-languages
project: searx/data/engines_languages.json
searx/data/engines_languages.json: pyenvinstall
$(PY_ENV_ACT); python utils/fetch_languages.py
mv engines_languages.json searx/data/engines_languages.json
mv languages.py searx/languages.py
# test # test
# ---- # ----

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
# Output files (engines_languages.json and languages.py) # Output files (engines_languages.json and languages.py)
# are written in current directory to avoid overwriting in case something goes wrong. # are written in current directory to avoid overwriting in case something goes wrong.
from json import dump import json
import io import io
from sys import path from sys import path
from babel import Locale, UnknownLocaleError from babel import Locale, UnknownLocaleError
@ -22,19 +22,22 @@ languages_file = 'languages.py'
# Fetchs supported languages for each engine and writes json file with those. # Fetchs supported languages for each engine and writes json file with those.
def fetch_supported_languages(): def fetch_supported_languages():
engines_languages = {} engines_languages = {}
for engine_name in engines: names = list(engines)
names.sort()
for engine_name in names:
print("fetching languages of engine %s" % engine_name)
if hasattr(engines[engine_name], 'fetch_supported_languages'): if hasattr(engines[engine_name], 'fetch_supported_languages'):
try: engines_languages[engine_name] = engines[engine_name].fetch_supported_languages()
engines_languages[engine_name] = engines[engine_name].fetch_supported_languages() if type(engines_languages[engine_name]) == list:
if type(engines_languages[engine_name]) == list: engines_languages[engine_name] = sorted(engines_languages[engine_name])
engines_languages[engine_name] = sorted(engines_languages[engine_name])
except Exception as e:
print(e)
# write json file # write json file
with io.open(engines_languages_file, "w", encoding="utf-8") as f: with open(engines_languages_file, 'w', encoding='utf-8') as f:
dump(engines_languages, f, ensure_ascii=False, indent=4, separators=(',', ': ')) json.dump(engines_languages, f, indent=2, sort_keys=True)
return engines_languages return engines_languages