summaryrefslogtreecommitdiff
path: root/utils/fetch_languages.py
diff options
context:
space:
mode:
authorDalf <alex@al-f.net>2020-08-06 17:42:46 +0200
committerAlexandre Flament <alex@al-f.net>2020-09-10 10:39:04 +0200
commit1022228d950c2a809ed613df1a515d9a6cafda7c (patch)
treed792dddea1a5b278b018ed4e024cd13340d5c1b1 /utils/fetch_languages.py
parent272158944bf13503e2597018fc60a00baddec660 (diff)
downloadsearxng-1022228d950c2a809ed613df1a515d9a6cafda7c.tar.gz
searxng-1022228d950c2a809ed613df1a515d9a6cafda7c.zip
Drop Python 2 (1/n): remove unicode string and url_utils
Diffstat (limited to 'utils/fetch_languages.py')
-rw-r--r--utils/fetch_languages.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/utils/fetch_languages.py b/utils/fetch_languages.py
index 77ec0bf20..0fb9d9c18 100644
--- a/utils/fetch_languages.py
+++ b/utils/fetch_languages.py
@@ -174,14 +174,17 @@ def write_languages_file(languages):
+ '# this file is generated automatically by utils/update_search_languages.py\n'\
+ '\nlanguage_codes = ('
for code in sorted(languages):
- file_content += '\n (u"' + code + '"'\
- + ', u"' + languages[code]['name'].split(' (')[0] + '"'\
- + ', u"' + languages[code].get('country', '') + '"'\
- + ', u"' + languages[code].get('english_name', '').split(' (')[0] + '"),'
+ if 'name' in languages[code]:
+ file_content += '\n ("' + code + '"'\
+ + ', "' + languages[code]['name'].split(' (')[0] + '"'\
+ + ', "' + languages[code].get('country', '') + '"'\
+ + ', "' + languages[code].get('english_name', '').split(' (')[0] + '"),'
+ else:
+ print('ignore ',languages[code])
# remove last comma
file_content = file_content[:-1]
file_content += '\n)\n'
- new_file.write(file_content.encode('utf8'))
+ new_file.write(file_content.encode())
new_file.close()