summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2021-12-22 16:30:41 +0200
committerAlex Grönholm <alex.gronholm@nextday.fi>2021-12-22 16:30:41 +0200
commitfa4de8bd7dce1611be217ade3aade0bd8c76ca7a (patch)
tree621e55e88d3861bea1dc2c42ea0eae87b5930b89 /src
parent45af6b0f420b7a90af417b3846b0bdfe1c6a70d4 (diff)
downloadwheel-git-fa4de8bd7dce1611be217ade3aade0bd8c76ca7a.tar.gz
Upgraded to py3.7+ syntax
Diffstat (limited to 'src')
-rw-r--r--src/wheel/bdist_wheel.py18
-rw-r--r--src/wheel/cli/__init__.py2
-rwxr-xr-xsrc/wheel/cli/convert.py10
-rw-r--r--src/wheel/cli/pack.py8
-rw-r--r--src/wheel/cli/unpack.py2
-rw-r--r--src/wheel/macosx_libfile.py6
-rw-r--r--src/wheel/pkginfo.py2
-rw-r--r--src/wheel/wheelfile.py12
8 files changed, 30 insertions, 30 deletions
diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py
index 84a3fcf..ae8da2a 100644
--- a/src/wheel/bdist_wheel.py
+++ b/src/wheel/bdist_wheel.py
@@ -38,7 +38,7 @@ PY_LIMITED_API_PATTERN = r'cp3\d'
def python_tag():
- return 'py{}'.format(sys.version_info[0])
+ return f'py{sys.version_info[0]}'
def get_platform(archive_root):
@@ -59,7 +59,7 @@ def get_flag(var, fallback, expected=True, warn=True):
val = get_config_var(var)
if val is None:
if warn:
- warnings.warn("Config variable '{0}' is unset, Python ABI tag may "
+ warnings.warn("Config variable '{}' is unset, Python ABI tag may "
"be incorrect".format(var), RuntimeWarning, 2)
return fallback
return val == expected
@@ -85,7 +85,7 @@ def get_abi_tag():
and sys.version_info < (3, 8):
m = 'm'
- abi = '%s%s%s%s%s' % (impl, tags.interpreter_version(), d, m, u)
+ abi = f'{impl}{tags.interpreter_version()}{d}{m}{u}'
elif soabi and soabi.startswith('cpython-'):
abi = 'cp' + soabi.split('-')[1]
elif soabi and soabi.startswith('pypy-'):
@@ -197,7 +197,7 @@ class bdist_wheel(Command):
try:
self.compression = self.supported_compressions[self.compression]
except KeyError:
- raise ValueError('Unsupported compression: {}'.format(self.compression))
+ raise ValueError(f'Unsupported compression: {self.compression}')
need_options = ('dist_dir', 'plat_name', 'skip_build')
@@ -276,7 +276,7 @@ class bdist_wheel(Command):
# issue gh-374: allow overriding plat_name
supported_tags = [(t.interpreter, t.abi, plat_name)
for t in tags.sys_tags()]
- assert tag in supported_tags, "would build wheel with unsupported tag {}".format(tag)
+ assert tag in supported_tags, f"would build wheel with unsupported tag {tag}"
return tag
def run(self):
@@ -327,7 +327,7 @@ class bdist_wheel(Command):
self.run_command('install')
impl_tag, abi_tag, plat_tag = self.get_tag()
- archive_basename = "{}-{}-{}-{}".format(self.wheel_dist_name, impl_tag, abi_tag, plat_tag)
+ archive_basename = f"{self.wheel_dist_name}-{impl_tag}-{abi_tag}-{plat_tag}"
if not self.relative:
archive_root = self.bdist_dir
else:
@@ -441,10 +441,10 @@ class bdist_wheel(Command):
import glob
pat = os.path.join(os.path.dirname(egginfo_path), '*.egg-info')
possible = glob.glob(pat)
- err = "Egg metadata expected at %s but not found" % (egginfo_path,)
+ err = f"Egg metadata expected at {egginfo_path} but not found"
if possible:
alt = os.path.basename(possible[0])
- err += " (%s found - possible misnamed archive file?)" % (alt,)
+ err += f" ({alt} found - possible misnamed archive file?)"
raise ValueError(err)
@@ -466,7 +466,7 @@ class bdist_wheel(Command):
# delete dependency_links if it is only whitespace
dependency_links_path = os.path.join(distinfo_path, 'dependency_links.txt')
- with open(dependency_links_path, 'r') as dependency_links_file:
+ with open(dependency_links_path) as dependency_links_file:
dependency_links = dependency_links_file.read().strip()
if not dependency_links:
adios(dependency_links_path)
diff --git a/src/wheel/cli/__init__.py b/src/wheel/cli/__init__.py
index d41dcfd..c8a3b35 100644
--- a/src/wheel/cli/__init__.py
+++ b/src/wheel/cli/__init__.py
@@ -11,7 +11,7 @@ def require_pkgresources(name):
try:
import pkg_resources # noqa: F401
except ImportError:
- raise RuntimeError("'{0}' needs pkg_resources (part of setuptools).".format(name))
+ raise RuntimeError(f"'{name}' needs pkg_resources (part of setuptools).")
class WheelError(Exception):
diff --git a/src/wheel/cli/convert.py b/src/wheel/cli/convert.py
index b502daf..5c76d5f 100755
--- a/src/wheel/cli/convert.py
+++ b/src/wheel/cli/convert.py
@@ -37,7 +37,7 @@ def egg2wheel(egg_path, dest_dir):
filename = os.path.basename(egg_path)
match = egg_info_re.match(filename)
if not match:
- raise WheelError('Invalid egg file name: {}'.format(filename))
+ raise WheelError(f'Invalid egg file name: {filename}')
egg_info = match.groupdict()
dir = tempfile.mkdtemp(suffix="_e2w")
@@ -124,13 +124,13 @@ def parse_wininst_info(wininfo_name, egginfo_name):
if egginfo_name:
egginfo = egg_info_re.search(egginfo_name)
if not egginfo:
- raise ValueError("Egg info filename %s is not valid" % (egginfo_name,))
+ raise ValueError(f"Egg info filename {egginfo_name} is not valid")
# Parse the wininst filename
# 1. Distribution name (up to the first '-')
w_name, sep, rest = wininfo_name.partition('-')
if not sep:
- raise ValueError("Installer filename %s is not valid" % (wininfo_name,))
+ raise ValueError(f"Installer filename {wininfo_name} is not valid")
# Strip '.exe'
rest = rest[:-4]
@@ -149,7 +149,7 @@ def parse_wininst_info(wininfo_name, egginfo_name):
# 3. Version and architecture
w_ver, sep, w_arch = rest.rpartition('.')
if not sep:
- raise ValueError("Installer filename %s is not valid" % (wininfo_name,))
+ raise ValueError(f"Installer filename {wininfo_name} is not valid")
if egginfo:
w_name = egginfo.group('name')
@@ -260,7 +260,7 @@ def convert(files, dest_dir, verbose):
conv = wininst2wheel
if verbose:
- print("{}... ".format(installer), flush=True)
+ print(f"{installer}... ", flush=True)
conv(installer, dest_dir)
if verbose:
diff --git a/src/wheel/cli/pack.py b/src/wheel/cli/pack.py
index 04d858d..094eb67 100644
--- a/src/wheel/cli/pack.py
+++ b/src/wheel/cli/pack.py
@@ -21,9 +21,9 @@ def pack(directory, dest_dir, build_number):
dist_info_dirs = [fn for fn in os.listdir(directory)
if os.path.isdir(os.path.join(directory, fn)) and DIST_INFO_RE.match(fn)]
if len(dist_info_dirs) > 1:
- raise WheelError('Multiple .dist-info directories found in {}'.format(directory))
+ raise WheelError(f'Multiple .dist-info directories found in {directory}')
elif not dist_info_dirs:
- raise WheelError('No .dist-info directories found in {}'.format(directory))
+ raise WheelError(f'No .dist-info directories found in {directory}')
# Determine the target wheel filename
dist_info_dir = dist_info_dirs[0]
@@ -70,9 +70,9 @@ def pack(directory, dest_dir, build_number):
tagline = '-'.join(['.'.join(impls), '.'.join(abivers), '.'.join(platforms)])
# Repack the wheel
- wheel_path = os.path.join(dest_dir, '{}-{}.whl'.format(name_version, tagline))
+ wheel_path = os.path.join(dest_dir, f'{name_version}-{tagline}.whl')
with WheelFile(wheel_path, 'w') as wf:
- print("Repacking wheel as {}...".format(wheel_path), end='', flush=True)
+ print(f"Repacking wheel as {wheel_path}...", end='', flush=True)
wf.write_files(directory)
print('OK')
diff --git a/src/wheel/cli/unpack.py b/src/wheel/cli/unpack.py
index 8aa8180..3f3963c 100644
--- a/src/wheel/cli/unpack.py
+++ b/src/wheel/cli/unpack.py
@@ -15,7 +15,7 @@ def unpack(path, dest='.'):
with WheelFile(path) as wf:
namever = wf.parsed_filename.group('namever')
destination = os.path.join(dest, namever)
- print("Unpacking to: {}...".format(destination), end='', flush=True)
+ print(f"Unpacking to: {destination}...", end='', flush=True)
wf.extractall(destination)
print('OK')
diff --git a/src/wheel/macosx_libfile.py b/src/wheel/macosx_libfile.py
index 39006fb..29b0395 100644
--- a/src/wheel/macosx_libfile.py
+++ b/src/wheel/macosx_libfile.py
@@ -363,14 +363,14 @@ def calculate_macosx_platform_tag(archive_root, platform_tag):
Example platform tag `macosx-10.14-x86_64`
"""
prefix, base_version, suffix = platform_tag.split('-')
- base_version = tuple([int(x) for x in base_version.split(".")])
+ base_version = tuple(int(x) for x in base_version.split("."))
base_version = base_version[:2]
if base_version[0] > 10:
base_version = (base_version[0], 0)
assert len(base_version) == 2
if "MACOSX_DEPLOYMENT_TARGET" in os.environ:
- deploy_target = tuple([int(x) for x in os.environ[
- "MACOSX_DEPLOYMENT_TARGET"].split(".")])
+ deploy_target = tuple(int(x) for x in os.environ[
+ "MACOSX_DEPLOYMENT_TARGET"].split("."))
deploy_target = deploy_target[:2]
if deploy_target[0] > 10:
deploy_target = (deploy_target[0], 0)
diff --git a/src/wheel/pkginfo.py b/src/wheel/pkginfo.py
index 0470a1d..bed016c 100644
--- a/src/wheel/pkginfo.py
+++ b/src/wheel/pkginfo.py
@@ -12,7 +12,7 @@ def read_pkg_info_bytes(bytestr):
def read_pkg_info(path):
- with open(path, "r", encoding="ascii", errors="surrogateescape") as headers:
+ with open(path, encoding="ascii", errors="surrogateescape") as headers:
message = Parser().parse(headers)
return message
diff --git a/src/wheel/wheelfile.py b/src/wheel/wheelfile.py
index 2295306..83f1611 100644
--- a/src/wheel/wheelfile.py
+++ b/src/wheel/wheelfile.py
@@ -38,7 +38,7 @@ class WheelFile(ZipFile):
basename = os.path.basename(file)
self.parsed_filename = WHEEL_INFO_RE.match(basename)
if not basename.endswith('.whl') or self.parsed_filename is None:
- raise WheelError("Bad wheel filename {!r}".format(basename))
+ raise WheelError(f"Bad wheel filename {basename!r}")
ZipFile.__init__(self, file, mode, compression=compression, allowZip64=True)
@@ -56,7 +56,7 @@ class WheelFile(ZipFile):
try:
record = self.open(self.record_path)
except KeyError:
- raise WheelError('Missing {} file'.format(self.record_path))
+ raise WheelError(f'Missing {self.record_path} file')
with record:
for line in csv.reader(TextIOWrapper(record, newline='', encoding='utf-8')):
@@ -64,11 +64,11 @@ class WheelFile(ZipFile):
if not hash_sum:
continue
- algorithm, hash_sum = hash_sum.split(u'=')
+ algorithm, hash_sum = hash_sum.split('=')
try:
hashlib.new(algorithm)
except ValueError:
- raise WheelError('Unsupported hash algorithm: {}'.format(algorithm))
+ raise WheelError(f'Unsupported hash algorithm: {algorithm}')
if algorithm.lower() in {'md5', 'sha1'}:
raise WheelError(
@@ -88,12 +88,12 @@ class WheelFile(ZipFile):
running_hash.update(newdata)
if eof and running_hash.digest() != expected_hash:
- raise WheelError("Hash mismatch for file '{}'".format(native(ef_name)))
+ raise WheelError(f"Hash mismatch for file '{native(ef_name)}'")
ef_name = as_unicode(name_or_info.filename if isinstance(name_or_info, ZipInfo)
else name_or_info)
if mode == 'r' and not ef_name.endswith('/') and ef_name not in self._file_hashes:
- raise WheelError("No hash found for file '{}'".format(native(ef_name)))
+ raise WheelError(f"No hash found for file '{native(ef_name)}'")
ef = ZipFile.open(self, name_or_info, mode, pwd)
if mode == 'r' and not ef_name.endswith('/'):