datalad_next.archive_operations

Handler for operations on various archive types

All handlers implement the API defined by ArchiveOperations.

Available handlers:

tarfile

TAR archive operation handler

zipfile

ZIP archive operation handler

class datalad_next.archive_operations.ArchiveOperations(location: Any, *, cfg: ConfigManager | None = None)[source]

Bases: ABC

Base class of all archives handlers

Any handler can be used as a context manager to adequately acquire and release any resources necessary to access an archive. Alternatively, the close() method can be called, when archive access is no longer needed.

In addition to the open() method for accessing archive item content, each handler implements the standard __contains__(), and __iter__() methods.

__contains__() -> bool reports whether the archive contains an items of a given identifier.

__iter__() provides an iterator that yields FileSystemItem instances with information on each archive item.

property cfg: ConfigManager

ConfigManager given to the constructor, or the session default

close() None[source]

Default implementation for closing a archive handler

This default implementation does nothing.

abstract open(item: Any) Generator[IO | None, None, None][source]

Get a file-like for an archive item

Parameters:

item -- Any identifier for an archive item supported by a particular handler