Skip to content

Commit

Permalink
set encoding to utf-8 to fix generation on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Günther <[email protected]>
  • Loading branch information
tom-hg57 committed Jul 25, 2024
1 parent c406409 commit 93e93b7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cimgen/languages/cpp/lang_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions cimgen/languages/java/lang_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions cimgen/languages/javascript/lang_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions cimgen/languages/python/lang_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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


Expand All @@ -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)

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

0 comments on commit 93e93b7

Please sign in to comment.