calamari.catalog.logbook#

calamari.catalog.logbook(root, *, paths=None, delimiter=None)#

Logbook lines for every recognised file under root, sorted by date.

The one-call form of logbook_line() over a directory tree:

print("\n".join(calamari.logbook(data_dir)))

Files are discovered with find_files() (by content, never by extension, so stray non-measurement .dat files are skipped) and sorted by date then name – the order a paper logbook would be in. A file with no readable date sorts first rather than being dropped.

The walk is only a discovery convenience: when a catalog DataFrame has already done the discovering – and been filtered down to the rows that matter – re-walking the tree would silently resurrect every file the filtering dropped. Pass the surviving relative_path values as paths instead, and the logbook renders exactly those files, keeping the column alignment a per-file logbook_line() loop cannot:

kept = df[df["filename"] != "aborted.dat"]
print("\n".join(calamari.logbook(root, paths=kept["relative_path"])))
Parameters:
  • root (Path | str) – Directory tree to inventory (and the base that relative paths entries and the name cell are resolved against).

  • paths (Iterable[Path | str] | None) – Exactly which files to render, instead of walking root. Relative entries are resolved against root (absolute ones are used as-is), so a catalog’s relative_path column can be passed directly. A single bare path renders that one file – it is not iterated as characters. Unlike the walk, an entry that is not a recognised measurement file raises (UnsupportedFileError) rather than being skipped: an explicit list is a claim about what should be there, and a silently missing line would hide its failure.

  • delimiter (str | None) – None (default) pads the columns with spaces so the logbook reads aligned in a terminal or a text file. Pass '\t' for tab-separated lines to paste into a spreadsheet.

Return type:

list[str]

Returns:

list[str] – One line per recognised file. Empty when the tree holds none.

Raises:
  • OSError – If root is missing, is not a directory, or cannot be listed (walk mode; see find_files()), or if a file find_files() matched cannot be read when parsed – e.g. deleted mid-walk. Files that fail the signature check never raise; they are simply absent, like any other unrecognised file (paths mode raises instead, as above).

  • UnsupportedFileError – If a paths entry is not a recognised measurement file.