# 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.

  property name

        >>> package = yarg.get('yarg')
        >>> package.name
        u'yarg'

  property pypi_url

        >>> package = yarg.get('yarg')
        >>> package.url
        u'https://pypi.python.org/pypi/yarg'

  property summary

        >>> package = yarg.get('yarg')
        >>> package.summary
        u'Some random summary stuff'

  property description

        >>> package = yarg.get('yarg')
        >>> package.description
        u'A super long description, usually uploaded from the README'

  property homepage

        >>> package = yarg.get('yarg')
        >>> package.homepage
        u'https://kura.io/yarg/'

  property bugtracker

        >>> package = yarg.get('yarg')
        >>> package.bugtracker
        u'https://github.com/kura/yarg/issues'

  property docs

        >>> package = yarg.get('yarg')
        >>> package.docs
        u'https://yarg.readthedocs.org/en/latest'

  property author

        >>> package = yarg.get('yarg')
        >>> package.author
        Author(name=u'Kura', email=u'kura@kura.io')

  property maintainer

        >>> package = yarg.get('yarg')
        >>> package.maintainer
        Maintainer(name=u'Kura', email=u'kura@kura.io')

  property license

        >>> package = yarg.get('yarg')
        >>> package.license
        u'MIT'

  property license_from_classifiers

        >>> package = yarg.get('yarg')
        >>> package.license_from_classifiers
        u'MIT License'

  property downloads

        >>> package = yarg.get('yarg')
        >>> package.downloads
        Downloads(day=50100, week=367941, month=1601938)  # I wish

  property classifiers

        >>> package = yarg.get('yarg')
        >>> package.classifiers
        [u'License :: OSI Approved :: MIT License',
         u'Programming Language :: Python :: 2.7',
         u'Programming Language :: Python :: 3.4']

  property 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
        [u'2.6', u'2.7', u'3.3', u'3.4']

  property 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
        [u'CPython', u'PyPy']

  property latest_release_id

        >>> package = yarg.get('yarg')
        >>> package.latest_release_id
        u'0.1.0'

  property 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>]

  property 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

  property 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

  property 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

  property release_ids

        >>> package = yarg.get('yarg')
        >>> package.release_ids
        [u'0.0.1', u'0.0.5', u'0.1.0']

  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 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.

  property release_id

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r[0].release_id
        u'0.1.0'

  property uploaded

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r.uploaded
        datetime.datime(2014, 8, 7, 21, 26, 19)

  property python_version

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r.python_version
        u'2.7'

  property url

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r.url
        u'https://pypi.python.org/packages/2.7/y/yarg/yarg...'

  property md5_digest

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r.md5_digest
        u'bec88e1c1765ca6177360e8f37b44c5c'

  property filename

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r.filename
        u'yarg-0.1.0-py27-none-any.whl'

  property size

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r.size
        52941

  property package_type

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r.package_type
        u'wheel'

  property has_sig

        >>> package = yarg.get('yarg')
        >>> v = "0.1.0"
        >>> r = package.release(v)
        >>> r.has_sig
        True

## 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

  add_note()

    Exception.add_note(note) – add a note to the exception

  errno

    POSIX exception code

  filename

    exception filename

  filename2

    second exception filename

  strerror

    exception strerror

  with_traceback()

    Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.