thoth.package_extract package


thoth.package_extract.cli module

Command line interface for thoth-package-extract.

thoth.package_extract.core module

Implementation of core routines for thoth-package-extract.

thoth.package_extract.core.extract_image(image_name: str, timeout: Optional[int] = None, *, registry_credentials: Optional[str] = None, tls_verify: bool = True) → dict[source]

Extract dependencies from an image.

thoth.package_extract.exceptions module

Exception hierarchy in thoth-package-extract tool.

exception thoth.package_extract.exceptions.InvalidImageError[source]

Bases: thoth.package_extract.exceptions.ThothPkgdepsException

Raised on invalid Docker image.

exception thoth.package_extract.exceptions.NotSupported[source]

Bases: thoth.package_extract.exceptions.ThothPkgdepsException

Raised on requesting an unsupported operation.

exception thoth.package_extract.exceptions.ThothPkgdepsException[source]

Bases: Exception

A base exception in the thoth-package-extract exception hierarchy.

exception thoth.package_extract.exceptions.TimeoutExpired[source]

Bases: thoth.package_extract.exceptions.ThothPkgdepsException

Raised on command timeout.

thoth.package_extract.image module

Manipulation with an image and image scanning.

thoth.package_extract.image.construct_rootfs(dir_path: str, rootfs_path: str) → list[source]

Construct rootfs in a directory by extracting layers.

thoth.package_extract.image.download_image(image_name: str, dir_path: str, timeout: int = None, registry_credentials: str = None, tls_verify: bool = True) → None[source]

Download an image to dir_path.

thoth.package_extract.image.get_image_size(path: str) → int[source]

Calculate the size of the image.

thoth.package_extract.image.run_analyzers(path: str, timeout: int = None) → dict[source]

Run analyzers on the given path (directory) and extract found packages.

thoth.package_extract.rpmlib module

Functionality copied from kobo.

Even though copying code is not nice at all, this is better to have copied. Assuming naming is mature and stable enough, it should be safe to have them there.

The original code can be found at:

Note we used code from Koji before, but that looks to be broken in some cases.


Split N-V-R into a dictionary.

@param nvre: N-V-R:E, E:N-V-R or N-E:V-R string @type nvre: str @return: {name, version, release, epoch} @rtype: dict


Split N-V-R.A[.rpm] into a dictionary.

@param nvra: N-V-R:E.A[.rpm], E:N-V-R.A[.rpm], N-V-R.A[.rpm]:E or N-E:V-R.A[.rpm] string @type nvra: str @return: {name, version, release, epoch, arch} @rtype: dict


Split nvre to N-V-R and E.

@param nvre: E:N-V-R or N-V-R:E string @type nvre: str @return: (N-V-R, E) @rtype: (str, str)

Module contents

Extraction of installed packages for project Thoth.

thoth.package_extract.extract_image(image_name: str, timeout: Optional[int] = None, *, registry_credentials: Optional[str] = None, tls_verify: bool = True) → dict[source]

Extract dependencies from an image.