datalad_next.archive_operations.TarArchiveOperations
- class datalad_next.archive_operations.TarArchiveOperations(location: Path, *, cfg: ConfigManager | None = None)[source]
Bases:
ArchiveOperations
Handler for a TAR archive on a local file system
Any methods that take an archive item/member name as an argument accept a POSIX path string, or any PurePath instance.
- open(item: str | PurePosixPath) Generator[IO | None] [source]
Get a file-like for a TAR archive item
The file-like object allows to read from the archive-item specified by item.
- Parameters:
item (str | PurePath) -- The identifier must be a POSIX path string, or a PurePath instance.
- Returns:
A file-like object to read bytes from the item, if the item is a regular file, else None. (This is returned by the context manager that is created via the decorator @contextmanager.)
- Return type:
IO | None
- Raises:
KeyError -- If no item with the name item can be found in the tar-archive
- property tarfile: TarFile
Returns TarFile instance, after creating it on-demand
The instance is cached, and needs to be released by calling
.close()
if called outside a context manager.