Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

modernize to f-string #1172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 21 additions & 33 deletions 54 winpython/wppm.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,15 @@ def __init__(self, fname):
self.url = None

def __str__(self):
text = "%s %s" % (self.name, self.version)
text = f"{self.name} {self.version}"
pytext = ""
if self.pyversion is not None:
pytext = " for Python %s" % self.pyversion
pytext = f" for Python {self.pyversion}"
if self.architecture is not None:
if not pytext:
pytext = " for Python"
pytext += " %dbits" % self.architecture
text += "%s\n%s\nWebsite: %s\n[%s]" % (
pytext,
self.description,
self.url,
Path(self.fname).name,
)
pytext += f" {self.architecture}bits"
text += f"{pytext}\n{self.description}\nWebsite: {self.url}\n[{Path(self.fname).name}]"
return text

def is_compatible_with(self, distribution):
Expand Down Expand Up @@ -205,7 +200,7 @@ def extract_infos(self):
self.name, self.version = infos
return
raise NotImplementedError(
"Not supported package type %s" % bname
f"Not supported package type {bname}"
)


Expand All @@ -227,7 +222,7 @@ def extract_infos(self):
if match is None:
return
self.name = match.groups()[0]
self.logname = '%s-wininst.log' % self.name
self.logname = f'{self.name}-wininst.log'
fd = open(
str(Path(self.distribution.target) / self.logname),
'U',
Expand Down Expand Up @@ -285,8 +280,7 @@ def clean_up(self):
shutil.rmtree(path, onerror=utils.onerror)
except WindowsError:
print(
"Directory %s could not be removed"
% path,
f"Directory {path} could not be removed",
file=sys.stderr,
)

Expand Down Expand Up @@ -316,7 +310,7 @@ def copy_files(
src = str(Path(srcdir) / t_dname)
dst = str(Path(dstdir) / t_dname)
if self.verbose:
print("mkdir: %s" % dst)
print(f"mkdir: {dst}")
full_dst = str(Path(self.target) / dst)
if not Path(full_dst).exists():
os.mkdir(full_dst)
Expand All @@ -330,15 +324,15 @@ def copy_files(
else:
dst = str(Path(dstdir) / t_fname)
if self.verbose:
print("file: %s" % dst)
print(f"file: {dst}")
full_dst = str(Path(self.target) / dst)
shutil.move(src, full_dst)
package.files.append(dst)
name, ext = Path(dst).stem, Path(dst).suffix
if create_bat_files and ext in ('', '.py'):
dst = name + '.bat'
if self.verbose:
print("file: %s" % dst)
print(f"file: {dst}")
full_dst = str(Path(self.target) / dst)
fd = open(full_dst, 'w')
fd.write(
Expand All @@ -354,7 +348,7 @@ def create_file(self, package, name, dstdir, contents):
"""Generate data file -- path is relative to distribution root dir"""
dst = str(Path(dstdir) / name)
if self.verbose:
print("create: %s" % dst)
print(f"create: {dst}")
full_dst = str(Path(self.target) / dst)
open(full_dst, 'w').write(contents)
package.files.append(dst)
Expand Down Expand Up @@ -386,8 +380,7 @@ def get_installed_packages(self, update=False):
# create pip package list
wppm = [
Package(
'%s-%s-py2.py3-none-any.whl'
% (i[0].replace('-', '_').lower(), i[1])
f"{i[0].replace('-', '_').lower()}-{i[1]}-py2.py3-none-any.whl"
, update=update)
for i in pip_list
]
Expand Down Expand Up @@ -671,7 +664,7 @@ def handle_specific_packages(self, package):
'.',
contents.replace(
'.',
'./Lib/site-packages/%s' % package.name,
f'./Lib/site-packages/{package.name}',
),
)
# pyuic script
Expand All @@ -691,7 +684,7 @@ def handle_specific_packages(self, package):

self.create_file(
package,
'pyuic%s.bat' % package.name[-1],
f'pyuic{package.name[-1]}.bat',
'Scripts',
tmp_string.replace(
'package.name', package.name
Expand Down Expand Up @@ -754,7 +747,7 @@ def install_bdist_direct(
"""Install a package directly !"""
self._print(
package,
"Installing %s" % package.fname.split(".")[-1],
f"Installing {package.fname.split('.')[-1]}",
)
try:
fname = utils.direct_pip_install(
Expand Down Expand Up @@ -861,7 +854,7 @@ def main(test=False):
dest='target',
default=sys.prefix,
help='path to target Python distribution '
'(default: "%s")' % sys.prefix,
f'(default: "{sys.prefix}")',
)
parser.add_argument(
'-i',
Expand Down Expand Up @@ -948,7 +941,7 @@ def main(test=False):
if utils.is_python_distribution(args.target):
dist = Distribution(args.target)
else:
raise WindowsError("Invalid Python distribution {args.target}")
raise WindowsError(f"Invalid Python distribution {args.target}")
print(f'registering {args.target}')
print('continue ? Y/N')
theAnswer=input()
Expand All @@ -961,7 +954,7 @@ def main(test=False):
if utils.is_python_distribution(args.target):
dist = Distribution(args.target)
else:
raise WindowsError("Invalid Python distribution {args.target}")
raise WindowsError(f"Invalid Python distribution {args.target}")
print(f'unregistering {args.target}')
print('continue ? Y/N')
theAnswer=input()
Expand All @@ -976,7 +969,7 @@ def main(test=False):
parser.print_help()
sys.exit()
else:
raise IOError("File not found: %s" % args.fname)
raise IOError(f"File not found: {args.fname}")
if utils.is_python_distribution(args.target):
dist = Distribution(args.target)
try:
Expand All @@ -993,20 +986,15 @@ def main(test=False):
else:
raise RuntimeError(
"Package is not compatible with Python "
"%s %dbit"
% (
dist.version,
dist.architecture,
)
f"{dist.version} {dist.architecture}bit"
)
except NotImplementedError:
raise RuntimeError(
"Package is not (yet) supported by WPPM"
)
else:
raise WindowsError(
"Invalid Python distribution %s"
% args.target
f"Invalid Python distribution {args.target}"
)


Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.