tmt.libraries package
Submodules
tmt.libraries.beakerlib module
- class tmt.libraries.beakerlib.BeakerLib(*, identifier: DependencySimple | DependencyFmfId, parent: Common | None = None, logger: Logger)
Bases:
Library
A beakerlib library
Takes care of fetching beakerlib libraries from remote repositories based on provided library identifier described in detail here: https://tmt.readthedocs.io/en/latest/spec/tests.html#require
Optional ‘parent’ object inheriting from tmt.utils.Common can be provided in order to share the cache of already fetched libraries.
The following attributes are available in the object:
repo …….. library prefix (git repository name or nick if provided) name …….. library suffix (folder containing the library code)
url ……… full git repository url ref ……… git revision (branch, tag or commit) dest …….. target folder into which the library repo is cloned
tree …….. fmf tree holding library metadata require ….. list of required packages recommend … list of recommended packages
Libraries are fetched into the ‘libs’ directory under parent’s workdir or into ‘destination’ if provided in the identifier.
Process the library identifier and fetch the library
- fetch() None
Fetch the library (unless already fetched)
- property hostname: str
Get hostname from url or default to local
- class tmt.libraries.beakerlib.CommonWithLibraryCache(*, parent: CommonDerivedType | None = None, name: str | None = None, workdir: Literal[True] | Path | None = None, relative_indent: int = 1, cli_invocation: CliInvocation | None = None, logger: Logger, **kwargs: Any)
Bases:
Common
Initialize name and relation with the parent object
Prepare the workdir for provided id / directory path or generate a new workdir name if workdir=True given. Store command line context and options for future use if context is provided.
- cli_invocation: 'tmt.cli.CliInvocation' | None = None
tmt.libraries.file module
- class tmt.libraries.file.File(*, identifier: DependencyFile, parent: Common | None = None, logger: Logger, source_location: Path, target_location: Path)
Bases:
Library
Required files
Takes care of copying required files for specific test or library, more details here: https://tmt.readthedocs.io/en/latest/spec/tests.html#require
Optional ‘parent’ object inheriting from tmt.utils.Common can be provided in order to share the cache of already fetched libraries.
The following attributes are available in the object:
repo …….. library prefix (git repository name or nick if provided) pattern ….. filename paths and regexes which need to be copied
Process the library identifier and fetch the library
- fetch() None
Copy the files over to target location
Module contents
Handle libraries
- class tmt.libraries.Library(*, parent: Common | None = None, logger: Logger)
Bases:
object
General library class
Used as parent for specific libraries like beakerlib and file
Process the library identifier and fetch the library
- property hostname: str
Get hostname from url or default to local
- exception tmt.libraries.LibraryError
Bases:
Exception
Used when library cannot be parsed from the identifier
- tmt.libraries.dependencies(*, original_require: list[Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]], original_recommend: list[Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]] | None = None, parent: Common | None = None, imported_lib_ids: list[Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]] | None = None, logger: Logger, source_location: Path | None = None, target_location: Path | None = None) tuple[list[Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]], list[Union[tmt.base.DependencySimple, tmt.base.DependencyFmfId, tmt.base.DependencyFile]], list['LibraryType']]
Check dependencies for possible beakerlib libraries
Fetch all identified libraries, check their required and recommended packages. Return tuple (requires, recommends, libraries) containing list of regular rpm package names aggregated from all fetched libraries, list of aggregated recommended packages and a list of gathered libraries (instances of the Library class).
Avoid infinite recursion by keeping track of imported library identifiers and not trying to fetch those again.
- tmt.libraries.library_factory(*, identifier: DependencySimple | DependencyFmfId | DependencyFile, parent: Common | None = None, logger: Logger, source_location: Path | None = None, target_location: Path | None = None) BeakerLib | File
Factory function to get correct library instance