setting encoding for file opening

This commit is contained in:
DYefremov
2021-02-28 21:22:22 +03:00
parent a0e3566bec
commit 3b23ddc1a7
4 changed files with 6 additions and 6 deletions

View File

@@ -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))

View File

@@ -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)

View File

@@ -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=" ")

View File

@@ -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)