Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Keywords support (pypi) #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions Products/PloneSoftwareCenter/browser/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def _get_package(self, normalized_name, name, version, msg=None):

release = releases._getOb(version)
self._map_classifiers_to_compatibility(project, release)
self._map_keywords_to_categories(project, release)

return project, release

Expand All @@ -374,6 +375,18 @@ def _map_classifiers_to_compatibility(self, project, release):
if compats:
release.setCompatibility(compats)

def _map_keywords_to_categories(self, project, release):
"""This map keywords from setup.py to categories defined in PSC"""
project_cat = list(project.getCategories())
available_cat = project.getCategoriesVocab()
keywords = self.request.form.get('keywords', '').split(' ')

for keyword in keywords:
if keyword in available_cat and keyword not in project_cat:
project_cat.append(keyword)

project.setCategories(project_cat)

def _get_classifiers(self):
"""returns current classifiers"""
sc = self.context
Expand Down
13 changes: 13 additions & 0 deletions Products/PloneSoftwareCenter/tests/pypi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ Now let's upload the egg::
... 'md5_digest': 'd41d8cd98f00b204e9800998ecf8427e',
... 'filetype': 'sdist', 'pyversion': '',
... 'content': tarball, 'version': '0.2.3',
... 'classifiers': ['Programming Language :: Python',
... 'Framework :: Plone :: 4.1',
... 'Framework :: Plone :: 4.2'],
... 'keywords': 'plone add-on',
... 'name': 'iw.fss',
... 'description': 'this is **not rest**'}
>>> request = TestRequest(form=form)
Expand All @@ -268,6 +272,15 @@ We should have many releases now in this single project::
The main egg doesn't have a prefix so PloneHelpCenter works with it.
Secondary eggs have the name of the package as a prefix for the release id.

We should have mapping done between pypi's classifiers and psc's compatibility
and between pypi's keywords and psc's categories.

>>> project.getCategories()
('add-on',)
>>> releases['iw.fss-0.2.3'].getCompatibility()
('Plone 4.1', 'Plone 4.2')


Getting the release
===================

Expand Down
2 changes: 1 addition & 1 deletion docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
1.6.5 (unreleased)
------------------

- Nothing changed yet.
- Map keywords from setup.py to categories in project during release (pypi) [toutpt]


1.6.4 (2012-09-27)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def read(*rnames):
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
],
keywords='',
keywords='plone project',
author='Plone Website Team',
author_email='[email protected]',
maintainer='Alex Clark',
Expand Down