read_document

function of dascore.utils.documents source

read_document(
    path: Path ,
    file_format: Literal[‘json’, ‘yaml’] ,
    error: type[<class ’Exception] = <class ‘dascore.exceptions.ParameterError’>,
    holds: str = describes nothing,
)-> ‘dict[str, Any]’

Return the mapping a document file holds.

Which parser to use is the caller’s to decide, because each format names its files its own way; everything after that is the same.

Parameters

Parameter Description
path The file to read.
file_format Either “json” or “yaml”.
error The exception raised for a file which cannot be read, cannot be
parsed, or holds something other than a mapping.
holds How to finish the sentence “ holds no mapping, so it …”.