summaryrefslogtreecommitdiffstats
path: root/modules/text_server_adv
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-03-10 12:09:48 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-03-10 12:57:57 -0500
commitfb299d0fb134c603eafe7737bab8d22ec0b1cd59 (patch)
tree7f8bfac3259a5c6f55d09c5e041357e98b3c7fe9 /modules/text_server_adv
parent0ace0a129284ffc6646b199699c1607a316fcec0 (diff)
downloadredot-engine-fb299d0fb134c603eafe7737bab8d22ec0b1cd59.tar.gz
SCons: Ensure `with` statement where applicable
Diffstat (limited to 'modules/text_server_adv')
-rw-r--r--modules/text_server_adv/SCsub41
-rw-r--r--modules/text_server_adv/gdextension_build/methods.py92
2 files changed, 66 insertions, 67 deletions
diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub
index 79950eaac3..6b53353ec9 100644
--- a/modules/text_server_adv/SCsub
+++ b/modules/text_server_adv/SCsub
@@ -9,27 +9,26 @@ env_text_server_adv = env_modules.Clone()
def make_icu_data(target, source, env):
dst = target[0].srcnode().abspath
- g = open(dst, "w", encoding="utf-8", newline="\n")
-
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("/* (C) 2016 and later: Unicode, Inc. and others. */\n")
- g.write("/* License & terms of use: https://www.unicode.org/copyright.html */\n")
- g.write("#ifndef _ICU_DATA_H\n")
- g.write("#define _ICU_DATA_H\n")
- g.write('#include "unicode/utypes.h"\n')
- g.write('#include "unicode/udata.h"\n')
- g.write('#include "unicode/uversion.h"\n')
-
- f = open(source[0].srcnode().abspath, "rb")
- buf = f.read()
-
- g.write('extern "C" U_EXPORT const size_t U_ICUDATA_SIZE = ' + str(len(buf)) + ";\n")
- g.write('extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {\n')
- for i in range(len(buf)):
- g.write("\t" + str(buf[i]) + ",\n")
-
- g.write("};\n")
- g.write("#endif")
+ with open(dst, "w", encoding="utf-8", newline="\n") as g:
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("/* (C) 2016 and later: Unicode, Inc. and others. */\n")
+ g.write("/* License & terms of use: https://www.unicode.org/copyright.html */\n")
+ g.write("#ifndef _ICU_DATA_H\n")
+ g.write("#define _ICU_DATA_H\n")
+ g.write('#include "unicode/utypes.h"\n')
+ g.write('#include "unicode/udata.h"\n')
+ g.write('#include "unicode/uversion.h"\n')
+
+ with open(source[0].srcnode().abspath, "rb") as f:
+ buf = f.read()
+
+ g.write('extern "C" U_EXPORT const size_t U_ICUDATA_SIZE = ' + str(len(buf)) + ";\n")
+ g.write('extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {\n')
+ for i in range(len(buf)):
+ g.write("\t" + str(buf[i]) + ",\n")
+
+ g.write("};\n")
+ g.write("#endif")
# Thirdparty source files
diff --git a/modules/text_server_adv/gdextension_build/methods.py b/modules/text_server_adv/gdextension_build/methods.py
index 8456149973..32dbc59fd4 100644
--- a/modules/text_server_adv/gdextension_build/methods.py
+++ b/modules/text_server_adv/gdextension_build/methods.py
@@ -83,56 +83,56 @@ def disable_warnings(self):
def make_icu_data(target, source, env):
dst = target[0].srcnode().abspath
- g = open(dst, "w", encoding="utf-8", newline="\n")
+ with open(dst, "w", encoding="utf-8", newline="\n") as g:
+ g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
+ g.write("/* (C) 2016 and later: Unicode, Inc. and others. */\n")
+ g.write("/* License & terms of use: https://www.unicode.org/copyright.html */\n")
+ g.write("#ifndef _ICU_DATA_H\n")
+ g.write("#define _ICU_DATA_H\n")
+ g.write('#include "unicode/utypes.h"\n')
+ g.write('#include "unicode/udata.h"\n')
+ g.write('#include "unicode/uversion.h"\n')
- g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("/* (C) 2016 and later: Unicode, Inc. and others. */\n")
- g.write("/* License & terms of use: https://www.unicode.org/copyright.html */\n")
- g.write("#ifndef _ICU_DATA_H\n")
- g.write("#define _ICU_DATA_H\n")
- g.write('#include "unicode/utypes.h"\n')
- g.write('#include "unicode/udata.h"\n')
- g.write('#include "unicode/uversion.h"\n')
+ with open(source[0].srcnode().abspath, "rb") as f:
+ buf = f.read()
- f = open(source[0].srcnode().abspath, "rb")
- buf = f.read()
+ g.write('extern "C" U_EXPORT const size_t U_ICUDATA_SIZE = ' + str(len(buf)) + ";\n")
+ g.write('extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {\n')
+ for i in range(len(buf)):
+ g.write("\t" + str(buf[i]) + ",\n")
- g.write('extern "C" U_EXPORT const size_t U_ICUDATA_SIZE = ' + str(len(buf)) + ";\n")
- g.write('extern "C" U_EXPORT const unsigned char U_ICUDATA_ENTRY_POINT[] = {\n')
- for i in range(len(buf)):
- g.write("\t" + str(buf[i]) + ",\n")
-
- g.write("};\n")
- g.write("#endif")
+ g.write("};\n")
+ g.write("#endif")
def write_macos_plist(target, binary_name, identifier, name):
os.makedirs(f"{target}/Resource/", exist_ok=True)
- f = open(f"{target}/Resource/Info.plist", "w", encoding="utf-8", newline="\n")
-
- f.write(f'<?xml version="1.0" encoding="UTF-8"?>\n')
- f.write(f'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n')
- f.write(f'<plist version="1.0">\n')
- f.write(f"<dict>\n")
- f.write(f"\t<key>CFBundleExecutable</key>\n")
- f.write(f"\t<string>{binary_name}</string>\n")
- f.write(f"\t<key>CFBundleIdentifier</key>\n")
- f.write(f"\t<string>{identifier}</string>\n")
- f.write(f"\t<key>CFBundleInfoDictionaryVersion</key>\n")
- f.write(f"\t<string>6.0</string>\n")
- f.write(f"\t<key>CFBundleName</key>\n")
- f.write(f"\t<string>{name}</string>\n")
- f.write(f"\t<key>CFBundlePackageType</key>\n")
- f.write(f"\t<string>FMWK</string>\n")
- f.write(f"\t<key>CFBundleShortVersionString</key>\n")
- f.write(f"\t<string>1.0.0</string>\n")
- f.write(f"\t<key>CFBundleSupportedPlatforms</key>\n")
- f.write(f"\t<array>\n")
- f.write(f"\t\t<string>MacOSX</string>\n")
- f.write(f"\t</array>\n")
- f.write(f"\t<key>CFBundleVersion</key>\n")
- f.write(f"\t<string>1.0.0</string>\n")
- f.write(f"\t<key>LSMinimumSystemVersion</key>\n")
- f.write(f"\t<string>10.14</string>\n")
- f.write(f"</dict>\n")
- f.write(f"</plist>\n")
+ with open(f"{target}/Resource/Info.plist", "w", encoding="utf-8", newline="\n") as f:
+ f.write(f'<?xml version="1.0" encoding="UTF-8"?>\n')
+ f.write(
+ f'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n'
+ )
+ f.write(f'<plist version="1.0">\n')
+ f.write(f"<dict>\n")
+ f.write(f"\t<key>CFBundleExecutable</key>\n")
+ f.write(f"\t<string>{binary_name}</string>\n")
+ f.write(f"\t<key>CFBundleIdentifier</key>\n")
+ f.write(f"\t<string>{identifier}</string>\n")
+ f.write(f"\t<key>CFBundleInfoDictionaryVersion</key>\n")
+ f.write(f"\t<string>6.0</string>\n")
+ f.write(f"\t<key>CFBundleName</key>\n")
+ f.write(f"\t<string>{name}</string>\n")
+ f.write(f"\t<key>CFBundlePackageType</key>\n")
+ f.write(f"\t<string>FMWK</string>\n")
+ f.write(f"\t<key>CFBundleShortVersionString</key>\n")
+ f.write(f"\t<string>1.0.0</string>\n")
+ f.write(f"\t<key>CFBundleSupportedPlatforms</key>\n")
+ f.write(f"\t<array>\n")
+ f.write(f"\t\t<string>MacOSX</string>\n")
+ f.write(f"\t</array>\n")
+ f.write(f"\t<key>CFBundleVersion</key>\n")
+ f.write(f"\t<string>1.0.0</string>\n")
+ f.write(f"\t<key>LSMinimumSystemVersion</key>\n")
+ f.write(f"\t<string>10.14</string>\n")
+ f.write(f"</dict>\n")
+ f.write(f"</plist>\n")