Python Forum
PyPi XML_RPC command wrapper class
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyPi XML_RPC command wrapper class
#1
I just finished a wrapper class for the complete PyPi XML-RPC command set.

It's available on github here:


To get started, all you need to do is instanciate the class
ppi = PyPiInfo()
Here's a sample:

get_release_data(self, package_name, version)


Retrieve metadata describing a specific package release. Returns a dict with keys for

    name
    version
    stable_version
    author
    author_email
    maintainer
    maintainer_email
    home_page
    license
    summary
    description
    keywords
    platform
    download_url
    classifiers (list of classifier strings)
    requires
    requires_dist
    provides
    requires_external
    requires_python
    obsoletes
    obsoletes_dist
    project_url
    docs_url (URL of the packages.python.org docs if they've been supplied)
    # =========================================
    # a dict of metadata describing a specific package release
    # =========================================
    print('\n=========================================')
    release_data = ppi.get_release_data(package_name, releases[0])
    print("Package: {} - Version: {} - Release Data".format(package_name, releases[n]))
    for key, value in release_data.items():
        print('{}: {}'.format(key, value))
    print()
    time.sleep(.2)

get_search(self, *command)

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} 
    # =========================================
    # Search the package database using the indicated search spec
    # =========================================
    print('\n=========================================')
    search_packages = ppi.get_search({'name': package_name, 'version': releases[0]})
    for n, search_dict in enumerate(search_packages):
        print("Package: {} - Version: {} - Search Results".format(package_name, releases[n]))
        for key, value in search_dict.items():
            print('{}: {}'.format(key, value))
        print()
    time.sleep(.2)
Credits: Original commands and call descriptions come from from PyPi
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Information Asynchronous & synchronous Wrapper for Backblaze's B2 WardWeeb 0 2,171 Oct-16-2020, 05:23 AM
Last Post: WardWeeb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020