nemo_export.tarutils#

Module Contents#

Classes#

TarPath

A class that represents a path inside a TAR archive and behaves like pathlib.Path.

ZarrPathStore

An implementation of read-only Store for zarr library that works with pathlib.Path or TarPath objects.

Data#

API#

nemo_export.tarutils.LOGGER = 'getLogger(...)'#
class nemo_export.tarutils.TarPath(
tar: Union[str, tarfile.TarFile, nemo_export.tarutils.TarPath],
*parts,
)[source]#

A class that represents a path inside a TAR archive and behaves like pathlib.Path.

Expected use is to create a TarPath for the root of the archive first, and then derive paths to other files or directories inside the archive like so:

with TarPath(‘/path/to/archive.tar’) as archive: myfile = archive / ‘filename.txt’ if myfile.exists(): data = myfile.read() …

Only read and enumeration operations are supported.

Initialization

__del__()[source]#
__truediv__(key) nemo_export.tarutils.TarPath[source]#
__str__() str[source]#
property tarobject#

Returns the wrapped tar object.

property relpath#

Returns the relative path of the path.

property name#

Returns the name of the path.

property suffix#

Returns the suffix of the path.

__enter__()[source]#
__exit__(*args)[source]#
exists()[source]#

Checks if the path exists.

is_file()[source]#

Checks if the path is a file.

is_dir()[source]#

Checks if the path is a directory.

open(mode: str) IO[bytes][source]#

Opens a file in the archive.

glob(pattern)[source]#

Returns an iterator over the files in the directory, matching the pattern.

rglob(pattern)[source]#

Returns an iterator over the files in the directory, including subdirectories.

iterdir()[source]#

Returns an iterator over the files in the directory.

class nemo_export.tarutils.ZarrPathStore(tarpath: nemo_export.tarutils.TarPath)[source]#

Bases: zarr.storage.BaseStore

An implementation of read-only Store for zarr library that works with pathlib.Path or TarPath objects.

Initialization

__getitem__(key)[source]#
__contains__(key)[source]#
__iter__()[source]#
__len__()[source]#
abstractmethod __setitem__(key, value)[source]#
abstractmethod __delitem__(key)[source]#
keys()[source]#

Returns an iterator over the keys in the store.