8000 Merge pull request #1362 from stonebig/master · Nizhal/winpython@ff7f791 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff7f791

Browse files
authored
Merge pull request winpython#1362 from stonebig/master
small simplification
2 parents f337fed + 7c432ae commit ff7f791

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

winpython/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,8 @@ def formatted_list(list_of_list, full=False, max_width=70):
862862
]
863863
return zz
864864

865-
# pep503 defines normalized package names: www.python.org/dev/peps/pep-0503
866-
def normalize(name):
867-
"""return normalized (unique) name of a package"""
865+
def normalize(this):
866+
"""apply https://peps.python.org/pep-0503/#normalized-names"""
868867
return re.sub(r"[-_.]+", "-", name).lower()
869868

870869
def get_package_metadata(database, name, update=False, suggested_summary=None):

winpython/wppm.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,13 @@
4141
# Workaround for installing PyVISA on Windows from source:
4242
os.environ["HOME"] = os.environ["USERPROFILE"]
4343

44-
# pep503 defines normalized package names: www.python.org/dev/peps/pep-0503
45-
def normalize(name):
46-
"""return normalized (unique) name of a package"""
47-
return re.sub(r"[-_.]+", "-", name).lower()
48-
49-
5044

5145
class BasePackage(object):
5246
def __init__(self, fname):
5347
self.fname = fname
5448
self.name = None
5549
self.version = None
56-
self.description = None
50+
self.description = ""
5751
self.url = None
5852

5953
def __str__(self):
@@ -71,8 +65,6 @@ def __init__(self, fname, update=False, suggested_summary=None):
7165
if suggested_summary:
7266
setattr(self, 'description',
7367
piptree.sum_up(suggested_summary ))
74-
else:
75-
setattr(self, 'description','.')
7668
bname = fname.split("-")[0]
7769
setattr(self,'url',"https://pypi.org/project/" + bname)
7870

@@ -220,7 +212,7 @@ def get_installed_packages(self, update=False):
220212
def find_package(self, name):
221213
"""Find installed package"""
222214
for pack in self.get_installed_packages():
223-
if normalize(pack.name) == normalize(name):
215+
if utils.normalize(pack.name) == utils.normalize(name):
224216
return pack
225217

226218
def patch_all_shebang(
@@ -553,9 +545,7 @@ def main(test=False):
553545
# dist.uninstall(pack)
554546
else:
555547
registerWinPythonHelp = f"Register distribution: associate file extensions, icons and context menu with this WinPython"
556-
557548
unregisterWinPythonHelp = f"Unregister distribution: de-associate file extensions, icons and context menu from this WinPython"
558-
559549
parser = ArgumentParser(
560550
description="WinPython Package Manager: handle a WinPython Distribution and its packages",
561551
formatter_class=RawTextHelpFormatter,

0 commit comments

Comments
 (0)
0