Set encoding correctly when opening files everywhere

Otherwise the encoding is interpreted differently on Windows and Mac.
This commit is contained in:
Ghostkeeper 2018-06-11 11:08:47 +02:00
parent c779795618
commit 54a03723ab
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A
8 changed files with 13 additions and 13 deletions

View file

@ -94,7 +94,7 @@ class VersionUpgrade22to24(VersionUpgrade):
if variant_path.endswith("_variant.inst.cfg"):
variant_path = variant_path[:-len("_variant.inst.cfg")] + "_settings.inst.cfg"
with open(os.path.join(machine_instances_dir, os.path.basename(variant_path)), "w") as fp:
with open(os.path.join(machine_instances_dir, os.path.basename(variant_path)), "w", encoding = "utf-8") as fp:
variant_config.write(fp)
return config_name
@ -105,9 +105,9 @@ class VersionUpgrade22to24(VersionUpgrade):
result = []
for entry in os.scandir(variants_dir):
if entry.name.endswith('.inst.cfg') and entry.is_file():
if entry.name.endswith(".inst.cfg") and entry.is_file():
config = configparser.ConfigParser(interpolation = None)
with open(entry.path, "r") as fhandle:
with open(entry.path, "r", encoding = "utf-8") as fhandle:
config.read_file(fhandle)
if config.has_section("general") and config.has_option("general", "name"):
result.append( { "path": entry.path, "name": config.get("general", "name") } )

View file

@ -249,11 +249,11 @@ class VersionUpgrade25to26(VersionUpgrade):
definition_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.DefinitionChangesContainer)
user_settings_dir = Resources.getPath(CuraApplication.ResourceTypes.UserInstanceContainer)
with open(os.path.join(definition_changes_dir, definition_changes_filename), "w") as f:
with open(os.path.join(definition_changes_dir, definition_changes_filename), "w", encoding = "utf-8") as f:
f.write(definition_changes_output.getvalue())
with open(os.path.join(user_settings_dir, user_settings_filename), "w") as f:
with open(os.path.join(user_settings_dir, user_settings_filename), "w", encoding = "utf-8") as f:
f.write(user_settings_output.getvalue())
with open(os.path.join(extruder_stack_dir, extruder_filename), "w") as f:
with open(os.path.join(extruder_stack_dir, extruder_filename), "w", encoding = "utf-8") as f:
f.write(extruder_output.getvalue())
## Creates a definition changes container which doesn't contain anything for the Custom FDM Printers.