owmeta_core.bundle.archive module¶
- exception owmeta_core.bundle.archive.ArchiveTargetPathDoesNotExist[source]¶
Bases:
Exception
Thrown when the
Archiver
target path does not exist
- exception owmeta_core.bundle.archive.TargetDirectoryMismatch(target_directory, expected_target_directory)[source]¶
Bases:
UnarchiveFailed
Thrown when the target path doesn’t agree with the bundle manifest
- exception owmeta_core.bundle.archive.UnarchiveFailed[source]¶
Bases:
Exception
Thrown when an
Unarchiver
fails for some reason not covered by other
- class owmeta_core.bundle.archive.ArchiveExtractor(targetdir, tarfile)[source]¶
Bases:
object
Extracts
tarfile
archives- Parameters
- targetdir
str
The directory to which the archive will be extracted
- tarfile
tarfile.TarFile
The file to extract
- targetdir
- class owmeta_core.bundle.archive.Archiver(target_directory, bundles_directory=None)[source]¶
Bases:
object
Archives a bundle directory tree
- Parameters
- pack(bundle_id=None, version=None, *, bundle_directory=None, target_file_name=None)[source]¶
Pack an installed bundle into an archive file
- Parameters
- bundle_id
str
,optional
ID of the bundle to pack. If omitted, the
bundle_directory
must be provided- version
int
,optional
Bundle version
- bundle_directory
str
,optional
Bundle directory. If omitted,
bundle_id
must be provided. If provided,bundle_id
andversion
are ignored- target_file_name
str
,optional
Name of the archive file. If not provided, the name will be ‘bundle.tar.xz’ and will placed in the
target_directory
. Relative paths are relative totarget_directory
- bundle_id
- Raises
BundleNotFound
Thrown when the bundle with the given ID cannot be found, or cannot be found at the demanded version
ArchiveTargetPathDoesNotExist
Thrown when the path to the desired target file does not exist
- class owmeta_core.bundle.archive.Unarchiver(bundles_directory=None)[source]¶
Bases:
object
Unpacks an archive file (e.g., a
tar.xz
) of a bundle- Parameters
- bundles_directory
str
,optional
The directory under which bundles should be unpacked. Typically the bundle cache directory.
- bundles_directory
- classmethod manifest(bundle_tarfile, input_file=None)[source]¶
Get the manifest file from a bundle archive
- Parameters
- bundle_tarfile
tarfile.TarFile
Tarfile, ostensibly containing bundle data
- input_filefile object or
str
,optional
Name of the tar file. Will attempt to extract it from the tarfile if not given
- bundle_tarfile
- unpack(input_file, target_directory=None)[source]¶
Unpack the archive file
If
target_directory
is provided, andbundles_directory
is provided at initialization, then if the bundle manifest doesn’t match the expected archive path, then an exception is raised.- Parameters
- input_file
str
or file object The archive file
- target_directory
str
,optional
The path where the archive should be unpacked. If this argument is not provided, then the target directory is derived from
bundles_directory
(seefmt_bundle_directory
)
- input_file
- Raises
NotABundlePath
Thrown in one of these conditions:
If the
input_file
is not in an expected format (lzma-zipped TAR file)If the
input_file
does not have a “manifest” fileIf the
input_file
manifest file is invalid or is not a regular file (seevalidate_manifest
for further details)If the
input_file
is a file path and the corresponding file is not found
TargetDirectoryMismatch
Thrown when both a
bundles_directory
has been set at initialization and atarget_directory
is passed to this method and the path underbundles_directory
indicated by the manifest in theinput_file
does not agree withtarget_directory