def available_on_pypi(prerelease=current_version.is_prerelease): """Return True if an update is available on PyPI. >>> available_on_pypi() # doctest: +ELLIPSIS <Version('...')> >>> available_on_pypi(prerelease=False).is_prerelease False """ client = ServerProxy('https://pypi.python.org/pypi') versions = client.package_releases('pwntools', True) versions = map(packaging.version.Version, versions) if not prerelease: versions = filter(lambda v: not v.is_prerelease, versions) return max(versions)
def available_on_pypi(prerelease=current_version.is_prerelease): """Return True if an update is available on PyPI. >>> available_on_pypi() # doctest: +ELLIPSIS <Version('...')> >>> available_on_pypi(prerelease=False).is_prerelease False """ # Deferred import to save startup time from six.moves.xmlrpc_client import ServerProxy versions = getattr(available_on_pypi, 'cached', None) if versions is None: client = ServerProxy('https://pypi.python.org/pypi') versions = client.package_releases('pwntools', True) available_on_pypi.cached = versions versions = map(packaging.version.Version, versions) if not prerelease: versions = filter(lambda v: not v.is_prerelease, versions) return max(versions)