Skip to content
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
16 changes: 14 additions & 2 deletions winpython/wppm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def normalize(name):
return re.sub(r"[-_.]+", "-", name).lower()


def get_package_metadata(database, name):
def get_package_metadata(database, name, gotoWWW=False):
"""Extract infos (description, url) from the local database"""
# Note: we could use the PyPI database but this has been written on
# machine which is not connected to the internet
Expand Down Expand Up @@ -78,6 +78,18 @@ def get_package_metadata(database, name):
metadata(name)['Summary']+'\n').splitlines()[0]
except:
pass
if my_metadata['description'] == '' and gotoWWW:
from winpython import utils
dir_path = os.path.dirname(sys.executable)
this = normalize(name)
pip_ask = 'pip search '+ this
try:
pip_res = (utils.exec_shell_cmd(pip_ask, dir_path)+'\n').splitlines()
pip_filter = [l for l in pip_res if this + " (" == l[:len(this)+2]]+['']
pip_desc = (pip_filter[0][len(this)+1:]).split(" -", 1)[1]
my_metadata['description'] = '**' + pip_desc
except:
pass
return my_metadata


Expand Down Expand Up @@ -131,7 +143,7 @@ def extract_optional_infos(self):
"""Extract package optional infos (description, url)
from the package database"""
metadata = get_package_metadata(
'packages.ini', self.name
'packages.ini', self.name, True
)
for key, value in list(metadata.items()):
setattr(self, key, value)
Expand Down