aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/wrap
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/wrap')
-rw-r--r--mesonbuild/wrap/wrap.py34
-rw-r--r--mesonbuild/wrap/wraptool.py16
2 files changed, 25 insertions, 25 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index ca201de..c93ecae 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -57,11 +57,11 @@ def whitelist_wrapdb(urlstr: str) -> urllib.parse.ParseResult:
""" raises WrapException if not whitelisted subdomain """
url = urllib.parse.urlparse(urlstr)
if not url.hostname:
- raise WrapException('{} is not a valid URL'.format(urlstr))
+ raise WrapException(f'{urlstr} is not a valid URL')
if not url.hostname.endswith(WHITELIST_SUBDOMAIN):
- raise WrapException('{} is not a whitelisted WrapDB URL'.format(urlstr))
+ raise WrapException(f'{urlstr} is not a whitelisted WrapDB URL')
if has_ssl and not url.scheme == 'https':
- raise WrapException('WrapDB did not have expected SSL https url, instead got {}'.format(urlstr))
+ raise WrapException(f'WrapDB did not have expected SSL https url, instead got {urlstr}')
return url
def open_wrapdburl(urlstring: str) -> 'http.client.HTTPResponse':
@@ -72,17 +72,17 @@ def open_wrapdburl(urlstring: str) -> 'http.client.HTTPResponse':
try:
return T.cast('http.client.HTTPResponse', urllib.request.urlopen(urllib.parse.urlunparse(url), timeout=REQ_TIMEOUT))
except urllib.error.URLError as excp:
- raise WrapException('WrapDB connection failed to {} with error {}'.format(urlstring, excp))
+ raise WrapException(f'WrapDB connection failed to {urlstring} with error {excp}')
# following code is only for those without Python SSL
nossl_url = url._replace(scheme='http')
if not SSL_WARNING_PRINTED:
- mlog.warning('SSL module not available in {}: WrapDB traffic not authenticated.'.format(sys.executable))
+ mlog.warning(f'SSL module not available in {sys.executable}: WrapDB traffic not authenticated.')
SSL_WARNING_PRINTED = True
try:
return T.cast('http.client.HTTPResponse', urllib.request.urlopen(urllib.parse.urlunparse(nossl_url), timeout=REQ_TIMEOUT))
except urllib.error.URLError as excp:
- raise WrapException('WrapDB connection failed to {} with error {}'.format(urlstring, excp))
+ raise WrapException(f'WrapDB connection failed to {urlstring} with error {excp}')
class WrapException(MesonException):
@@ -109,7 +109,7 @@ class PackageDefinition:
if os.path.dirname(self.directory):
raise WrapException('Directory key must be a name and not a path')
if self.type and self.type not in ALL_TYPES:
- raise WrapException('Unknown wrap type {!r}'.format(self.type))
+ raise WrapException(f'Unknown wrap type {self.type!r}')
self.filesdir = os.path.join(os.path.dirname(self.filename), 'packagefiles')
def parse_wrap(self) -> None:
@@ -144,7 +144,7 @@ class PackageDefinition:
def parse_wrap_section(self, config: configparser.ConfigParser) -> None:
if len(config.sections()) < 1:
- raise WrapException('Missing sections in {}'.format(self.basename))
+ raise WrapException(f'Missing sections in {self.basename}')
self.wrap_section = config.sections()[0]
if not self.wrap_section.startswith('wrap-'):
m = '{!r} is not a valid first section in {}'
@@ -334,7 +334,7 @@ class Resolver:
elif self.wrap.type == "svn":
self.get_svn()
else:
- raise WrapException('Unknown wrap type {!r}'.format(self.wrap.type))
+ raise WrapException(f'Unknown wrap type {self.wrap.type!r}')
self.apply_patch()
# A meson.build or CMakeLists.txt file is required in the directory
@@ -472,14 +472,14 @@ class Resolver:
if url.hostname and url.hostname.endswith(WHITELIST_SUBDOMAIN):
resp = open_wrapdburl(urlstring)
elif WHITELIST_SUBDOMAIN in urlstring:
- raise WrapException('{} may be a WrapDB-impersonating URL'.format(urlstring))
+ raise WrapException(f'{urlstring} may be a WrapDB-impersonating URL')
else:
try:
- req = urllib.request.Request(urlstring, headers={'User-Agent': 'mesonbuild/{}'.format(coredata.version)})
+ req = urllib.request.Request(urlstring, headers={'User-Agent': f'mesonbuild/{coredata.version}'})
resp = urllib.request.urlopen(req, timeout=REQ_TIMEOUT)
except urllib.error.URLError as e:
mlog.log(str(e))
- raise WrapException('could not get {} is the internet available?'.format(urlstring))
+ raise WrapException(f'could not get {urlstring} is the internet available?')
with contextlib.closing(resp) as resp:
try:
dlsize = int(resp.info()['Content-Length'])
@@ -518,7 +518,7 @@ class Resolver:
h.update(f.read())
dhash = h.hexdigest()
if dhash != expected:
- raise WrapException('Incorrect hash for {}:\n {} expected\n {} actual.'.format(what, expected, dhash))
+ raise WrapException(f'Incorrect hash for {what}:\n {expected} expected\n {dhash} actual.')
def download(self, what: str, ofname: str, fallback: bool = False) -> None:
self.check_can_download()
@@ -529,7 +529,7 @@ class Resolver:
expected = self.wrap.get(what + '_hash').lower()
if dhash != expected:
os.remove(tmpfile)
- raise WrapException('Incorrect hash for {}:\n {} expected\n {} actual.'.format(what, expected, dhash))
+ raise WrapException(f'Incorrect hash for {what}:\n {expected} expected\n {dhash} actual.')
except WrapException:
if not fallback:
if what + '_fallback_url' in self.wrap.values:
@@ -555,11 +555,11 @@ class Resolver:
return cache_path
else:
from ..interpreterbase import FeatureNew
- FeatureNew('Local wrap patch files without {}_url'.format(what), '0.55.0').use(self.current_subproject)
+ FeatureNew(f'Local wrap patch files without {what}_url', '0.55.0').use(self.current_subproject)
path = Path(self.wrap.filesdir) / filename
if not path.exists():
- raise WrapException('File "{}" does not exist'.format(path))
+ raise WrapException(f'File "{path}" does not exist')
self.check_hash(what, path.as_posix(), hash_required=False)
return path.as_posix()
@@ -582,7 +582,7 @@ class Resolver:
patch_dir = self.wrap.values['patch_directory']
src_dir = os.path.join(self.wrap.filesdir, patch_dir)
if not os.path.isdir(src_dir):
- raise WrapException('patch directory does not exists: {}'.format(patch_dir))
+ raise WrapException(f'patch directory does not exists: {patch_dir}')
self.copy_tree(src_dir, self.dirname)
def copy_tree(self, root_src_dir: str, root_dst_dir: str) -> None:
diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py
index d420889..fb91f3a 100644
--- a/mesonbuild/wrap/wraptool.py
+++ b/mesonbuild/wrap/wraptool.py
@@ -100,7 +100,7 @@ def install(options: 'argparse.Namespace') -> None:
if os.path.exists(wrapfile):
raise SystemExit('Wrap file already exists.')
(branch, revision) = get_latest_version(name)
- u = open_wrapdburl(API_ROOT + 'projects/{}/{}/{}/get_wrap'.format(name, branch, revision))
+ u = open_wrapdburl(API_ROOT + f'projects/{name}/{branch}/{revision}/get_wrap')
data = u.read()
with open(wrapfile, 'wb') as f:
f.write(data)
@@ -119,7 +119,7 @@ def get_current_version(wrapfile: str) -> T.Tuple[str, int, str, str, str]:
return branch, revision, wrap_data['directory'], wrap_data['source_filename'], wrap_data['patch_filename']
def update_wrap_file(wrapfile: str, name: str, new_branch: str, new_revision: str) -> None:
- u = open_wrapdburl(API_ROOT + 'projects/{}/{}/{}/get_wrap'.format(name, new_branch, new_revision))
+ u = open_wrapdburl(API_ROOT + f'projects/{name}/{new_branch}/{new_revision}/get_wrap')
data = u.read()
with open(wrapfile, 'wb') as f:
f.write(data)
@@ -154,7 +154,7 @@ def info(options: 'argparse.Namespace') -> None:
versions = jd['versions']
if not versions:
raise SystemExit('No available versions of' + name)
- print('Available versions of {}:'.format(name))
+ print(f'Available versions of {name}:')
for v in versions:
print(' ', v['branch'], v['revision'])
@@ -166,7 +166,7 @@ def do_promotion(from_path: str, spdir_name: str) -> None:
sproj_name = os.path.basename(from_path)
outputdir = os.path.join(spdir_name, sproj_name)
if os.path.exists(outputdir):
- raise SystemExit('Output dir {} already exists. Will not overwrite.'.format(outputdir))
+ raise SystemExit(f'Output dir {outputdir} already exists. Will not overwrite.')
shutil.copytree(from_path, outputdir, ignore=shutil.ignore_patterns('subprojects'))
def promote(options: 'argparse.Namespace') -> None:
@@ -183,10 +183,10 @@ def promote(options: 'argparse.Namespace') -> None:
# otherwise the argument is just a subproject basename which must be unambiguous
if argument not in sprojs:
- raise SystemExit('Subproject {} not found in directory tree.'.format(argument))
+ raise SystemExit(f'Subproject {argument} not found in directory tree.')
matches = sprojs[argument]
if len(matches) > 1:
- print('There is more than one version of {} in tree. Please specify which one to promote:\n'.format(argument), file=sys.stderr)
+ print(f'There is more than one version of {argument} in tree. Please specify which one to promote:\n', file=sys.stderr)
for s in matches:
print(s, file=sys.stderr)
raise SystemExit(1)
@@ -207,9 +207,9 @@ def status(options: 'argparse.Namespace') -> None:
print('Wrap file not from wrapdb.', file=sys.stderr)
continue
if current_branch == latest_branch and current_revision == latest_revision:
- print('', name, 'up to date. Branch {}, revision {}.'.format(current_branch, current_revision))
+ print('', name, f'up to date. Branch {current_branch}, revision {current_revision}.')
else:
- print('', name, 'not up to date. Have {} {}, but {} {} is available.'.format(current_branch, current_revision, latest_branch, latest_revision))
+ print('', name, f'not up to date. Have {current_branch} {current_revision}, but {latest_branch} {latest_revision} is available.')
def run(options: 'argparse.Namespace') -> int:
options.wrap_func(options)