summaryrefslogtreecommitdiff
path: root/main/SCsub
diff options
context:
space:
mode:
authorViktor Ferenczi <viktor@ferenczi.eu>2018-03-10 18:37:33 +0100
committerViktor Ferenczi <viktor@ferenczi.eu>2018-03-11 14:55:50 +0100
commit272ecddb2859e3c184886bc2d142e2e329b8ae83 (patch)
tree8f76dbf6737196fbb66a1b379e1f18437f609173 /main/SCsub
parenteceba5aa6a36521c878cf976845123e820d27161 (diff)
Properly closing all files in Python code
Diffstat (limited to 'main/SCsub')
-rw-r--r--main/SCsub75
1 files changed, 37 insertions, 38 deletions
diff --git a/main/SCsub b/main/SCsub
index 5748bc38d2..aa9092ca51 100644
--- a/main/SCsub
+++ b/main/SCsub
@@ -8,60 +8,59 @@ def make_splash(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
- f = open(src, "rb")
- g = open(dst, "w")
- buf = f.read()
+ with open(src, "rb") as f:
+ buf = f.read()
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef BOOT_SPLASH_H\n")
- g.write("#define BOOT_SPLASH_H\n")
- g.write('static const Color boot_splash_bg_color = Color::html("#232323");\n')
- g.write("static const unsigned char boot_splash_png[] = {\n")
- for i in range(len(buf)):
- g.write(byte_to_str(buf[i]) + ",\n")
- g.write("};\n")
- g.write("#endif")
+ with open(dst, "w") as g:
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef BOOT_SPLASH_H\n")
+ g.write("#define BOOT_SPLASH_H\n")
+ g.write('static const Color boot_splash_bg_color = Color::html("#232323");\n')
+ g.write("static const unsigned char boot_splash_png[] = {\n")
+ for i in range(len(buf)):
+ g.write(byte_to_str(buf[i]) + ",\n")
+ g.write("};\n")
+ g.write("#endif")
def make_splash_editor(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
- f = open(src, "rb")
- g = open(dst, "w")
- buf = f.read()
-
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef BOOT_SPLASH_EDITOR_H\n")
- g.write("#define BOOT_SPLASH_EDITOR_H\n")
- g.write('static const Color boot_splash_editor_bg_color = Color::html("#232323");\n')
- g.write("static const unsigned char boot_splash_editor_png[] = {\n")
- for i in range(len(buf)):
- g.write(byte_to_str(buf[i]) + ",\n")
- g.write("};\n")
- g.write("#endif")
+ with open(src, "rb") as f:
+ buf = f.read()
+ with open(dst, "w") as g:
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef BOOT_SPLASH_EDITOR_H\n")
+ g.write("#define BOOT_SPLASH_EDITOR_H\n")
+ g.write('static const Color boot_splash_editor_bg_color = Color::html("#232323");\n')
+ g.write("static const unsigned char boot_splash_editor_png[] = {\n")
+ for i in range(len(buf)):
+ g.write(byte_to_str(buf[i]) + ",\n")
+ g.write("};\n")
+ g.write("#endif")
def make_app_icon(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
- f = open(src, "rb")
- g = open(dst, "w")
-
- buf = f.read()
-
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef APP_ICON_H\n")
- g.write("#define APP_ICON_H\n")
- g.write("static const unsigned char app_icon_png[] = {\n")
- for i in range(len(buf)):
- g.write(byte_to_str(buf[i]) + ",\n")
- g.write("};\n")
- g.write("#endif")
+
+ with open(src, "rb") as f:
+ buf = f.read()
+
+ with open(dst, "w") as g:
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("#ifndef APP_ICON_H\n")
+ g.write("#define APP_ICON_H\n")
+ g.write("static const unsigned char app_icon_png[] = {\n")
+ for i in range(len(buf)):
+ g.write(byte_to_str(buf[i]) + ",\n")
+ g.write("};\n")
+ g.write("#endif")
env.main_sources = []