Ejemplo n.º 1
0
 def list_packages(self):
     """
     Retrieve a list of the package names registered with the package index.
     Returns a list of name strings.
     """
     session = DBSession()
     names = [p.name for p in Package.all(session, order_by=Package.name)]
     session.rollback()
     return names
Ejemplo n.º 2
0
 def package_releases(self, package_name, show_hidden=False):
     """
     Retrieve a list of the releases registered for the given package_name.
     Returns a list with all version strings if show_hidden is True or
     only the non-hidden ones otherwise."""
     session = DBSession()
     releases = Release.by_package_name(session, package_name, show_hidden)
     session.rollback()
     return releases
Ejemplo n.º 3
0
 def package_releases(self, package_name, show_hidden=False):
     """
     Retrieve a list of the releases registered for the given package_name.
     Returns a list with all version strings if show_hidden is True or
     only the non-hidden ones otherwise."""
     session = DBSession()
     releases = Release.by_package_name(session, package_name, show_hidden)
     session.rollback()
     return releases
Ejemplo n.º 4
0
 def list_packages(self):
     """
     Retrieve a list of the package names registered with the package index.
     Returns a list of name strings.
     """
     session = DBSession()
     names = [p.name for p in Package.all(session, order_by=Package.name)]
     session.rollback()
     return names
Ejemplo n.º 5
0
 def release_downloads(self, package_name, version):
     """
     Retrieve a list of files and download count for a given package and
     release version. 
     """
     session = DBSession()
     release_files = ReleaseFile.by_release(session, package_name, version)
     if release_files:
         release_files = [(f.release.package.name,
                          f.filename) for f in release_files]
     session.rollback()
     return release_files
Ejemplo n.º 6
0
 def user_packages(self, user):
     """
     Retrieve a list of [role_name, package_name] for a given username.
     Role is either 'Maintainer' or 'Owner'. 
     """
     session = DBSession()
     owned = Package.by_owner(session, user)
     maintained = Package.by_maintainer(session, user)
     owned = [('Owner', p.name) for p in owned]
     maintained = [('Maintainer', p.name) for p in maintained]
     session.rollback()
     return owned + maintained
Ejemplo n.º 7
0
 def release_downloads(self, package_name, version):
     """
     Retrieve a list of files and download count for a given package and
     release version. 
     """
     session = DBSession()
     release_files = ReleaseFile.by_release(session, package_name, version)
     if release_files:
         release_files = [(f.release.package.name, f.filename)
                          for f in release_files]
     session.rollback()
     return release_files
Ejemplo n.º 8
0
 def user_packages(self, user):
     """
     Retrieve a list of [role_name, package_name] for a given username.
     Role is either 'Maintainer' or 'Owner'. 
     """
     session = DBSession()
     owned = Package.by_owner(session, user)
     maintained = Package.by_maintainer(session, user)
     owned = [('Owner', p.name) for p in owned]
     maintained = [('Maintainer', p.name) for p in maintained]
     session.rollback()
     return owned + maintained
Ejemplo n.º 9
0
    def search(self, spec, operator='and'):
        """
        Search the package database using the indicated search spec. 

        The spec may include any of the keywords described in the above list
        (except 'stable_version' and 'classifiers'),
        for example: {'description': 'spam'} will search description fields.
        Within the spec, a field's value can be a string or a list of strings
        (the values within the list are combined with an OR),
        for example: {'name': ['foo', 'bar']}.
        Valid keys for the spec dict are listed here. Invalid keys are ignored:
            name
            version
            author
            author_email
            maintainer
            maintainer_email
            home_page
            license
            summary
            description
            keywords
            platform
            download_url 
        Arguments for different fields are combined using either "and"
        (the default) or "or".
        Example: search({'name': 'foo', 'description': 'bar'}, 'or').
        The results are returned as a list of dicts
        {'name': package name,
         'version': package release version,
         'summary': package release summary} 
        """
        api = pypi.proxy
        rv = []
        # search in proxy
        for k, v in spec.items():
            rv += api.search({k: v}, True)

        # search in local
        session = DBSession()
        release = Release.search(session, spec, operator)
        session.rollback()
        rv += [
            {
                'name': r.package.name,
                'version': r.version,
                'summary': r.summary,
                # hack https://mail.python.org/pipermail/catalog-sig/2012-October/004633.html
                '_pypi_ordering': '',
            } for r in release
        ]
        return rv
Ejemplo n.º 10
0
    def search(self, spec, operator='and'):
        """
        Search the package database using the indicated search spec. 

        The spec may include any of the keywords described in the above list
        (except 'stable_version' and 'classifiers'),
        for example: {'description': 'spam'} will search description fields.
        Within the spec, a field's value can be a string or a list of strings
        (the values within the list are combined with an OR),
        for example: {'name': ['foo', 'bar']}.
        Valid keys for the spec dict are listed here. Invalid keys are ignored:
            name
            version
            author
            author_email
            maintainer
            maintainer_email
            home_page
            license
            summary
            description
            keywords
            platform
            download_url 
        Arguments for different fields are combined using either "and"
        (the default) or "or".
        Example: search({'name': 'foo', 'description': 'bar'}, 'or').
        The results are returned as a list of dicts
        {'name': package name,
         'version': package release version,
         'summary': package release summary} 
        """
        api = pypi.proxy
        rv = []
         # search in proxy
        for k, v in spec.items():
            rv += api.search({k: v}, True)

        # search in local
        session = DBSession()
        release = Release.search(session, spec, operator)
        session.rollback()
        rv += [{'name': r.package.name,
                'version': r.version,
                'summary': r.summary,
                # hack https://mail.python.org/pipermail/catalog-sig/2012-October/004633.html
                '_pypi_ordering':'',
                } for r in release]
        return rv
Ejemplo n.º 11
0
    def search(self, spec, operator='and'):
        """
        Search the package database using the indicated search spec. 

        The spec may include any of the keywords described in the above list
        (except 'stable_version' and 'classifiers'),
        for example: {'description': 'spam'} will search description fields.
        Within the spec, a field's value can be a string or a list of strings
        (the values within the list are combined with an OR),
        for example: {'name': ['foo', 'bar']}.
        Valid keys for the spec dict are listed here. Invalid keys are ignored:
            name
            version
            author
            author_email
            maintainer
            maintainer_email
            home_page
            license
            summary
            description
            keywords
            platform
            download_url 
        Arguments for different fields are combined using either "and"
        (the default) or "or".
        Example: search({'name': 'foo', 'description': 'bar'}, 'or').
        The results are returned as a list of dicts
        {'name': package name,
         'version': package release version,
         'summary': package release summary} 
        """
        session = DBSession()
        release = Release.search(session, spec, operator)
        session.rollback()
        rv = [{'name': r.package.name,
               'version': r.version,
               'summary': r.summary} for r in release]
        return rv