Skip to content

Commit 51729a4

Browse files
committed
scripts: use format() in macdeployqtplus
1 parent 1c37e81 commit 51729a4

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

contrib/macdeploy/macdeployqtplus

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ class FrameworkInfo(object):
4949
return False
5050

5151
def __str__(self):
52-
return """ Framework name: %s
53-
Framework directory: %s
54-
Framework path: %s
55-
Binary name: %s
56-
Binary directory: %s
57-
Binary path: %s
58-
Version: %s
59-
Install name: %s
60-
Deployed install name: %s
61-
Source file Path: %s
62-
Deployed Directory (relative to bundle): %s
63-
""" % (self.frameworkName,
52+
return """ Framework name: {}
53+
Framework directory: {}
54+
Framework path: {}
55+
Binary name: {}
56+
Binary directory: {}
57+
Binary path: {}
58+
Version: {}
59+
Install name: {}
60+
Deployed install name: {}
61+
Source file Path: {}
62+
Deployed Directory (relative to bundle): {}
63+
""".format(self.frameworkName,
6464
self.frameworkDirectory,
6565
self.frameworkPath,
6666
self.binaryName,
@@ -182,8 +182,8 @@ class DeploymentInfo(object):
182182
self.pluginPath = pluginPath
183183

184184
def usesFramework(self, name: str) -> bool:
185-
nameDot = "%s." % name
186-
libNameDot = "lib%s." % name
185+
nameDot = "{}.".format(name)
186+
libNameDot = "lib{}.".format(name)
187187
for framework in self.deployedFrameworks:
188188
if framework.endswith(".framework"):
189189
if framework.startswith(nameDot):
@@ -203,7 +203,7 @@ def getFrameworks(binaryPath: str, verbose: int) -> List[FrameworkInfo]:
203203
if verbose >= 1:
204204
sys.stderr.write(o_stderr)
205205
sys.stderr.flush()
206-
raise RuntimeError("otool failed with return code %d" % otool.returncode)
206+
raise RuntimeError("otool failed with return code {}".format(otool.returncode))
207207

208208
otoolLines = o_stdout.split("\n")
209209
otoolLines.pop(0) # First line is the inspected binary
@@ -359,7 +359,7 @@ def deployFrameworks(frameworks: List[FrameworkInfo], bundlePath: str, binaryPat
359359
def deployFrameworksForAppBundle(applicationBundle: ApplicationBundleInfo, strip: bool, verbose: int) -> DeploymentInfo:
360360
frameworks = getFrameworks(applicationBundle.binaryPath, verbose)
361361
if len(frameworks) == 0 and verbose >= 1:
362-
print("Warning: Could not find any external frameworks to deploy in %s." % (applicationBundle.path))
362+
print("Warning: Could not find any external frameworks to deploy in {}.".format(applicationBundle.path))
363363
return DeploymentInfo()
364364
else:
365365
return deployFrameworks(frameworks, applicationBundle.path, applicationBundle.binaryPath, strip, verbose)
@@ -500,7 +500,7 @@ app_bundle = config.app_bundle[0]
500500

501501
if not os.path.exists(app_bundle):
502502
if verbose >= 1:
503-
sys.stderr.write("Error: Could not find app bundle \"%s\"\n" % (app_bundle))
503+
sys.stderr.write("Error: Could not find app bundle \"{}\"\n".format(app_bundle))
504504
sys.exit(1)
505505

506506
app_bundle_name = os.path.splitext(os.path.basename(app_bundle))[0]
@@ -512,7 +512,7 @@ if config.translations_dir and config.translations_dir[0]:
512512
translations_dir = config.translations_dir[0]
513513
else:
514514
if verbose >= 1:
515-
sys.stderr.write("Error: Could not find translation dir \"%s\"\n" % (translations_dir))
515+
sys.stderr.write("Error: Could not find translation dir \"{}\"\n".format(translations_dir))
516516
sys.exit(1)
517517
# ------------------------------------------------
518518

@@ -521,7 +521,7 @@ for p in config.add_resources:
521521
print("Checking for \"%s\"..." % p)
522522
if not os.path.exists(p):
523523
if verbose >= 1:
524-
sys.stderr.write("Error: Could not find additional resource file \"%s\"\n" % (p))
524+
sys.stderr.write("Error: Could not find additional resource file \"{}\"\n".format(p))
525525
sys.exit(1)
526526

527527
# ------------------------------------------------
@@ -538,17 +538,17 @@ if len(config.fancy) == 1:
538538

539539
p = config.fancy[0]
540540
if verbose >= 3:
541-
print("Fancy: Loading \"%s\"..." % p)
541+
print("Fancy: Loading \"{}\"...".format(p))
542542
if not os.path.exists(p):
543543
if verbose >= 1:
544-
sys.stderr.write("Error: Could not find fancy disk image plist at \"%s\"\n" % (p))
544+
sys.stderr.write("Error: Could not find fancy disk image plist at \"{}\"\n".format(p))
545545
sys.exit(1)
546546

547547
try:
548548
fancy = plistlib.readPlist(p)
549549
except:
550550
if verbose >= 1:
551-
sys.stderr.write("Error: Could not parse fancy disk image plist at \"%s\"\n" % (p))
551+
sys.stderr.write("Error: Could not parse fancy disk image plist at \"{}\"\n".format(p))
552552
sys.exit(1)
553553

554554
try:
@@ -562,18 +562,18 @@ if len(config.fancy) == 1:
562562
assert isinstance(value, list) and len(value) == 2 and isinstance(value[0], int) and isinstance(value[1], int)
563563
except:
564564
if verbose >= 1:
565-
sys.stderr.write("Error: Bad format of fancy disk image plist at \"%s\"\n" % (p))
565+
sys.stderr.write("Error: Bad format of fancy disk image plist at \"{}\"\n".format(p))
566566
sys.exit(1)
567567

568568
if "background_picture" in fancy:
569569
bp = fancy["background_picture"]
570570
if verbose >= 3:
571-
print("Fancy: Resolving background picture \"%s\"..." % bp)
571+
print("Fancy: Resolving background picture \"{}\"...".format(bp))
572572
if not os.path.exists(bp):
573573
bp = os.path.join(os.path.dirname(p), bp)
574574
if not os.path.exists(bp):
575575
if verbose >= 1:
576-
sys.stderr.write("Error: Could not find background picture at \"%s\" or \"%s\"\n" % (fancy["background_picture"], bp))
576+
sys.stderr.write("Error: Could not find background picture at \"{}\" or \"{}\"\n".format(fancy["background_picture"], bp))
577577
sys.exit(1)
578578
else:
579579
fancy["background_picture"] = bp
@@ -624,7 +624,7 @@ try:
624624
config.plugins = False
625625
except RuntimeError as e:
626626
if verbose >= 1:
627-
sys.stderr.write("Error: %s\n" % str(e))
627+
sys.stderr.write("Error: {}\n".format(str(e)))
628628
sys.exit(1)
629629

630630
# ------------------------------------------------
@@ -637,7 +637,7 @@ if config.plugins:
637637
deployPlugins(applicationBundle, deploymentInfo, config.strip, verbose)
638638
except RuntimeError as e:
639639
if verbose >= 1:
640-
sys.stderr.write("Error: %s\n" % str(e))
640+
sys.stderr.write("Error: {}\n".format(str(e)))
641641
sys.exit(1)
642642

643643
# ------------------------------------------------
@@ -653,14 +653,14 @@ else:
653653
else:
654654
sys.stderr.write("Error: Could not find Qt translation path\n")
655655
sys.exit(1)
656-
add_qt_tr = ["qt_%s.qm" % lng for lng in config.add_qt_tr[0].split(",")]
656+
add_qt_tr = ["qt_{}.qm".format(lng) for lng in config.add_qt_tr[0].split(",")]
657657
for lng_file in add_qt_tr:
658658
p = os.path.join(qt_tr_dir, lng_file)
659659
if verbose >= 3:
660-
print("Checking for \"%s\"..." % p)
660+
print("Checking for \"{}\"...".format(p))
661661
if not os.path.exists(p):
662662
if verbose >= 1:
663-
sys.stderr.write("Error: Could not find Qt translation file \"%s\"\n" % (lng_file))
663+
sys.stderr.write("Error: Could not find Qt translation file \"{}\"\n".format(lng_file))
664664
sys.exit(1)
665665

666666
# ------------------------------------------------
@@ -701,8 +701,8 @@ if config.sign and 'CODESIGNARGS' not in os.environ:
701701
print("You must set the CODESIGNARGS environment variable. Skipping signing.")
702702
elif config.sign:
703703
if verbose >= 1:
704-
print("Code-signing app bundle %s"%(target,))
705-
subprocess.check_call("codesign --force %s %s"%(os.environ['CODESIGNARGS'], target), shell=True)
704+
print("Code-signing app bundle {}".format(target))
705+
subprocess.check_call("codesign --force {} {}".format(os.environ['CODESIGNARGS'], target), shell=True)
706706

707707
# ------------------------------------------------
708708

0 commit comments

Comments
 (0)