owmeta_core.bundle.archive module¶
- exception owmeta_core.bundle.archive.ArchiveTargetPathDoesNotExist[source]¶
Bases:
ExceptionThrown when the
Archivertarget path does not exist
- exception owmeta_core.bundle.archive.TargetDirectoryMismatch(target_directory, expected_target_directory)[source]¶
Bases:
UnarchiveFailedThrown when the target path doesn’t agree with the bundle manifest
- exception owmeta_core.bundle.archive.UnarchiveFailed[source]¶
Bases:
ExceptionThrown when an
Unarchiverfails for some reason not covered by other
- class owmeta_core.bundle.archive.ArchiveExtractor(targetdir, tarfile)[source]¶
Bases:
objectExtracts
tarfilearchives- 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:
objectArchives 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_directorymust be provided- version
int,optional Bundle version
- bundle_directory
str,optional Bundle directory. If omitted,
bundle_idmust be provided. If provided,bundle_idandversionare 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
BundleNotFoundThrown when the bundle with the given ID cannot be found, or cannot be found at the demanded version
ArchiveTargetPathDoesNotExistThrown when the path to the desired target file does not exist
- class owmeta_core.bundle.archive.Unarchiver(bundles_directory=None)[source]¶
Bases:
objectUnpacks 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_directoryis provided, andbundles_directoryis provided at initialization, then if the bundle manifest doesn’t match the expected archive path, then an exception is raised.- Parameters
- input_file
stror 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
NotABundlePathThrown in one of these conditions:
If the
input_fileis not in an expected format (lzma-zipped TAR file)If the
input_filedoes not have a “manifest” fileIf the
input_filemanifest file is invalid or is not a regular file (seevalidate_manifestfor further details)If the
input_fileis a file path and the corresponding file is not found
TargetDirectoryMismatchThrown when both a
bundles_directoryhas been set at initialization and atarget_directoryis passed to this method and the path underbundles_directoryindicated by the manifest in theinput_filedoes not agree withtarget_directory