Skip to content

Commit 166de9d

Browse files
committed
bug fix
was not working for packageX-detail if packageX was defined
1 parent 6b7b6ed commit 166de9d

File tree

3 files changed

+77
-32
lines changed

3 files changed

+77
-32
lines changed

winpython/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '2.3.20200408'
31+
__version__ = '2.3.20200410'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

winpython/data/packages.ini

+48-3
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ description = Fiona reads and writes spatial data files
533533
description = the modular source code checker: pep8, pyflakes and co
534534
535535
[flask]
536-
description = A microframework based on Werkzeug, Jinja2 and good intentions
536+
description = A simple framework for building complex web applications.
537537
538538
[flaskerize]
539539
description = Python CLI build/dev tool for templated code generation and project modification. Think Angular schematics for Python.
@@ -842,7 +842,7 @@ description = Differentiate, compile, and transform Numpy code.
842842
description = An autocompletion tool for Python that can be used for text editors.
843843
844844
[jinja2]
845-
description = A very fast and expressive template engine.
845+
description = A small but fast and easy to use stand-alone template engine written in pure python.
846846
847847
[jmespath]
848848
description = JSON Matching Expressions
@@ -2155,7 +2155,7 @@ description = Plugin for the Spyder IDE that integrates the Python memory profil
21552155
description = A plugin to run the autopep8 python linter from within the spyder editor
21562156
21572157
[sqlalchemy]
2158-
description = SQL Toolkit and Object Relational Mapper
2158+
description = Database Abstraction Library
21592159
21602160
[sqlite-bro]
21612161
description = a graphic SQLite Client in 1 Python file
@@ -2509,3 +2509,48 @@ description = What-If Tool TensorBoard plugin.
25092509
[tbb]
25102510
description = Intel(R) Threading Building Blocks
25112511

2512+
[geemap]
2513+
description = A Python package for interactive mapping using Google Earth Engine and ipyleaflet
2514+
2515+
[earthengine-api]
2516+
description = Earth Engine Python API
2517+
2518+
[ipynb-py-convert]
2519+
description = Convert .py files runnable in VSCode/Python or Atom/Hydrogen to jupyter .ipynb notebooks and vice versa
2520+
2521+
[google-cloud-storage]
2522+
description = Google Cloud Storage API client library
2523+
2524+
[google-auth-httplib2]
2525+
description = Google Authentication Library: httplib2 transport
2526+
2527+
[httplib2shim]
2528+
description = A wrapper over urllib3 that matches httplib2's interface
2529+
2530+
[google-cloud-core]
2531+
description = Google Cloud API client core library
2532+
2533+
[google-resumable-media]
2534+
description = Utilities for Google Media Downloads and Resumable Uploads
2535+
2536+
[google-api-core]
2537+
description = Google API client core library
2538+
2539+
[googleapis-common-protos]
2540+
description = Common protobufs used in Google APIs
2541+
2542+
[pipenv]
2543+
description = Python Development Workflow for Humans.
2544+
2545+
[virtualenv-clone]
2546+
description = script to clone virtualenvs.
2547+
2548+
[virtualenv]
2549+
description = Virtual Python Environment builder
2550+
2551+
[distlib]
2552+
description = Distribution utilities
2553+
2554+
[flask-sqlalchemy]
2555+
description = Adds SQLAlchemy support to your Flask application.
2556+

winpython/wppm.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,26 @@
4444

4545
# pep503 defines normalized package names: www.python.org/dev/peps/pep-0503
4646
def normalize(name):
47+
""" return normalized (unique) name of a package"""
4748
return re.sub(r"[-_.]+", "-", name).lower()
4849

4950
def get_official_description(name):
50-
from winpython import utils
51-
dir_path = os.path.dirname(sys.executable)
52-
this = normalize(name)
53-
this_len = len(this)
54-
pip_ask = ['pip', 'search', this, '--retries', '0']
55-
if len(this)<2: # don't ask stupid things
56-
return ''
57-
try:
58-
# .run work when .popen fails when no internet
59-
pip_res = (utils.exec_run_cmd(pip_ask)+'\n').splitlines()
60-
pip_filter = [l for l in pip_res if this + " (" ==
61-
normalize(l[:this_len])+l[this_len:this_len+2]]
62-
pip_desc = (pip_filter[0][len(this)+1:]).split(" - ", 1)[1]
63-
return pip_desc.replace("://", " ")
64-
except:
65-
return ''
51+
"""Extract package Summary description from pypi.org"""
52+
from winpython import utils
53+
this = normalize(name)
54+
this_len = len(this)
55+
pip_ask = ['pip', 'search', this, '--retries', '0']
56+
if len(this)<2: # don't ask stupid things
57+
return ''
58+
try:
59+
# .run work when .popen fails when no internet
60+
pip_res = (utils.exec_run_cmd(pip_ask)+'\n').splitlines()
61+
pip_filter = [l for l in pip_res if this + " (" ==
62+
normalize(l[:this_len])+l[this_len:this_len+2]]
63+
pip_desc = (pip_filter[0][len(this)+1:]).split(" - ", 1)[1]
64+
return pip_desc.replace("://", " ")
65+
except:
66+
return ''
6667

6768
def get_package_metadata(database, name, gotoWWW=False, update=False):
6869
"""Extract infos (description, url) from the local database"""
@@ -76,34 +77,33 @@ def get_package_metadata(database, name, gotoWWW=False, update=False):
7677
url='https://pypi.org/project/' + name,
7778
)
7879
for key in my_metadata:
79-
name1 = name.lower()
8080
# wheel replace '-' per '_' in key
81-
for name2 in (
82-
name1,
83-
name1.split('-')[0],
84-
name1.replace('-', '_'),
85-
'-'.join(name1.split('_')),
86-
normalize(name),
87-
):
81+
for name2 in (name, normalize(name)):
8882
try:
8983
my_metadata[key] = db.get(name2, key)
9084
break
9185
except (cp.NoSectionError, cp.NoOptionError):
9286
pass
93-
database_desc = my_metadata.get('description')
94-
if my_metadata.get('description') == '' and metadata: # nothing in package.ini
87+
db_desc = my_metadata.get('description')
88+
89+
if my_metadata.get('description') == '' and metadata:
90+
# nothing in package.ini, we look in our installed packages
9591
try:
9692
my_metadata['description']=(
9793
metadata(name)['Summary']+'\n').splitlines()[0]
9894
except:
9995
pass
96+
10097
if my_metadata['description'] == '' and gotoWWW:
98+
# still nothing, try look on pypi
10199
the_official = get_official_description(name)
102100
if the_official != '':
103101
my_metadata['description'] = the_official
104-
if update == True and database_desc == '' and my_metadata['description'] !='':
102+
103+
if update == True and db_desc == '' and my_metadata['description'] != '':
104+
# we add new findings in our packgages.ini list, if it's required
105105
try:
106-
db[normalize(name)]={}
106+
db[normalize(name)] = {}
107107
db[normalize(name)]['description'] = my_metadata['description']
108108
with open(osp.join(DATA_PATH, database), 'w') as configfile:
109109
db.write(configfile)

0 commit comments

Comments
 (0)