pypi

PyPi index utils.

exception confirm.utils.pypi.NewerVersionFound(name, version)

Exception which is thrown when a newer package version was found.

Parameters:
  • name (str) – The package name

  • version (str) – The new package version

class confirm.utils.pypi.PackageInfo(name, pypi_index='https://pypi.confirm.ch/')

A parser to parse a single package from a PyPi simple package index.

Parameters:
  • name (str) – The package name

  • pypi_index (str) – The URL of the PyPi index

check_version(version)

Checks if there’s a newer version than version available.

Parameters:

version (str) – The version to check

Raises:

NewerVersionFound – In case a newer version was found

Hint

This includes only stable versions for now.

fetch()

Fetch the package informations from the PyPi index.

handle_data(data)

Handle the data found in the HTML content.

Parameters:

data (str) – The data of the HTML tag

property latest_version

The latest stable version.

Hint

This includes only stable versions for now.

Returns:

The latest stable version

Return type:

str

property names

The names of all packages.

Returns:

The package names

Return type:

set

property stable_versions

The stable version numbers of all packages.

Returns:

The stable package versions

Return type:

set

classmethod str_version(version)

Convert the tuple version into a string.

Parameters:

version (tuple) – The tuple version

Returns:

The string version

Return type:

str

Hint

Examples:

>>> version = PackageInfo.str_version(tuple((1, 2, 3)))
>>> version
'1.2.3'
>>> type(version)
<class 'str'>
classmethod tuple_version(version)

Convert the string version into a tuple.

Parameters:

version (str) – The string version

Returns:

The tuple version

Return type:

tuple

Hint

Examples:

>>> version = PackageInfo.tuple_version('1.2.3')
>>> version
(1, 2, 3)
>>> type(version)
<class 'tuple'>
property versions

The version numbers of all packages.

Returns:

The package versions

Return type:

set