emmet.core.types.id_paths
Locate the identifier fields of a document model.
Models annotate fields holding MP identifiers with IdentifierType, MaterialIdentifierType or TaskIdentifierType (see emmet.core.types.typing). find_identifier_paths walks a model and reports where, at any depth, such fields are found, and how to display them.
A path is a tuple of segments describing how to reach identifiers from a document (a plain dict, as obtained from a database or model_dump()):
str: the value of this key of a dict. Lists met on the way are traversed transparently, i.e. the rest of the path applies to each of their elements.
int: this position of a list or tuple.
VALUES: every value of a dict, for dict[str, <identifier>]-like fields.
KEYS: every key of a dict, for dict[<identifier>, …]-like fields. Can only be the last segment, since keys cannot be navigated further.
apply_to_path carries out a path on a document.
Module Attributes
Path segment: every value of a dict. |
|
Path segment: every key of a dict. |
|
formatter(value, legacy=<bool>), see IdDisplayFormat. |
Functions
Reformat in place the identifiers found at path below node. |
|
Find every identifier-typed field of a pydantic model, at any depth. |
|
Convert a dotted path to a tuple path. |