diff options
author | Dalf <alex@al-f.net> | 2020-08-06 17:42:46 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2020-09-10 10:39:04 +0200 |
commit | 1022228d950c2a809ed613df1a515d9a6cafda7c (patch) | |
tree | d792dddea1a5b278b018ed4e024cd13340d5c1b1 /searx/preferences.py | |
parent | 272158944bf13503e2597018fc60a00baddec660 (diff) | |
download | searxng-1022228d950c2a809ed613df1a515d9a6cafda7c.tar.gz searxng-1022228d950c2a809ed613df1a515d9a6cafda7c.zip |
Drop Python 2 (1/n): remove unicode string and url_utils
Diffstat (limited to 'searx/preferences.py')
-rw-r--r-- | searx/preferences.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/searx/preferences.py b/searx/preferences.py index 82b8f5224..04098be25 100644 --- a/searx/preferences.py +++ b/searx/preferences.py @@ -6,16 +6,11 @@ from base64 import urlsafe_b64encode, urlsafe_b64decode from zlib import compress, decompress -from sys import version +from urllib.parse import parse_qs, urlencode from searx import settings, autocomplete from searx.languages import language_codes as languages from searx.utils import match_language -from searx.url_utils import parse_qs, urlencode - -if version[0] == '3': - # pylint: disable=invalid-name - unicode = str COOKIE_MAX_AGE = 60 * 60 * 24 * 365 * 5 # 5 years @@ -402,14 +397,14 @@ class Preferences(object): settings_kv['tokens'] = ','.join(self.tokens.values) - return urlsafe_b64encode(compress(urlencode(settings_kv).encode('utf-8'))).decode('utf-8') + return urlsafe_b64encode(compress(urlencode(settings_kv).encode())).decode() def parse_encoded_data(self, input_data): """parse (base64) preferences from request (``flask.request.form['preferences']``)""" - decoded_data = decompress(urlsafe_b64decode(input_data.encode('utf-8'))) + decoded_data = decompress(urlsafe_b64decode(input_data.encode())) dict_data = {} for x, y in parse_qs(decoded_data).items(): - dict_data[x.decode('utf8')] = y[0].decode('utf8') + dict_data[x.decode()] = y[0].decode() self.parse_dict(dict_data) def parse_dict(self, input_data): |