From 01f2fb682a7ae7ea3f32b30141795557383151f1 Mon Sep 17 00:00:00 2001 From: MarkusRost <2701034-MarkusRost@users.noreply.gitlab.com> Date: Thu, 29 Apr 2021 06:12:27 +0000 Subject: [PATCH] Encode ALL files to utf8 --- scripts/configbuilder.py | 8 ++++---- src/migrations/11311.py | 2 +- src/migrations/utils.py | 2 +- src/rcgcdw.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/configbuilder.py b/scripts/configbuilder.py index 9c02d73..8677506 100644 --- a/scripts/configbuilder.py +++ b/scripts/configbuilder.py @@ -196,7 +196,7 @@ def yes_no(answer): print("Welcome in RcGcDw config builder! This script is still work in progress so beware! You can accept the default value if provided in the question by using Enter key without providing any other input.\nWARNING! Your current settings.json will be overwritten if you continue!") try: # load settings - with open("../settings.json.example") as sfile: + with open("../settings.json.example", encoding="utf-8") as sfile: settings = json.load(sfile) except FileNotFoundError: if yes_no(default_or_custom(input("Template config (settings.json.example) could not be found. Download the most recent stable one from master branch? (https://gitlab.com/piotrex43/RcGcDw/raw/master/settings.json.example)? (Y/n)"), "y")): @@ -468,7 +468,7 @@ class AdvancedSettings: try: BasicSettings() shutil.copy("settings.json", "settings.json.bak") - with open("settings.json", "w") as settings_file: + with open("settings.json", "w", encoding="utf-8") as settings_file: settings_file.write(json.dumps(settings, indent=4)) if "--advanced" in sys.argv: print("Basic part of the config has been completed. Starting the advanced part...") @@ -478,5 +478,5 @@ except KeyboardInterrupt: if not yes_no(default_or_custom(input("\nSave the config before exiting? (y/N)"),"n")): sys.exit(0) else: - with open("settings.json", "w") as settings_file: - settings_file.write(json.dumps(settings, indent=4)) \ No newline at end of file + with open("settings.json", "w", encoding="utf-8") as settings_file: + settings_file.write(json.dumps(settings, indent=4)) diff --git a/src/migrations/11311.py b/src/migrations/11311.py index ec966b2..9ead1da 100644 --- a/src/migrations/11311.py +++ b/src/migrations/11311.py @@ -35,7 +35,7 @@ def run(): logger.exception("Failed to migrate appearance embed.") sys.exit(1) shutil.copy("settings.json", "settings.json.{}.bak".format(int(time.time()))) - with open("settings.json", "w") as new_write: + with open("settings.json", "w", encoding="utf-8") as new_write: new_write.write(json.dumps(new_settings, indent=4)) load_settings() logger.info("Migration 1.13.1.1 has been successful.") diff --git a/src/migrations/utils.py b/src/migrations/utils.py index fc448f1..5e66bc8 100644 --- a/src/migrations/utils.py +++ b/src/migrations/utils.py @@ -9,7 +9,7 @@ def return_example_file(force=False) -> dict: try: if force: raise FileNotFoundError - with open('settings.json.example', 'r') as example_file: + with open('settings.json.example', 'r', encoding="utf-8") as example_file: return json.loads(example_file.read()) except FileNotFoundError: try: diff --git a/src/rcgcdw.py b/src/rcgcdw.py index 2bd33e5..a9b0d41 100644 --- a/src/rcgcdw.py +++ b/src/rcgcdw.py @@ -52,7 +52,7 @@ storage = datafile # Remove previous data holding file if exists and limitfetch allows if settings["limitrefetch"] != -1 and os.path.exists("lastchange.txt") is True: - with open("lastchange.txt", 'r') as sfile: + with open("lastchange.txt", 'r', encoding="utf-8") as sfile: logger.info("Converting old lastchange.txt file into new data storage data.json...") storage["rcid"] = int(sfile.read().strip()) datafile.save_datafile()