Encode ALL files to utf8

This commit is contained in:
MarkusRost 2021-04-29 06:12:27 +00:00
parent 65400f3fb5
commit 01f2fb682a
4 changed files with 7 additions and 7 deletions

View file

@ -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:
with open("settings.json", "w", encoding="utf-8") as settings_file:
settings_file.write(json.dumps(settings, indent=4))

View file

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

View file

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

View file

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