hydra.pg.terms_to_elements module

Functions for mapping Hydra terms to property graph elements using mapping specifications.

hydra.pg.terms_to_elements.apply_pattern(cx: T0, first_lit: str, pairs: Sequence[tuple[Sequence[str], str]], term: Term) object

Apply a parsed pattern to a term, producing string terms.

hydra.pg.terms_to_elements.decode_edge_label(cx: T0, g: Graph, t: Term) object

Decode an edge label from a term.

hydra.pg.terms_to_elements.decode_edge_spec(cx: T0, g: Graph, term: Term) object

Decode an edge specification from a term.

hydra.pg.terms_to_elements.decode_element_spec(cx: T0, g: Graph, term: Term) object

Decode an element specification from a term.

hydra.pg.terms_to_elements.decode_property_key(cx: T0, g: Graph, t: Term) object

Decode a property key from a term.

hydra.pg.terms_to_elements.decode_property_spec(cx: T0, g: Graph, term: Term) object

Decode a property specification from a term.

hydra.pg.terms_to_elements.decode_value_spec(cx: T0, g: Graph, term: Term) object

Decode a value specification from a term.

hydra.pg.terms_to_elements.decode_vertex_label(cx: T0, g: Graph, t: Term) object

Decode a vertex label from a term.

hydra.pg.terms_to_elements.decode_vertex_spec(cx: T0, g: Graph, term: Term) object

Decode a vertex specification from a term.

hydra.pg.terms_to_elements.eval_path(cx: T0, path: Sequence[str], term: Term) object

Evaluate a path (list of steps) on a term, returning all resulting terms.

hydra.pg.terms_to_elements.eval_step(cx: T0, step: str, term: Term) object

Evaluate a single step of a path traversal on a term.

hydra.pg.terms_to_elements.expect_list(cx: T0, g: Graph, f: Callable[[T0, Graph, Term], object], term: Term) object

Extract a list from a term and apply a decoder to each element.

hydra.pg.terms_to_elements.parse_edge_id_pattern(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], spec: ValueSpec) object

Parse an edge id pattern from a value spec and schema.

hydra.pg.terms_to_elements.parse_edge_spec(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], spec: EdgeSpec) object

Parse an edge specification into a label and encoder function.

hydra.pg.terms_to_elements.parse_element_spec(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], spec: ElementSpec) object

Parse an element specification into a label and encoder function.

hydra.pg.terms_to_elements.parse_pattern(cx: T0, _g: T1, pat: str) object

Parse a string pattern into a function that traverses terms.

hydra.pg.terms_to_elements.parse_property_spec(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], spec: PropertySpec) object

Parse a property specification into an encoder function.

hydra.pg.terms_to_elements.parse_value_spec(cx: T0, g: T1, spec: ValueSpec) object

Parse a value specification into a function that processes terms.

hydra.pg.terms_to_elements.parse_vertex_id_pattern(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], spec: ValueSpec) object

Parse a vertex id pattern from a value spec and schema.

hydra.pg.terms_to_elements.parse_vertex_spec(cx: T0, g: T1, schema: Schema[T2, T3, T4, Error], spec: VertexSpec) object

Parse a vertex specification into a label and encoder function.

hydra.pg.terms_to_elements.read_field(cx: T0, fields: Mapping[Name, T1], fname: Name, fun: Callable[[T1], object]) object

Read a field from a map of fields by name.

hydra.pg.terms_to_elements.read_injection(cx: T0, g: Graph, cases: Sequence[tuple[Name, Callable[[Term], object]]], encoded: Term) object

Read an injection (union value) from a term.

hydra.pg.terms_to_elements.read_record(cx: T0, g: Graph, cons: Callable[[Mapping[Name, Term]], object], term: Term) object

Read a record from a term as a map of field names to values.

hydra.pg.terms_to_elements.require_unique(cx: T0, context: str, fun: Callable[[T1], object], term: T1) object

Require exactly one result from a list-producing function.

hydra.pg.terms_to_elements.term_to_elements_adapter(cx: T0, g: Graph, schema: Schema[T1, T2, T3, Error], typ: Type) object

Create an adapter that maps terms to property graph elements using a mapping specification.

hydra.pg.terms_to_elements.term_to_string(term: Term) str

Convert a term to its string representation.