build: use python f-strings
Change-Id: I955739ac40508642509521760c1bc75286c94f30
diff --git a/tests/other/wscript b/tests/other/wscript
index 0d94bd6..a2099aa 100644
--- a/tests/other/wscript
+++ b/tests/other/wscript
@@ -1,6 +1,6 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
"""
-Copyright (c) 2014-2019, Regents of the University of California,
+Copyright (c) 2014-2023, Regents of the University of California,
Arizona Board of Regents,
Colorado State University,
University Pierre & Marie Curie, Sorbonne University,
@@ -29,20 +29,20 @@
for module, name in {"cs-benchmark": "CS Benchmark",
"pit-fib-benchmark": "PIT & FIB Benchmark"}.items():
# main
- bld.objects(target='other-tests-%s-main' % module,
+ bld.objects(target=f'other-tests-{module}-main',
source='../main.cpp',
use='BOOST',
- defines=['BOOST_TEST_MODULE=%s' % name])
+ defines=[f'BOOST_TEST_MODULE={name}'])
# module
bld.program(name=module,
- target='../../%s' % module,
- source=bld.path.ant_glob('%s*.cpp' % module),
- use='daemon-objects other-tests-%s-main' % module,
+ target=f'{top}/{module}',
+ source=bld.path.ant_glob(f'{module}*.cpp'),
+ use=f'daemon-objects other-tests-{module}-main',
install_path=None)
# face-benchmark does not rely on Boost.Test
bld.program(name='face-benchmark',
- target='../../face-benchmark',
+ target=f'{top}/face-benchmark',
source=bld.path.ant_glob('face-benchmark*.cpp'),
use='daemon-objects',
install_path=None)
diff --git a/tests/wscript b/tests/wscript
index cf28718..ed4eb19 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -1,6 +1,6 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
"""
-Copyright (c) 2014-2020, Regents of the University of California,
+Copyright (c) 2014-2023, Regents of the University of California,
Arizona Board of Regents,
Colorado State University,
University Pierre & Marie Curie, Sorbonne University,
@@ -41,10 +41,10 @@
for module in ['core', 'daemon', 'rib', 'tools']:
# main() for the module
- bld.objects(target='unit-tests-%s-main' % module,
+ bld.objects(target=f'unit-tests-{module}-main',
source='main.cpp',
use='BOOST',
- defines=['BOOST_TEST_MODULE=NFD %s' % module.capitalize()])
+ defines=[f'BOOST_TEST_MODULE=NFD {module.capitalize()}'])
subdir = 'daemon/rib' if module == 'rib' else module
node = bld.path.find_dir(subdir)
@@ -66,10 +66,10 @@
objmod = 'daemon' if module == 'rib' else module
# unit-tests binary for the module
- bld.program(name='unit-tests-%s' % module,
- target='../unit-tests-%s' % module,
+ bld.program(name=f'unit-tests-{module}',
+ target=f'{top}/unit-tests-{module}',
source=src,
- use='%s-objects tests-common unit-tests-%s-main' % (objmod, module),
+ use=f'{objmod}-objects tests-common unit-tests-{module}-main',
defines=[tmpdir],
install_path=None)
diff --git a/tools/wscript b/tools/wscript
index f3ee6a8..5a9c396 100644
--- a/tools/wscript
+++ b/tools/wscript
@@ -1,6 +1,6 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
"""
-Copyright (c) 2014-2022, Regents of the University of California,
+Copyright (c) 2014-2023, Regents of the University of California,
Arizona Board of Regents,
Colorado State University,
University Pierre & Marie Curie, Sorbonne University,
@@ -25,7 +25,7 @@
from waflib import Context, Utils
-top = '../'
+top = '..'
def build(bld):
# Single object tools:
@@ -34,7 +34,7 @@
for tool in bld.path.ant_glob('*.cpp'):
name = tool.change_ext('').path_from(bld.path.get_bld())
bld.program(name=name,
- target=top + 'bin/%s' % name,
+ target=f'{top}/bin/{name}',
source=[tool],
use='core-objects')
@@ -59,7 +59,7 @@
srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp'])
srcObjects = ''
if srcFiles:
- srcObjects = 'tools-%s-objects' % name
+ srcObjects = f'tools-{name}-objects'
bld.objects(target=srcObjects,
source=srcFiles,
features='pch',
@@ -69,7 +69,7 @@
testableObjects.append(srcObjects)
bld.program(name=name,
- target=top + 'bin/%s' % name,
+ target=f'{top}/bin/{name}',
source=[mainFile],
use='core-objects ' + srcObjects,
includes=name)
@@ -84,7 +84,7 @@
name = script.change_ext('').path_from(bld.path.get_bld())
bld(features='subst',
name=name,
- target=top + 'bin/%s' % name,
+ target=f'{top}/bin/{name}',
source=[script],
install_path='${BINDIR}',
chmod=Utils.O755,
diff --git a/wscript b/wscript
index 93f2c84..a89edf3 100644
--- a/wscript
+++ b/wscript
@@ -140,7 +140,7 @@
conf.define_cond('WITH_TESTS', conf.env.WITH_TESTS)
conf.define_cond('WITH_OTHER_TESTS', conf.env.WITH_OTHER_TESTS)
- conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env.SYSCONFDIR)
+ conf.define('DEFAULT_CONFIG_FILE', f'{conf.env.SYSCONFDIR}/ndn/nfd.conf')
# The config header will contain all defines that were added using conf.define()
# or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
# will not appear in the config header, but will instead be passed directly to the
@@ -304,16 +304,16 @@
# first, try to get a version string from git
gotVersionFromGit = False
try:
- cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX]
- out = subprocess.check_output(cmd, universal_newlines=True).strip()
+ cmd = ['git', 'describe', '--always', '--match', f'{GIT_TAG_PREFIX}*']
+ out = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
if out:
gotVersionFromGit = True
if out.startswith(GIT_TAG_PREFIX):
Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX)
else:
# no tags matched
- Context.g_module.VERSION = '%s-commit-%s' % (VERSION_BASE, out)
- except (OSError, subprocess.CalledProcessError):
+ Context.g_module.VERSION = f'{VERSION_BASE}-commit-{out}'
+ except (OSError, subprocess.SubprocessError):
pass
versionFile = ctx.path.find_node('VERSION.info')
@@ -331,14 +331,14 @@
# already up-to-date
return
except EnvironmentError as e:
- Logs.warn('%s exists but is not readable (%s)' % (versionFile, e.strerror))
+ Logs.warn(f'{versionFile} exists but is not readable ({e.strerror})')
else:
versionFile = ctx.path.make_node('VERSION.info')
try:
versionFile.write(Context.g_module.VERSION)
except EnvironmentError as e:
- Logs.warn('%s is not writable (%s)' % (versionFile, e.strerror))
+ Logs.warn(f'{versionFile} is not writable ({e.strerror})')
def dist(ctx):
ctx.algo = 'tar.xz'