Skip to content

Commit b411c3f

Browse files
authored
Merge pull request winpython#826 from stonebig/master
remove the need to update package.ini step2
2 parents 39e955a + 562afcb commit b411c3f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

winpython/wppm.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def normalize(name):
4747
return re.sub(r"[-_.]+", "-", name).lower()
4848

4949

50-
def get_package_metadata(database, name):
50+
def get_package_metadata(database, name, gotoWWW=False):
5151
"""Extract infos (description, url) from the local database"""
5252
# Note: we could use the PyPI database but this has been written on
5353
# machine which is not connected to the internet
@@ -78,6 +78,18 @@ def get_package_metadata(database, name):
7878
metadata(name)['Summary']+'\n').splitlines()[0]
7979
except:
8080
pass
81+
if my_metadata['description'] == '' and gotoWWW:
82+
from winpython import utils
83+
dir_path = os.path.dirname(sys.executable)
84+
this = normalize(name)
85+
pip_ask = 'pip search '+ this
86+
try:
87+
pip_res = (utils.exec_shell_cmd(pip_ask, dir_path)+'\n').splitlines()
88+
pip_filter = [l for l in pip_res if this + " (" == l[:len(this)+2]]+['']
89+
pip_desc = (pip_filter[0][len(this)+1:]).split(" -", 1)[1]
90+
my_metadata['description'] = '**' + pip_desc
91+
except:
92+
pass
8193
return my_metadata
8294

8395

@@ -131,7 +143,7 @@ def extract_optional_infos(self):
131143
"""Extract package optional infos (description, url)
132144
from the package database"""
133145
metadata = get_package_metadata(
134-
'packages.ini', self.name
146+
'packages.ini', self.name, True
135147
)
136148
for key, value in list(metadata.items()):
137149
setattr(self, key, value)

0 commit comments

Comments
 (0)