API - Package Lookup

Query Interface

yarg.get(package_name, pypi_server='https://pypi.python.org/pypi/')

Constructs a request to the PyPI server and returns a yarg.package.Package.

Parameters:
  • package_name – case sensitive name of the package on the PyPI server.
  • pypi_server

    (option) URL to the PyPI server.

    >>> import yarg
    >>> package = yarg.get('yarg')
    <Package yarg>
    

Package Object

class yarg.package.Package(pypi_dict)

A PyPI package.

Parameters:pypi_dict – A dictionary retrieved from the PyPI server.
author
>>> package = yarg.get('yarg')
>>> package.author
Author(name='Kura', email='kura@kura.io')
bugtracker
>>> package = yarg.get('yarg')
>>> package.bugtracker
'https://github.com/kura/yarg/issues'
classifiers
>>> package = yarg.get('yarg')
>>> package.classifiers
['License :: OSI Approved :: MIT License',
 'Programming Language :: Python :: 2.7',
 'Programming Language :: Python :: 3.4']
description
>>> package = yarg.get('yarg')
>>> package.description
'A super long description, usually uploaded from the README'
docs
>>> package = yarg.get('yarg')
>>> package.docs
'https://yarg.readthedocs.org/en/latest'
downloads
>>> package = yarg.get('yarg')
>>> package.downloads
Downloads(day=50100, week=367941, month=1601938)  # I wish
has_egg

Returns True if one of the yarg.release.Release objects in the latest set of release files is egg format. Returns False if not.

>>> package = yarg.get('yarg')
>>> package.has_egg
False
has_source

Returns True if one of the yarg.release.Release objects in the latest set of release files is source format. Returns False if not.

>>> package = yarg.get('yarg')
>>> package.has_source
True
has_wheel

Returns True if one of the yarg.release.Release objects in the latest set of release files is wheel format. Returns False if not.

>>> package = yarg.get('yarg')
>>> package.has_wheel
True
homepage
>>> package = yarg.get('yarg')
>>> package.homepage
'https://kura.io/yarg/'
latest_release

A list of yarg.release.Release objects for each file in the latest release.

>>> package = yarg.get('yarg')
>>> package.latest_release
[<Release 0.1.0>, <Release 0.1.0>]
latest_release_id
>>> package = yarg.get('yarg')
>>> package.latest_release_id
'0.1.0'
license
>>> package = yarg.get('yarg')
>>> package.license
'MIT'
license_from_classifiers
>>> package = yarg.get('yarg')
>>> package.license_from_classifiers
'MIT License'
maintainer
>>> package = yarg.get('yarg')
>>> package.maintainer
Maintainer(name='Kura', email='kura@kura.io')
name
>>> package = yarg.get('yarg')
>>> package.name
'yarg'
pypi_url
>>> package = yarg.get('yarg')
>>> package.url
'https://pypi.python.org/pypi/yarg'
python_implementations

Returns a list of Python implementation strings that the package has listed in yarg.Release.classifiers.

>>> package = yarg.get('yarg')
>>> package.python_implementations
['CPython', 'PyPy']
python_versions

Returns a list of Python version strings that the package has listed in yarg.Release.classifiers.

>>> package = yarg.get('yarg')
>>> package.python_versions
['2.6', '2.7', '3.3', '3.4']
release(release_id)

A list of yarg.release.Release objects for each file in a release.

Parameters:release_id

A pypi release id.

>>> package = yarg.get('yarg')
>>> last_release = yarg.releases[-1]
>>> package.release(last_release)
[<Release 0.1.0>, <Release 0.1.0>]
release_ids
>>> package = yarg.get('yarg')
>>> package.release_ids
['0.0.1', '0.0.5', '0.1.0']
summary
>>> package = yarg.get('yarg')
>>> package.summary
'Some random summary stuff'

Release Object

class yarg.release.Release(release_id, pypi_dict)

A release file from PyPI.

Parameters:
  • release_id – A release id.
  • pypi_dict – A dictionary of a release file.
filename
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r.filename
'yarg-0.1.0-py27-none-any.whl'
has_sig
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r.has_sig
True
md5_digest
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r.md5_digest
'bec88e1c1765ca6177360e8f37b44c5c'
package_type
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r.package_type
'wheel'
python_version
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r.python_version
'2.7'
release_id
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r[0].release_id
'0.1.0'
size
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r.size
52941
uploaded
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r.uploaded
datetime.datime(2014, 8, 7, 21, 26, 19)
url
>>> package = yarg.get('yarg')
>>> v = "0.1.0"
>>> r = package.release(v)
>>> r.url
'https://pypi.python.org/packages/2.7/y/yarg/yarg...'

Exceptions and Errors

class yarg.exceptions.HTTPError(*args, **kwargs)

A catchall HTTPError exception to handle HTTP errors when using yarg.get().

This exception is also loaded at yarg.HTTPError for ease of access.

Member:status_code
errno

exception errno

filename

exception filename

strerror

exception strerror