module documentation

Convenient functions for making use of yamlpath.

Function guess_briefer_schema Suggest an alternative schema, with low confidence.
Function mk_yaml_editor Construct a YAML editor with load and dump methods.
Function mk_yamlpath_processor Construct a YAML Path processor/document for the data.
Function non_null_matches Generate NodeCoords matching any query_paths.
Function typed_data_to_schema Analyze nested data and produce a matching schema document.
Function _schema_entry_type Undocumented
def guess_briefer_schema(schema: dict[str, list[str]]) -> dict[str, list[str]]: (source)

Suggest an alternative schema, with low confidence.

Parameters
schema:dict[str, list[str]]A map of type names ('date', 'boolean', 'number', 'null') to lists of YAML Paths.
Returns
dict[str, list[str]]A dumb guess at an alternative schema that matches more patterns and fewer literal paths.
def mk_yaml_editor() -> YAML: (source)

Construct a YAML editor with load and dump methods.

Returns
YAMLA configured object able to .load and .dump YAML (ruamel.yaml.main.YAML).
def mk_yamlpath_processor(data: dict | list) -> Processor: (source)

Construct a YAML Path processor/document for the data.

Parameters
data:dict | listAn object from which to create the processor, or "surgeon."
Returns
ProcessorA document object able to .set_value and .get_nodes (yamlpath.Processor).
def non_null_matches(surgeon: Processor, *query_paths: str) -> Iterable[NodeCoords]: (source)

Generate NodeCoords matching any query_paths.

Omit any matches whose node attr is None.

Parameters
surgeon:ProcessorA yamlpath.Processor, already storing the YAML document to be queried.
*query_paths:strYAMLPath query strs to find matches for in the document.
Returns
Iterable[NodeCoords]Undocumented
Yields
Matching NodeCoords items from the document,
each having a node (value) attribute and path (YAMLPath) attribute.
def typed_data_to_schema(data: dict | list) -> dict: (source)

Analyze nested data and produce a matching schema document.

Parameters
data:dict | listA nested data object whose elements can be mapped to schema entries.
Returns
dictA schema dict mapping ('number', 'boolean', 'null', or 'date') to lists of YAML Paths.
def _schema_entry_type(obj: int | float | bool | None | datetime | date | time): (source)

Undocumented