f_lib.archive_extractor package

Archive extractors.

class f_lib.archive_extractor.ArchiveExtractor[source]

Bases: ABC

Abstract base class for archive extractors.

SUFFIX: ClassVar[tuple[str, ...]] = ()

File extension/suffix supported by the extractor.

__init__(archive: Path | str, *, strict: bool = True) None[source]

Instantiate class.

Parameters:
  • archive – Path to the archive file.

  • strict – Raise an error if the provided archive file does not have the expected file extension/suffix.

classmethod can_extract(archive: Path | str) bool[source]

Determine if the extractor can attempt to extract the file.

Parameters:

archive – Path to an archive file.

abstractmethod extract(destination: Path) Path[source]

Extract the archive file.

Parameters:

destination – Where the archive file will be extracted to.

Returns:

Path to the extraction.

archive: Path

Resolved path to the archive file.

class f_lib.archive_extractor.TarExtractor[source]

Bases: ArchiveExtractor

Extractor for .tar archives.

Supports bz2, gz, and xz compression types.

SUFFIX: ClassVar[tuple[str, ...]] = ('.gzip', '.tar', '.tar.gz', '.tar.bz2', '.tar.xz')

File extension/suffix supported by the extractor.

extract(destination: Path) Path[source]

Extract the archive file.

Parameters:

destination – Where the archive file will be extracted to.

Returns:

Path to the extraction.

class f_lib.archive_extractor.ZipExtractor[source]

Bases: ArchiveExtractor

Extractor for .zip archives.

SUFFIX: ClassVar[tuple[str, ...]] = ('.zip',)

File extension/suffix supported by the extractor.

extract(destination: Path) Path[source]

Extract the archive file.

Parameters:

destination – Where the archive file will be extracted to.

Returns:

Path to the extraction.

Submodules