diff options
author | marc <a01200356@itesm.mx> | 2016-12-15 00:34:43 -0600 |
---|---|---|
committer | marc <a01200356@itesm.mx> | 2016-12-15 00:40:21 -0600 |
commit | af35eee10b98940c51c6e5e18629de514b4bd48d (patch) | |
tree | 804b0a4cfe08bb897541e9e8571b921a78e07992 /utils/fetch_languages.py | |
parent | e0c270bd72f7b2a40222e3ed264e25d36cb0fc30 (diff) | |
download | searxng-af35eee10b98940c51c6e5e18629de514b4bd48d.tar.gz searxng-af35eee10b98940c51c6e5e18629de514b4bd48d.zip |
tests for _fetch_supported_languages in engines
and refactor method to make it testable without making requests
Diffstat (limited to 'utils/fetch_languages.py')
-rw-r--r-- | utils/fetch_languages.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/utils/fetch_languages.py b/utils/fetch_languages.py index ae4a2def9..aed875daf 100644 --- a/utils/fetch_languages.py +++ b/utils/fetch_languages.py @@ -84,7 +84,7 @@ def fetch_supported_languages(): # write json file f = io.open(engines_languages_file, "w", encoding="utf-8") - f.write(unicode(dumps(engines_languages, indent=4, ensure_ascii=False, encoding="utf-8"))) + f.write(unicode(dumps(engines_languages, ensure_ascii=False, encoding="utf-8"))) f.close() @@ -110,18 +110,22 @@ def join_language_lists(): else: languages[locale] = {} - # get locales that have no name yet + # get locales that have no name or country yet for locale in languages.keys(): if not languages[locale].get('name'): - # try to get language and country names + # try to get language names name = languages.get(locale.split('-')[0], {}).get('name', None) if name: languages[locale]['name'] = name - languages[locale]['country'] = get_country_name(locale) or '' languages[locale]['english_name'] = languages.get(locale.split('-')[0], {}).get('english_name', '') else: # filter out locales with no name del languages[locale] + continue + + # try to get country name + if locale.find('-') > 0 and not languages[locale].get('country'): + languages[locale]['country'] = get_country_name(locale) or '' # Remove countryless language if language is featured in only one country. |