diff options
Diffstat (limited to 'platform_methods.py')
-rw-r--r-- | platform_methods.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/platform_methods.py b/platform_methods.py index a05298bfa5..43e6e4f799 100644 --- a/platform_methods.py +++ b/platform_methods.py @@ -40,7 +40,7 @@ def run_in_subprocess(builder_function): args = (target, source, filtered_env) data = dict(fn=function_name, args=args) json_path = os.path.join(os.environ["TMP"], uuid.uuid4().hex + ".json") - with open(json_path, "wt") as json_file: + with open(json_path, "wt", encoding="utf-8", newline="\n") as json_file: json.dump(data, json_file, indent=2) json_file_size = os.stat(json_path).st_size @@ -124,21 +124,19 @@ def generate_export_icons(platform_path, platform_name): svg_names.append("run_icon") for name in svg_names: - svgf = open(export_path + "/" + name + ".svg", "rb") - b = svgf.read(1) - svg_str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" - svg_str += " static const char *_" + platform_name + "_" + name + '_svg = "' - while len(b) == 1: - svg_str += "\\" + hex(ord(b))[1:] + with open(export_path + "/" + name + ".svg", "rb") as svgf: b = svgf.read(1) + svg_str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" + svg_str += " static const char *_" + platform_name + "_" + name + '_svg = "' + while len(b) == 1: + svg_str += "\\" + hex(ord(b))[1:] + b = svgf.read(1) - svg_str += '";\n' - - svgf.close() + svg_str += '";\n' # NOTE: It is safe to generate this file here, since this is still executed serially. wf = export_path + "/" + name + "_svg.gen.h" - with open(wf, "w") as svgw: + with open(wf, "w", encoding="utf-8", newline="\n") as svgw: svgw.write(svg_str) |