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

Commit 7b3044f

Browse filesBrowse files
authored
Merge pull request winpython#1171 from stonebig/master
modernize to f-string
2 parents e72bda0 + 2a39212 commit 7b3044f
Copy full SHA for 7b3044f

File tree

Expand file treeCollapse file tree

1 file changed

+13
-24
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-24
lines changed

‎winpython/disthelpers.py

Copy file name to clipboardExpand all lines: winpython/disthelpers.py
+13-24Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def prepend_module_to_path(module_path):
7474
name = Path(module_path).name
7575
prefix = "Prepending module to sys.path"
7676
message = prefix + (
77-
"%s [revision %s]" % (name, changeset)
77+
f"{name} [revision {changeset}]"
7878
).rjust(80 - len(prefix), ".")
7979
print(message, file=sys.stderr)
8080
if name in sys.modules:
@@ -84,9 +84,9 @@ def prepend_module_to_path(module_path):
8484
if modname.startswith(name + '.'):
8585
sys.modules.pop(modname)
8686
nbsp += 1
87-
warning = '(removed %s from sys.modules' % name
87+
warning = f'(removed {name} from sys.modules'
8888
if nbsp:
89-
warning += ' and %d subpackages' % nbsp
89+
warning += f' and {nbsp} subpackages'
9090
warning += ')'
9191
print(warning.rjust(80), file=sys.stderr)
9292
return message
@@ -157,7 +157,7 @@ def strip_version(version):
157157
def remove_dir(dirname):
158158
"""Remove directory *dirname* and all its contents
159159
Print details about the operation (progress, success/failure)"""
160-
print("Removing directory '%s'..." % dirname, end=' ')
160+
print(f"Removing directory '{dirname}'...", end=' ')
161161
try:
162162
shutil.rmtree(dirname, ignore_errors=True)
163163
print("OK")
@@ -530,7 +530,7 @@ def add_matplotlib(self):
530530
def add_modules(self, *module_names):
531531
"""Include module *module_name*"""
532532
for module_name in module_names:
533-
print("Configuring module '%s'" % module_name)
533+
print(f"Configuring module '{module_name}'")
534534
if module_name == 'PyQt4':
535535
self.add_pyqt4()
536536
elif module_name == 'PySide':
@@ -552,7 +552,7 @@ def add_modules(self, *module_names):
552552
]:
553553
if hasattr(h5py, attr):
554554
self.includes.append(
555-
'h5py.%s' % attr
555+
f'h5py.{attr}'
556556
)
557557
if (
558558
self.bin_path_excludes is not None
@@ -598,8 +598,7 @@ def add_modules(self, *module_names):
598598
):
599599
if Path(fname).suffix == '.py':
600600
modname = (
601-
'sphinx.ext.%s'
602-
% Path(fname).stem
601+
f'sphinx.ext.{Path(fname).stem}'
603602
)
604603
self.includes.append(modname)
605604
elif module_name == 'pygments':
@@ -661,8 +660,7 @@ def add_modules(self, *module_names):
661660
)
662661
except IOError:
663662
raise RuntimeError(
664-
"Module not supported: %s"
665-
% module_name
663+
f"Module not supported: {module_name}"
666664
)
667665

668666
def add_module_data_dir(
@@ -684,7 +682,7 @@ def add_module_data_dir(
684682
data_dir = str(Path(module_dir) / data_dir_name)
685683
if not Path(data_dir).is_dir():
686684
raise IOError(
687-
"Directory not found: %s" % data_dir
685+
f"Directory not found: {data_dir}"
688686
)
689687
for dirpath, _dirnames, filenames in os.walk(
690688
data_dir
@@ -719,12 +717,7 @@ def add_module_data_files(
719717
*extensions*: list of file extensions, e.g. ('.png', '.svg')
720718
"""
721719
print(
722-
"Adding module '%s' data files in %s (%s)"
723-
% (
724-
module_name,
725-
", ".join(data_dir_names),
726-
", ".join(extensions),
727-
)
720+
f"Adding module '{module_name}' data files in {', '.join(data_dir_names)} ({', '.join(extensions)})"
728721
)
729722
module_dir = get_module_path(module_name)
730723
for data_dir_name in data_dir_names:
@@ -750,11 +743,7 @@ def add_module_data_files(
750743
)
751744
)
752745
print(
753-
"Adding module '%s' translation file: %s"
754-
% (
755-
module_name,
756-
Path(translation_file).name,
757-
)
746+
f"Adding module '{module_name}' translation file: {Path(translation_file).name}"
758747
)
759748

760749
def build(
@@ -785,7 +774,7 @@ def build(
785774
)
786775
else:
787776
raise RuntimeError(
788-
"Unsupported library %s" % library
777+
f"Unsupported library {library}"
789778
)
790779

791780
def __cleanup(self):
@@ -803,7 +792,7 @@ def __create_archive(self, option):
803792
* 'move': move target directory to a ZIP archive
804793
"""
805794
name = self.target_dir
806-
os.system('zip "%s.zip" -r "%s"' % (name, name))
795+
os.system(f'zip "{name}.zip" -r "{name}"')
807796
if option == 'move':
808797
shutil.rmtree(name)
809798

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.