datalad_next.iter_collections.directory

Report on the content of directories

The main functionality is provided by the iter_dir() function.

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

Bases: FileSystemItem

datalad_next.iter_collections.directory.iter_dir(path: Path, *, fp: bool = False) Generator[DirectoryItem, None, None][source]

Uses Path.iterdir() to iterate over a directory and reports content

The iterator produces an DirectoryItem instance with standard information on file system elements, such as size, or mtime.

In addition to a plain Path.iterdir() the report includes a path-type label (distinguished are file, directory, symlink).

Parameters:
  • path (Path) -- Path of the directory to report content for (iterate over).

  • fp (bool, optional) -- If True, each file-type item includes a file-like object to access the file's content. This file handle will be closed automatically when the next item is yielded.

Yields:

DirectoryItem