espnet3.utils.download.extract_targz
Less than 1 minute
espnet3.utils.download.extract_targz
espnet3.utils.download.extract_targz(archive_path: Path, dst_dir: Path, logger: Logger | None = None) → None
Extract a .tar.gz archive into a destination directory.
- Parameters:
- archive_path (Path) – Path to the .tar.gz archive.
- dst_dir (Path) – Directory to extract files into.
- logger (logging.Logger | None) – Logger to emit progress messages.
- Returns: None
- Raises:tarfile.TarError – If the archive is invalid or extraction fails.
Notes
- This uses
tarfile.TarFile.extractall(), which may be unsafe for untrusted archives (path traversal). Only extract archives from trusted sources.
Example
>>> extract_targz(Path("./data/file.tgz"), Path("./data/out"))