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: Schema) -> dict[str, list[str]]: (source)

Suggest an alternative schema, with low confidence.

Parameters
schema:SchemaA 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: TypedData | StringyData) -> Processor: (source)

Construct a YAML Path processor/document for the data.

Parameters
data:TypedData | StringyDataAn 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: TypedData) -> Schema: (source)

Analyze nested data and produce a matching schema document.

Parameters
data:TypedDataA nested data object whose elements can be mapped to schema entries.
Returns
SchemaA Schema dict, mapping SchemaKeys to lists of YAML Paths.
def _schema_entry_type(obj: SchemaNative) -> SchemaKey: (source)

Undocumented