pymovements.utils.archives.extract_archive#

pymovements.utils.archives.extract_archive(source_path: Path, destination_path: Path | None = None, recursive: bool = True, remove_finished: bool = False, remove_top_level: bool = True, verbose: int = 1) Path#

Extract an archive.

The archive type and a possible compression is automatically detected from the file name. If the file is compressed but not an archive the call is dispatched to _decompress().

Parameters:
  • source_path (Path) – Path to the file to be extracted.

  • destination_path (Path | None) – Path to the directory the file will be extracted to. If omitted, the directory of the file is used. (default: None)

  • recursive (bool) – Recursively extract archives which are included in extracted archive. (default: True)

  • remove_finished (bool) – If True, remove the file after the extraction. (default: False)

  • remove_top_level (bool) – If True, remove the top-level directory if it has only one child. (default: True)

  • verbose (int) – Verbosity levels: (1) Print messages for extracting each dataset resource without printing messages for recursive archives. (2) Print additional messages for each recursive archive extract. (default: 1)

Returns:

Path to the directory the file was extracted to.

Return type:

Path