diff options
author | Viktor Ferenczi <viktor@ferenczi.eu> | 2018-03-10 18:37:33 +0100 |
---|---|---|
committer | Viktor Ferenczi <viktor@ferenczi.eu> | 2018-03-11 14:55:50 +0100 |
commit | 272ecddb2859e3c184886bc2d142e2e329b8ae83 (patch) | |
tree | 8f76dbf6737196fbb66a1b379e1f18437f609173 /misc | |
parent | eceba5aa6a36521c878cf976845123e820d27161 (diff) |
Properly closing all files in Python code
Diffstat (limited to 'misc')
-rw-r--r-- | misc/scripts/fix_headers.py | 8 | ||||
-rw-r--r-- | misc/scripts/make_glwrapper.py | 9 |
2 files changed, 11 insertions, 6 deletions
diff --git a/misc/scripts/fix_headers.py b/misc/scripts/fix_headers.py index 809820c20f..48b9628b1f 100644 --- a/misc/scripts/fix_headers.py +++ b/misc/scripts/fix_headers.py @@ -92,9 +92,11 @@ while (fname != ""): fileread.close() # Write - fileread = open(fname.strip(), "wb") - fileread.write(text) - fileread.close() + filewrite = open(fname.strip(), "wb") + filewrite.write(text) + filewrite.close() # Next file fname = files.readline() + +files.close()
\ No newline at end of file diff --git a/misc/scripts/make_glwrapper.py b/misc/scripts/make_glwrapper.py index 5694d2327e..15b66a950b 100644 --- a/misc/scripts/make_glwrapper.py +++ b/misc/scripts/make_glwrapper.py @@ -16,9 +16,7 @@ READ_CONSTANTS = 2 read_what = READ_TYPES -for x in (range(len(sys.argv) - 1)): - f = open(sys.argv[x + 1], "r") - +def read_file(f): while(True): line = f.readline() @@ -86,6 +84,9 @@ for x in (range(len(sys.argv) - 1)): functions.append(funcdata) print(funcdata) +for path in sys.argv[1:]: + with open(path, "r") as f: + read_file(f) # print(types) # print(constants) @@ -156,6 +157,7 @@ f.write("void glWrapperInit( GLWrapperFuncPtr (*wrapperFunc)(const char*) );\n") f.write("#ifdef __cplusplus\n}\n#endif\n") f.write("#endif\n\n") +f.close() f = open("glwrapper.c", "w") @@ -176,3 +178,4 @@ for x in functions: f.write("\n\n") f.write("}\n") f.write("\n\n") +f.close() |