From 93e93b7f8326c54b98840d535bfc22dcf6dab820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=BCnther?= Date: Thu, 25 Jul 2024 22:33:45 +0200 Subject: [PATCH] set encoding to utf-8 to fix generation on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Günther --- cimgen/languages/cpp/lang_pack.py | 4 ++-- cimgen/languages/java/lang_pack.py | 4 ++-- cimgen/languages/javascript/lang_pack.py | 4 ++-- cimgen/languages/python/lang_pack.py | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cimgen/languages/cpp/lang_pack.py b/cimgen/languages/cpp/lang_pack.py index 2698d92a..d81ccaae 100644 --- a/cimgen/languages/cpp/lang_pack.py +++ b/cimgen/languages/cpp/lang_pack.py @@ -74,9 +74,9 @@ def run_template(outputPath, class_details): for template_info in templates: class_file = os.path.join(outputPath, class_details["class_name"] + template_info["ext"]) if not os.path.exists(class_file): - with open(class_file, "w") as file: + with open(class_file, "w", encoding="utf-8") as file: templates = files("cimgen.languages.cpp.templates") - with templates.joinpath(template_info["filename"]).open() as f: + with templates.joinpath(template_info["filename"]).open(encoding="utf-8") as f: args = { "data": class_details, "template": f, diff --git a/cimgen/languages/java/lang_pack.py b/cimgen/languages/java/lang_pack.py index f9a0e4fd..06eedb93 100644 --- a/cimgen/languages/java/lang_pack.py +++ b/cimgen/languages/java/lang_pack.py @@ -66,10 +66,10 @@ def run_template(outputPath, class_details): for template_info in templates: class_file = os.path.join(outputPath, class_details["class_name"] + template_info["ext"]) if not os.path.exists(class_file): - with open(class_file, "w") as file: + with open(class_file, "w", encoding="utf-8") as file: class_details["setDefault"] = _set_default templates = files("cimgen.languages.java.templates") - with templates.joinpath(template_info["filename"]).open() as f: + with templates.joinpath(template_info["filename"]).open(encoding="utf-8") as f: args = { "data": class_details, "template": f, diff --git a/cimgen/languages/javascript/lang_pack.py b/cimgen/languages/javascript/lang_pack.py index 018b177b..d605e99b 100644 --- a/cimgen/languages/javascript/lang_pack.py +++ b/cimgen/languages/javascript/lang_pack.py @@ -190,9 +190,9 @@ def run_template(outputPath, class_details): def write_templated_file(class_file, class_details, template_filename): if not os.path.exists(class_file): - with open(class_file, "w") as file: + with open(class_file, "w", encoding="utf-8") as file: templates = files("cimgen.languages.javascript.templates") - with templates.joinpath(template_filename).open() as f: + with templates.joinpath(template_filename).open(encoding="utf-8") as f: args = {"data": class_details, "template": f, "partials_dict": partials} output = chevron.render(**args) file.write(output) diff --git a/cimgen/languages/python/lang_pack.py b/cimgen/languages/python/lang_pack.py index 40fc1242..a6ae58ac 100644 --- a/cimgen/languages/python/lang_pack.py +++ b/cimgen/languages/python/lang_pack.py @@ -80,10 +80,10 @@ def run_template(version_path, class_details): for template_info in template_files: class_file = os.path.join(version_path, class_details["class_name"] + template_info["ext"]) if not os.path.exists(class_file): - with open(class_file, "w") as file: + with open(class_file, "w", encoding="utf-8") as file: class_details["setDefault"] = _set_default templates = files("cimgen.languages.python.templates") - with templates.joinpath(template_info["filename"]).open() as f: + with templates.joinpath(template_info["filename"]).open(encoding="utf-8") as f: args = { "data": class_details, "template": f, @@ -95,7 +95,7 @@ def run_template(version_path, class_details): def _create_init(path): init_file = path + "/__init__.py" - with open(init_file, "w"): + with open(init_file, "w", encoding="utf-8"): pass @@ -118,7 +118,7 @@ def _create_base(path): " return dict\n", ] - with open(base_path, "w") as f: + with open(base_path, "w", encoding="utf-8") as f: for line in base: f.write(line) @@ -128,7 +128,7 @@ def resolve_headers(path): include_names = [] for filename in sorted(filenames): include_names.append(os.path.splitext(os.path.basename(filename))[0]) - with open(path + "/__init__.py", "w") as header_file: + with open(path + "/__init__.py", "w", encoding="utf-8") as header_file: for include_name in include_names: header_file.write("from " + "." + include_name + " import " + include_name + " as " + include_name + "\n") header_file.close()