aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-03-04 17:16:11 -0500
committerEli Schwartz <eschwartz@archlinux.org>2021-03-04 17:16:11 -0500
commit6a0fabc6472f49621260de215f128a31ae70219b (patch)
tree6a67908358a2c5e5baa215fe0201dfe213dd8a01 /mesonbuild/scripts
parent4340bf34faca7eed8076ba4c388fbe15355f2183 (diff)
downloadmeson-6a0fabc6472f49621260de215f128a31ae70219b.zip
meson-6a0fabc6472f49621260de215f128a31ae70219b.tar.gz
meson-6a0fabc6472f49621260de215f128a31ae70219b.tar.bz2
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/cleantrees.py2
-rwxr-xr-xmesonbuild/scripts/cmake_run_ctgt.py2
-rw-r--r--mesonbuild/scripts/coverage.py4
-rw-r--r--mesonbuild/scripts/depscan.py10
-rw-r--r--mesonbuild/scripts/externalproject.py6
-rw-r--r--mesonbuild/scripts/gettext.py4
-rw-r--r--mesonbuild/scripts/gtkdochelper.py6
-rw-r--r--mesonbuild/scripts/meson_exe.py2
-rw-r--r--mesonbuild/scripts/symbolextractor.py2
-rw-r--r--mesonbuild/scripts/uninstall.py2
-rw-r--r--mesonbuild/scripts/yelphelper.py6
11 files changed, 23 insertions, 23 deletions
diff --git a/mesonbuild/scripts/cleantrees.py b/mesonbuild/scripts/cleantrees.py
index 6feb9a7..1a38753 100644
--- a/mesonbuild/scripts/cleantrees.py
+++ b/mesonbuild/scripts/cleantrees.py
@@ -22,7 +22,7 @@ def rmtrees(build_dir: str, trees: T.List[str]) -> None:
for t in trees:
# Never delete trees outside of the builddir
if os.path.isabs(t):
- print('Cannot delete dir with absolute path {!r}'.format(t))
+ print(f'Cannot delete dir with absolute path {t!r}')
continue
bt = os.path.join(build_dir, t)
# Skip if it doesn't exist, or if it is not a directory
diff --git a/mesonbuild/scripts/cmake_run_ctgt.py b/mesonbuild/scripts/cmake_run_ctgt.py
index 3f6f2af..dfb70d1 100755
--- a/mesonbuild/scripts/cmake_run_ctgt.py
+++ b/mesonbuild/scripts/cmake_run_ctgt.py
@@ -16,7 +16,7 @@ def run(argsv: T.List[str]) -> int:
parser.add_argument('-d', '--directory', type=str, metavar='D', required=True, help='Working directory to cwd to')
parser.add_argument('-o', '--outputs', nargs='+', metavar='O', required=True, help='Expected output files')
parser.add_argument('-O', '--original-outputs', nargs='*', metavar='O', default=[], help='Output files expected by CMake')
- parser.add_argument('commands', nargs=argparse.REMAINDER, help='A "{}" separated list of commands'.format(SEPARATOR))
+ parser.add_argument('commands', nargs=argparse.REMAINDER, help=f'A "{SEPARATOR}" separated list of commands')
# Parse
args = parser.parse_args(argsv)
diff --git a/mesonbuild/scripts/coverage.py b/mesonbuild/scripts/coverage.py
index 80e9052..f8a4924 100644
--- a/mesonbuild/scripts/coverage.py
+++ b/mesonbuild/scripts/coverage.py
@@ -69,11 +69,11 @@ def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build
if mesonlib.is_windows():
llvm_cov_shim_path = os.path.join(log_dir, 'llvm-cov.bat')
with open(llvm_cov_shim_path, 'w') as llvm_cov_bat:
- llvm_cov_bat.write('@"{}" gcov %*'.format(llvm_cov_exe))
+ llvm_cov_bat.write(f'@"{llvm_cov_exe}" gcov %*')
else:
llvm_cov_shim_path = os.path.join(log_dir, 'llvm-cov.sh')
with open(llvm_cov_shim_path, 'w') as llvm_cov_sh:
- llvm_cov_sh.write('#!/usr/bin/env sh\nexec "{}" gcov $@'.format(llvm_cov_exe))
+ llvm_cov_sh.write(f'#!/usr/bin/env sh\nexec "{llvm_cov_exe}" gcov $@')
os.chmod(llvm_cov_shim_path, os.stat(llvm_cov_shim_path).st_mode | stat.S_IEXEC)
gcov_tool_args = ['--gcov-tool', llvm_cov_shim_path]
else:
diff --git a/mesonbuild/scripts/depscan.py b/mesonbuild/scripts/depscan.py
index 2879d8b..207bbc6 100644
--- a/mesonbuild/scripts/depscan.py
+++ b/mesonbuild/scripts/depscan.py
@@ -52,7 +52,7 @@ class DependencyScanner:
elif suffix in lang_suffixes['cpp']:
self.scan_cpp_file(fname)
else:
- sys.exit('Can not scan files with suffix .{}.'.format(suffix))
+ sys.exit(f'Can not scan files with suffix .{suffix}.')
def scan_fortran_file(self, fname: str) -> None:
fpath = pathlib.Path(fname)
@@ -75,7 +75,7 @@ class DependencyScanner:
assert(exported_module not in modules_in_this_file)
modules_in_this_file.add(exported_module)
if exported_module in self.provided_by:
- raise RuntimeError('Multiple files provide module {}.'.format(exported_module))
+ raise RuntimeError(f'Multiple files provide module {exported_module}.')
self.sources_with_exports.append(fname)
self.provided_by[exported_module] = fname
self.exports[fname] = exported_module
@@ -89,7 +89,7 @@ class DependencyScanner:
parent_module_name_full = submodule_export_match.group(1).lower()
parent_module_name = parent_module_name_full.split(':')[0]
submodule_name = submodule_export_match.group(2).lower()
- concat_name = '{}:{}'.format(parent_module_name, submodule_name)
+ concat_name = f'{parent_module_name}:{submodule_name}'
self.sources_with_exports.append(fname)
self.provided_by[concat_name] = fname
self.exports[fname] = concat_name
@@ -120,7 +120,7 @@ class DependencyScanner:
if export_match:
exported_module = export_match.group(1)
if exported_module in self.provided_by:
- raise RuntimeError('Multiple files provide module {}.'.format(exported_module))
+ raise RuntimeError(f'Multiple files provide module {exported_module}.')
self.sources_with_exports.append(fname)
self.provided_by[exported_module] = fname
self.exports[fname] = exported_module
@@ -141,7 +141,7 @@ class DependencyScanner:
extension = 'smod'
else:
extension = 'mod'
- return os.path.join(self.target_data.private_dir, '{}.{}'.format(namebase, extension))
+ return os.path.join(self.target_data.private_dir, f'{namebase}.{extension}')
elif suffix in lang_suffixes['cpp']:
return '{}.ifc'.format(self.exports[src])
else:
diff --git a/mesonbuild/scripts/externalproject.py b/mesonbuild/scripts/externalproject.py
index a3ffe73..657ef2f 100644
--- a/mesonbuild/scripts/externalproject.py
+++ b/mesonbuild/scripts/externalproject.py
@@ -35,7 +35,7 @@ class ExternalProject:
def write_depfile(self) -> None:
with open(self.depfile, 'w') as f:
- f.write('{}: \\\n'.format(self.stampfile))
+ f.write(f'{self.stampfile}: \\\n')
for dirpath, dirnames, filenames in os.walk(self.src_dir):
dirnames[:] = [d for d in dirnames if not d.startswith('.')]
for fname in filenames:
@@ -75,7 +75,7 @@ class ExternalProject:
def _run(self, step: str, command: T.List[str]) -> int:
m = 'Running command ' + str(command) + ' in directory ' + str(self.build_dir) + '\n'
- log_filename = Path(self.log_dir, '{}-{}.log'.format(self.name, step))
+ log_filename = Path(self.log_dir, f'{self.name}-{step}.log')
output = None
if not self.verbose:
output = open(log_filename, 'w')
@@ -86,7 +86,7 @@ class ExternalProject:
p, o, e = Popen_safe(command, stderr=subprocess.STDOUT, stdout=output,
cwd=self.build_dir)
if p.returncode != 0:
- m = '{} step returned error code {}.'.format(step, p.returncode)
+ m = f'{step} step returned error code {p.returncode}.'
if not self.verbose:
m += '\nSee logs: ' + str(log_filename)
print(m)
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py
index 64c228b..92b55d3 100644
--- a/mesonbuild/scripts/gettext.py
+++ b/mesonbuild/scripts/gettext.py
@@ -41,7 +41,7 @@ def read_linguas(src_sub: str) -> T.List[str]:
langs += line.split()
return langs
except (FileNotFoundError, PermissionError):
- print('Could not find file LINGUAS in {}'.format(src_sub))
+ print(f'Could not find file LINGUAS in {src_sub}')
return []
def run_potgen(src_sub: str, pkgname: str, datadirs: str, args: T.List[str]) -> int:
@@ -87,7 +87,7 @@ def do_install(src_sub: str, bld_sub: str, dest: str, pkgname: str, langs: T.Lis
shutil.copy2(srcfile, tempfile)
os.replace(tempfile, outfile)
if not os.getenv('MESON_INSTALL_QUIET', False):
- print('Installing %s to %s' % (srcfile, outfile))
+ print(f'Installing {srcfile} to {outfile}')
return 0
def run(args: T.List[str]) -> int:
diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py
index 86949e5..153c3d9 100644
--- a/mesonbuild/scripts/gtkdochelper.py
+++ b/mesonbuild/scripts/gtkdochelper.py
@@ -72,7 +72,7 @@ def gtkdoc_run_check(cmd: T.List[str], cwd: str, library_paths: T.Optional[T.Lis
# This preserves the order of messages.
p, out = Popen_safe(cmd, cwd=cwd, env=env, stderr=subprocess.STDOUT)[0:2]
if p.returncode != 0:
- err_msg = ["{!r} failed with status {:d}".format(cmd, p.returncode)]
+ err_msg = [f"{cmd!r} failed with status {p.returncode:d}"]
if out:
err_msg.append(out)
raise MesonException('\n'.join(err_msg))
@@ -215,8 +215,8 @@ def build_gtkdoc(source_root: str, build_root: str, doc_subdir: str, src_subdirs
gtkdoc_run_check(fixref_cmd, abs_out)
if module_version:
- shutil.move(os.path.join(htmldir, '{}.devhelp2'.format(module)),
- os.path.join(htmldir, '{}-{}.devhelp2'.format(module, module_version)))
+ shutil.move(os.path.join(htmldir, f'{module}.devhelp2'),
+ os.path.join(htmldir, f'{module}-{module_version}.devhelp2'))
def install_gtkdoc(build_root: str, doc_subdir: str, install_prefix: str, datadir: str, module: str) -> None:
source = os.path.join(build_root, doc_subdir, 'html')
diff --git a/mesonbuild/scripts/meson_exe.py b/mesonbuild/scripts/meson_exe.py
index d44280f..ceb9e43 100644
--- a/mesonbuild/scripts/meson_exe.py
+++ b/mesonbuild/scripts/meson_exe.py
@@ -67,7 +67,7 @@ def run_exe(exe: ExecutableSerialisation, extra_env: T.Optional[dict] = None) ->
if p.returncode != 0:
if exe.pickled:
- print('while executing {!r}'.format(cmd_args))
+ print(f'while executing {cmd_args!r}')
if exe.verbose:
return p.returncode
if not exe.capture:
diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py
index e80d9c2fac..728d5e2 100644
--- a/mesonbuild/scripts/symbolextractor.py
+++ b/mesonbuild/scripts/symbolextractor.py
@@ -56,7 +56,7 @@ def print_tool_warning(tools: T.List[str], msg: str, stderr: T.Optional[str] = N
global TOOL_WARNING_FILE
if os.path.exists(TOOL_WARNING_FILE):
return
- m = '{!r} {}. {}'.format(tools, msg, RELINKING_WARNING)
+ m = f'{tools!r} {msg}. {RELINKING_WARNING}'
if stderr:
m += '\n' + stderr
mlog.warning(m)
diff --git a/mesonbuild/scripts/uninstall.py b/mesonbuild/scripts/uninstall.py
index b648de4..8db04dd 100644
--- a/mesonbuild/scripts/uninstall.py
+++ b/mesonbuild/scripts/uninstall.py
@@ -32,7 +32,7 @@ def do_uninstall(log: str) -> None:
print('Deleted:', fname)
successes += 1
except Exception as e:
- print('Could not delete %s: %s.' % (fname, e))
+ print(f'Could not delete {fname}: {e}.')
failures += 1
print('\nUninstall finished.\n')
print('Deleted:', successes)
diff --git a/mesonbuild/scripts/yelphelper.py b/mesonbuild/scripts/yelphelper.py
index 0355d9f..374104b 100644
--- a/mesonbuild/scripts/yelphelper.py
+++ b/mesonbuild/scripts/yelphelper.py
@@ -68,7 +68,7 @@ def install_help(srcdir: str, blddir: str, sources: T.List[str], media: T.List[s
for source in sources:
infile = os.path.join(srcdir if lang == 'C' else blddir, lang, source)
outfile = os.path.join(indir, source)
- mlog.log('Installing %s to %s' % (infile, outfile))
+ mlog.log(f'Installing {infile} to {outfile}')
shutil.copy2(infile, outfile)
for m in media:
infile = os.path.join(srcdir, lang, m)
@@ -80,7 +80,7 @@ def install_help(srcdir: str, blddir: str, sources: T.List[str], media: T.List[s
continue
elif symlinks:
srcfile = os.path.join(c_install_dir, m)
- mlog.log('Symlinking %s to %s.' % (outfile, srcfile))
+ mlog.log(f'Symlinking {outfile} to {srcfile}.')
if has_path_sep(m):
os.makedirs(os.path.dirname(outfile), exist_ok=True)
try:
@@ -96,7 +96,7 @@ def install_help(srcdir: str, blddir: str, sources: T.List[str], media: T.List[s
else:
# Lang doesn't have media file so copy it over 'C' one
infile = c_infile
- mlog.log('Installing %s to %s' % (infile, outfile))
+ mlog.log(f'Installing {infile} to {outfile}')
if has_path_sep(m):
os.makedirs(os.path.dirname(outfile), exist_ok=True)
shutil.copyfile(infile, outfile)