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.datfiles 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_pathvalues aspathsinstead, and the logbook renders exactly those files, keeping the column alignment a per-filelogbook_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 relativepathsentries and the name cell are resolved against).paths (
Iterable[Path|str] |None) – Exactly which files to render, instead of walkingroot. Relative entries are resolved againstroot(absolute ones are used as-is), so a catalog’srelative_pathcolumn 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:
- Returns:
list[str]– One line per recognised file. Empty when the tree holds none.- Raises:
OSError – If
rootis missing, is not a directory, or cannot be listed (walk mode; seefind_files()), or if a filefind_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 (pathsmode raises instead, as above).UnsupportedFileError – If a
pathsentry is not a recognised measurement file.