PyPi XML_RPC command wrapper class - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: Code sharing (https://python-forum.io/forum-5.html) +--- Thread: PyPi XML_RPC command wrapper class (/thread-1146.html) |
PyPi XML_RPC command wrapper class - Larz60+ - Dec-07-2016 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 |