datalad_next.iter_collections.utils

Utilities and types for collection iterators

class datalad_next.iter_collections.utils.FileSystemItem(type: 'FileSystemItemType', name: 'Any', size: 'int', mtime: 'float | None' = None, mode: 'int | None' = None, uid: 'int | None' = None, gid: 'int | None' = None, link_target: 'Any | None' = None, fp: 'IO | None' = None)[source]

Bases: PathBasedItem, TypedItem

fp: IO | None = None
classmethod from_path(path: Path, *, link_target: bool = True)[source]

Populate item properties from a single stat and readlink call

The given path must exist. The link_target flag indicates whether to report the result of readlink for a symlink-type path.

gid: int | None = None

Returns the link_target as a PurePath instance

mode: int | None = None
mtime: float | None = None
size: int
type: FileSystemItemType
uid: int | None = None
class datalad_next.iter_collections.utils.FileSystemItemType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enumeration of file system path types

The associated str values are chosen to be appropriate for downstream use (e.g, as type labels in DataLad result records).

directory = 'directory'
file = 'file'
specialfile = 'specialfile'
class datalad_next.iter_collections.utils.NamedItem(name: 'Any')[source]

Bases: object

name: Any
class datalad_next.iter_collections.utils.PathBasedItem(name: Any)[source]

Bases: NamedItem

An item with a path as its name

A dedicated property supports the conversion of the native name representation into a PurePath instance.

Any argument understood by the PurePath constructor can be used as name, such as a a filename, a relative path, or an absolute path -- in string form, as path segment sequence, or a Path instance.

It is recommended to use name/path values that are relative to the containing collection (directory, archive, repository, etc.).

path() PurePath[source]

Returns the item name as a PurePath instance

This default implementation assumes the name to be platform path conventions.

class datalad_next.iter_collections.utils.TypedItem(type: 'Any')[source]

Bases: object

type: Any
datalad_next.iter_collections.utils.compute_multihash_from_fp(fp, hash: List[str], bufsize=65536)[source]

Compute multiple hashes from a file-like