Remove use of f-strings in wscripts
authorCarl Hetherington <cth@carlh.net>
Sun, 5 May 2024 09:58:18 +0000 (11:58 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 May 2024 18:42:22 +0000 (20:42 +0200)
Various Linux build environments have a python that is too old.

platform/windows/wscript
src/tools/wscript

index 9ddffca45a2eed8ec57b14ba1a4c7f6b76ed62c6..2f0bf2c22bd88ae5e72bf9f0d22494ee3c9fc7ac 100644 (file)
@@ -21,7 +21,7 @@ def verifier_name(variant):
     return 'Verifier'
 
 def tool_name(variant, debug, tool):
-    name = f'DCP-o-matic 2 {tool}'
+    name = 'DCP-o-matic 2 %s' % tool
     if debug:
         name += ' debug'
     return name
@@ -32,7 +32,7 @@ def start_menu_shortcut(file, link, target, variant, debug=False):
     folder = start_menu_shortcut_folder(variant)
     if debug:
         folder += ' debug'
-    print(f'CreateShortCut "$SMPROGRAMS\\{folder}\\{link}.lnk" "$INSTDIR\\{target}"', file=file)
+    print('CreateShortCut "$SMPROGRAMS\\%s\\%s.lnk" "$INSTDIR\\%s"' % (folder, link, target), file=file)
 
 
 def write_installer(bits, dcpomatic_version, debug, disk, variant):
@@ -72,11 +72,11 @@ def write_installer(bits, dcpomatic_version, debug, disk, variant):
     if bits == 64:
         print('!include "x64.nsh"', file=f)
 
-    print(f'Name "{short_name_with_debug}"', file=f)
+    print('Name "%s"' % short_name_with_debug, file=f)
     print('RequestExecutionLevel admin', file=f)
     print('Unicode true', file=f)
 
-    outfile = f'{short_name_with_debug} {dcpomatic_version} {bits}-bit Installer.exe'
+    outfile = '%s %s %d-bit Installer.exe' % (short_name_with_debug, dcpomatic_version, bits)
     print('outFile "%s"' % outfile, file=f)
 
     print("""
@@ -91,7 +91,7 @@ def write_installer(bits, dcpomatic_version, debug, disk, variant):
     else:
         program_files = "$PROGRAMFILES"
 
-    print(f'InstallDir "%s\\{long_name_with_debug}"' % program_files, file=f)
+    print('InstallDir "%s\\%s"' % (program_files, long_name_with_debug), file=f)
 
     print("""
 !insertmacro MUI_PAGE_WELCOME
@@ -404,12 +404,12 @@ File "%cdist_deps%/share/libdcp/ratings"
 SectionEnd
     """, file=f)
 
-    print(f'Section "{long_name_with_debug}" SEC_MASTER', file=f)
+    print('Section "%s" SEC_MASTER' % long_name_with_debug, file=f)
 
     print('SetOutPath "$INSTDIR\\bin"', file=f)
     print("SetShellVarContext all", file=f)
 
-    print(f'CreateDirectory "$SMPROGRAMS\\{long_name_with_debug}"', file=f)
+    print('CreateDirectory "$SMPROGRAMS\\%s"' % long_name_with_debug, file=f)
 
     print('File "%binaries%/src/tools/dcpomatic2.exe"', file=f)
     for s, l in tools:
@@ -422,19 +422,19 @@ File "%binaries%/src/tools/dcpomatic2_disk_writer.exe.manifest"
     """, file=f)
 
     suffix = '_debug.bat' if debug else '.exe'
-    start_menu_shortcut(f, long_name_with_debug, f'bin\\dcpomatic2{suffix}', variant, debug=True)
+    start_menu_shortcut(f, long_name_with_debug, 'bin\\dcpomatic2%s' % suffix, variant, debug=True)
     for s, l in tools:
-        start_menu_shortcut(f, tool_name(variant, debug, l), f'bin\\dcpomatic2_{s}{suffix}', variant, debug=True)
-    start_menu_shortcut(f, f'Uninstall {long_name_with_debug}', 'Uninstall.exe', variant, debug=True)
-    print(f'WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{long_name_with_debug}" "DisplayName" "{long_name_with_debug} (remove only)"', file=f)
-    print(f'WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{long_name_with_debug}" "UninstallString" "$INSTDIR\\Uninstall.exe"', file=f)
+        start_menu_shortcut(f, tool_name(variant, debug, l), 'bin\\dcpomatic2_%s%s' % (s, suffix), variant, debug=True)
+    start_menu_shortcut(f, 'Uninstall %s' % long_name_with_debug, 'Uninstall.exe', variant, debug=True)
+    print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s" "DisplayName" "%s (remove only)"' % (long_name_with_debug, long_name_with_debug), file=f)
+    print('WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s" "UninstallString" "$INSTDIR\\Uninstall.exe"' % long_name_with_debug, file=f)
 
     print("SectionEnd", file=f)
 
-    print(f'Section "{long_name_with_debug} desktop shortcuts" SEC_MASTER_DESKTOP', file=f)
-    print(f'CreateShortCut "$DESKTOP\\{long_name_with_debug}.lnk" "$INSTDIR\\bin\\dcpomatic2{suffix}" ""', file=f)
+    print('Section "%s desktop shortcuts" SEC_MASTER_DESKTOP' % long_name_with_debug, file=f)
+    print('CreateShortCut "$DESKTOP\\%s.lnk" "$INSTDIR\\bin\\dcpomatic2%s" ""' % (long_name_with_debug, suffix), file=f)
     for s, l in tools:
-        print(f'CreateShortCut "$DESKTOP\\{tool_name(variant, debug, l)}.lnk" "$INSTDIR\\bin\\dcpomatic2_{s}{suffix}" ""', file=f)
+        print('CreateShortCut "$DESKTOP\\%s.lnk" "$INSTDIR\\bin\\dcpomatic2_%s%s" ""' % (tool_name(variant, debug, l), s, suffix), file=f)
 
     print("SectionEnd", file=f)
 
index 5375ae430c0e0fa2947a025530513c51ae354ffe..7d03bab62ac207ed1cbfafd451e7da533597bcc8 100644 (file)
@@ -38,7 +38,7 @@ def description(tool, variant):
 
 
 def make_rc(tool, icon, variant):
-    filename = f'build/src/tools/{tool}.rc'
+    filename = 'build/src/tools/%s.rc' % tool
     with open(filename, 'w') as rc:
         if tool == 'dcpomatic_disk_writer':
             print('#include "winuser.h"', file=rc)
@@ -58,8 +58,8 @@ def make_rc(tool, icon, variant):
     </trustInfo>
 </assembly>""", file=manifest)
         else:
-            print(f"""
-id ICON "../../graphics/windows/{icon}"
+            print("""
+id ICON "../../graphics/windows/%s"
 #include "wx-3.1/wx/msw/wx.rc"
 VS_VERSION_INFO VERSIONINFO
  FILEVERSION    0,0,0,2
@@ -73,20 +73,20 @@ VS_VERSION_INFO VERSIONINFO
  FILEOS 0x4L
  FILETYPE 0x1L
  FILESUBTYPE 0x0L
-{{
+ {
     BLOCK "StringFileInfo"
-    {{
+    {
         BLOCK "040904b0"
-        {{
-            VALUE "FileDescription", "{description(tool, variant)}\\0"
-        }}
-    }}
+        {
+            VALUE "FileDescription", "%s\\0"
+        }
+    }
     BLOCK "VarFileInfo"
-    {{
+    {
         VALUE "Translation", 0x409, 1200
-    }}
-}}
-    """, file=rc)
+    }
+ }
+    """ % (icon, description(tool, variant)), file=rc)
     return filename
 
 def configure(conf):
@@ -125,7 +125,7 @@ def build(bld):
         obj.use    = ['libdcpomatic2']
         obj.source = '%s.cc' % t
         if (bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32) and t == 'dcpomatic_disk_writer':
-            obj.source += f' ../../{make_rc(t, None, bld.env.VARIANT)}'
+            obj.source += ' ../../%s' % (make_rc(t, None, bld.env.VARIANT))
             # Prevent a console window opening when we start dcpomatic2_disk_writer
             obj.env.append_value('LINKFLAGS', '-Wl,-subsystem,windows')
         obj.target = t.replace('dcpomatic', 'dcpomatic2')
@@ -162,7 +162,7 @@ def build(bld):
         obj.use    = ['libdcpomatic2', 'libdcpomatic2-wx']
         obj.source = '%s.cc' % t
         if bld.env.TARGET_WINDOWS_64 or bld.env.TARGET_WINDOWS_32:
-            obj.source += f' ../../{make_rc(t, t.replace("dcpomatic", "dcpomatic2") + ".ico", bld.env.VARIANT)}'
+            obj.source += ' ../../%s' % make_rc(t, t.replace("dcpomatic", "dcpomatic2") + ".ico", bld.env.VARIANT)
         obj.target = t.replace('dcpomatic', 'dcpomatic2')
 
     i18n.po_to_mo(os.path.join('src', 'tools'), 'dcpomatic2', bld)