squirrel.zarr.key

Module Contents

Functions

flatten(nested_keys: List[Iterable[str]]) → List[str]

Flatten a nested list of keys.

is_dir(key: str) → bool

Infers if a given key is for a folder or not (.zip files are considered as files).

is_squirrel_key(key: str) → bool

Check if the given key is a key set by squirrel.

is_zarr_chunk(key: str) → bool

Determines whether a key contains zarr chunk pattern (e.g. ‘0.0.0’) or not.

is_zarr_key(key: str) → bool

Check if the given key is a zarr key.

key_end(key: str, separator: str = '/') → str

Split the key with separator and return the last token.

normalize_key(key: str, key_separator: str = '/') → str

Normalize keys.

Attributes

ZARR_CHUNK_PATTERN

squirrel.zarr.key.ZARR_CHUNK_PATTERN
squirrel.zarr.key.flatten(nested_keys: List[Iterable[str]])List[str]

Flatten a nested list of keys.

squirrel.zarr.key.is_dir(key: str)bool

Infers if a given key is for a folder or not (.zip files are considered as files).

squirrel.zarr.key.is_squirrel_key(key: str)bool

Check if the given key is a key set by squirrel.

squirrel.zarr.key.is_zarr_chunk(key: str)bool

Determines whether a key contains zarr chunk pattern (e.g. ‘0.0.0’) or not.

squirrel.zarr.key.is_zarr_key(key: str)bool

Check if the given key is a zarr key.

squirrel.zarr.key.key_end(key: str, separator: str = '/')str

Split the key with separator and return the last token.

Examples

>>> key_end("path/to/my.file")
'my.file'
>>> key_end("path/to/my.file", separator=".")
'file'
squirrel.zarr.key.normalize_key(key: str, key_separator: str = '/')str

Normalize keys.

Removes preceding and trailing whitespace and ‘key_separator’s. If the key corresponds to a folder, then it is made sure that the key ends with key_separator.