From 3b23ddc1a7ff522363b0ade5754a885d6dd06dbe Mon Sep 17 00:00:00 2001 From: DYefremov Date: Sun, 28 Feb 2021 21:22:22 +0300 Subject: [PATCH] setting encoding for file opening --- app/eparser/enigma/blacklist.py | 4 ++-- app/eparser/enigma/lamedb.py | 2 +- app/settings.py | 4 ++-- app/ui/dialogs.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/eparser/enigma/blacklist.py b/app/eparser/enigma/blacklist.py index e3fba887..f36655c7 100644 --- a/app/eparser/enigma/blacklist.py +++ b/app/eparser/enigma/blacklist.py @@ -9,7 +9,7 @@ __FILE_NAME = "blacklist" def get_blacklist(path): with suppress(FileNotFoundError): - with open(path + __FILE_NAME, "r") as file: + with open(path + __FILE_NAME, "r", encoding="utf-8") as file: # filter empty values and "\n" return set(filter(None, (x.strip() for x in file.readlines()))) @@ -17,7 +17,7 @@ def get_blacklist(path): def write_blacklist(path, channels): - with open(path + __FILE_NAME, "w") as file: + with open(path + __FILE_NAME, "w", encoding="utf-8") as file: if channels: file.writelines("\n".join(channels)) diff --git a/app/eparser/enigma/lamedb.py b/app/eparser/enigma/lamedb.py index 59de230b..46029ad0 100644 --- a/app/eparser/enigma/lamedb.py +++ b/app/eparser/enigma/lamedb.py @@ -299,7 +299,7 @@ class LameDbWriter: lines.extend(services_lines) lines.append(_END_LINE) - with open(self._path + "lamedb5", "w") as file: + with open(self._path + "lamedb5", "w", encoding="utf-8") as file: file.writelines(lines) diff --git a/app/settings.py b/app/settings.py index 3a739174..5a3e9a32 100644 --- a/app/settings.py +++ b/app/settings.py @@ -43,7 +43,7 @@ def get_settings(): if not os.path.isfile(CONFIG_FILE) or os.stat(CONFIG_FILE).st_size == 0: write_settings(get_default_settings()) - with open(CONFIG_FILE, "r") as config_file: + with open(CONFIG_FILE, "r", encoding="utf-8") as config_file: return json.load(config_file) @@ -77,7 +77,7 @@ def get_default_transcoding_presets(): def write_settings(config): os.makedirs(os.path.dirname(CONFIG_PATH), exist_ok=True) - with open(CONFIG_FILE, "w") as config_file: + with open(CONFIG_FILE, "w", encoding="utf-8") as config_file: json.dump(config, config_file, indent=" ") diff --git a/app/ui/dialogs.py b/app/ui/dialogs.py index bca3e753..cc0e693b 100644 --- a/app/ui/dialogs.py +++ b/app/ui/dialogs.py @@ -182,7 +182,7 @@ def get_message(message): @lru_cache(maxsize=5) def get_dialogs_string(path): - with open(path, "r") as f: + with open(path, "r", encoding="utf-8") as f: return "".join(f)