fix: unicode error on windows when writing the config file

This commit is contained in:
benex
2024-09-15 14:38:50 +03:00
parent 3ef7c5248c
commit 5d3c0cc6ec
2 changed files with 4 additions and 4 deletions

View File

@@ -94,8 +94,8 @@ def config(user_config: "Config", path, view, desktop_entry, update):
print(f"Successfully wrote \n{f.read()}")
exit_app(0)
elif update:
with open(USER_CONFIG_PATH, "w") as file:
file.write(user_config.__repr__())
with open(USER_CONFIG_PATH, "w",encoding="utf-8") as file:
file.write(user_config.__str__())
print("update successfull")
else:
click.edit(filename=USER_CONFIG_PATH)

View File

@@ -64,7 +64,7 @@ class Config(object):
# --- set config values from file or using defaults ---
if os.path.exists(USER_CONFIG_PATH):
self.configparser.read(USER_CONFIG_PATH)
self.configparser.read(USER_CONFIG_PATH,encoding="utf-8")
self.downloads_dir = self.get_downloads_dir()
self.sub_lang = self.get_sub_lang()
@@ -103,7 +103,7 @@ class Config(object):
os.environ["CURRENT_FASTANIME_PROVIDER"] = self.provider
if not os.path.exists(USER_CONFIG_PATH):
with open(USER_CONFIG_PATH, "w") as config:
with open(USER_CONFIG_PATH, "w",encoding="utf-8") as config:
config.write(self.__repr__())
def update_user(self, user):