ocebuild.filesystem.archives
#
Methods for handling and extracting archive formats.
Module Contents#
Functions#
|
Extracts a file from a URL and yields a temporary extraction directory. |
- ocebuild.filesystem.archives.extract_archive(url: str | urllib.request.Request, persist: bool = False) Generator[ocebuild.third_party.cpython.pathlib.Path, str, None] [source]#
Extracts a file from a URL and yields a temporary extraction directory.
- Parameters:
url – URL of the archive file.
persist – Flag to disable cleanup of the temporary directory.
- Yields:
tmp_dir (str) – Path to the temporary directory.
Example
>>> with extract_archive('https://example.com/foo.zip') as tmp_dir: print(tmp_dir) # -> "/tmp/xxxxxx"