summaryrefslogtreecommitdiff
path: root/platform/android
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 /platform/android
parenteceba5aa6a36521c878cf976845123e820d27161 (diff)
Properly closing all files in Python code
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/SCsub20
1 files changed, 10 insertions, 10 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub
index d2285a82dd..8c08289932 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -41,10 +41,8 @@ prog = None
abspath = env.Dir(".").abspath
-gradle_basein = open_utf8(abspath + "/build.gradle.template", "r")
-gradle_baseout = open_utf8(abspath + "/java/build.gradle", "w")
-
-gradle_text = gradle_basein.read()
+with open_utf8(abspath + "/build.gradle.template", "r") as gradle_basein:
+ gradle_text = gradle_basein.read()
gradle_maven_flat_text = ""
if len(env.android_flat_dirs) > 0:
@@ -131,17 +129,19 @@ gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$", gradle_default_co
gradle_text = gradle_text.replace("$$GRADLE_PLUGINS$$", gradle_plugins)
gradle_text = gradle_text.replace("$$GRADLE_CLASSPATH$$", gradle_classpath)
-gradle_baseout.write(gradle_text)
-gradle_baseout.close()
+with open_utf8(abspath + "/java/build.gradle", "w") as gradle_baseout:
+ gradle_baseout.write(gradle_text)
+
+with open_utf8(abspath + "/AndroidManifest.xml.template", "r") as pp_basein:
+ manifest = pp_basein.read()
-pp_basein = open_utf8(abspath + "/AndroidManifest.xml.template", "r")
-pp_baseout = open_utf8(abspath + "/java/AndroidManifest.xml", "w")
-manifest = pp_basein.read()
manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$", env.android_manifest_chunk)
manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$", env.android_permission_chunk)
manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$", env.android_appattributes_chunk)
-pp_baseout.write(manifest)
+
+with open_utf8(abspath + "/java/AndroidManifest.xml", "w") as pp_baseout:
+ pp_baseout.write(manifest)
lib = env_android.add_shared_library("#bin/libgodot", [android_objects], SHLIBSUFFIX=env["SHLIBSUFFIX"])