ds_common_placeholder_py_lib.resolve ==================================== .. py:module:: ds_common_placeholder_py_lib.resolve .. autoapi-nested-parse:: **File:** ``resolve.py`` **Region:** ``ds-common-placeholder-py-lib`` Description ----------- Walks a JSON value and resolves every placeholder (contract §8.1, §8.2). Attributes ---------- .. autoapisummary:: ds_common_placeholder_py_lib.resolve.READ_DEPTH_MAX ds_common_placeholder_py_lib.resolve.Paths ds_common_placeholder_py_lib.resolve.Path ds_common_placeholder_py_lib.resolve.SECRET_PART_MIN Functions --------- .. autoapisummary:: ds_common_placeholder_py_lib.resolve.pointer ds_common_placeholder_py_lib.resolve.context_pointer ds_common_placeholder_py_lib.resolve.is_verbatim ds_common_placeholder_py_lib.resolve.verbatim_pointers ds_common_placeholder_py_lib.resolve.path_keys ds_common_placeholder_py_lib.resolve.as_written ds_common_placeholder_py_lib.resolve.parse_at ds_common_placeholder_py_lib.resolve.check_key ds_common_placeholder_py_lib.resolve.is_missing ds_common_placeholder_py_lib.resolve.as_text ds_common_placeholder_py_lib.resolve.json_text ds_common_placeholder_py_lib.resolve.check_arity ds_common_placeholder_py_lib.resolve.check_params ds_common_placeholder_py_lib.resolve.check_lazy_literals Module Contents --------------- .. py:function:: pointer(path: str, key: str | int) -> str Append *key* to a JSON Pointer. .. py:function:: context_pointer(namespace: str, path: tuple[str, ...]) -> str The JSON Pointer of a value in the context: ``//``. .. py:function:: is_verbatim(at: str, verbatim: frozenset[str]) -> bool Whether the value at the pointer *at* is, or is inside, a verbatim path. .. py:data:: READ_DEPTH_MAX :value: 64 How many context values can be read inside one another, each through a placeholder the one before it holds. .. py:data:: Paths paths, each a dotted string (``tasks.0.settings.'a.b'``) or a list of keys (``["tasks", 0, "a.b"]``). :type: The ``verbatim`` argument .. py:function:: verbatim_pointers(paths: Paths) -> frozenset[str] The JSON Pointers of the *verbatim* paths a caller passed. :raises TypeError: If *paths* is a single string, or a path is neither a string nor a list of keys. :raises ValueError: If a string path is not a path, or a list of keys is empty. .. py:data:: Path a dotted string (``tasks.0.settings.'a.b'``) or a list of keys (``["tasks", 0, "a.b"]``). :type: A path to a value .. py:function:: path_keys(path: Path) -> tuple[str, ...] The keys of *path*, array indexes as strings. :raises TypeError: If *path* is neither a string nor a list of keys. :raises ValueError: If a string is not a path, or a list of keys is empty. .. py:function:: as_written(value: Any) -> Any A verbatim value: a copy, with plain ``dict`` and ``list`` containers as the rest of a resolved value has. .. py:function:: parse_at(text: str, path: str) -> list[ds_common_placeholder_py_lib.grammar.Segment] :func:`parse` with *path* set on any error. .. py:function:: check_key(key: Any, path: str) -> Any Reject a placeholder in an object key (contract §3). :returns: The key. :raises PlaceholderError: ``syntax``. .. py:function:: is_missing(value: Any) -> bool ``None`` and empty or blank strings are missing (contract §8.2). .. py:function:: as_text(value: Any) -> str Render a value inside a longer string (contract §8.1). :raises PlaceholderError: ``type`` for an object, array, or non-JSON value. .. py:function:: json_text(value: Any) -> str *value* as compact JSON text, non-ASCII escaped: ``lookup``'s ``json`` format. A DataFrame, at any depth, is its rows, as ``dataframe_to_json_array`` gives them. :raises PlaceholderError: ``type`` if the value, or a value in it, is not JSON. .. py:data:: SECRET_PART_MIN :value: 6 The shortest string in a function's result over a secret that is recorded as a secret. .. py:function:: check_arity(call: ds_common_placeholder_py_lib.grammar.Call, spec: ds_common_placeholder_py_lib.functions.FunctionSpec) -> None Check the argument count of a registered function. :raises PlaceholderError: ``arity``. .. py:function:: check_params(call: ds_common_placeholder_py_lib.grammar.Call, spec: ds_common_placeholder_py_lib.functions.FunctionSpec, values: list[Any]) -> None Run each parameter's own check on its argument's value, a reference's value too, so a failure names the reference. :raises PlaceholderError: ``argument``. .. py:function:: check_lazy_literals(call: ds_common_placeholder_py_lib.grammar.Call) -> None For ``coalesce``: a literal must be last and not blank. A blank one is never a value, and nothing after a literal is ever read. :raises PlaceholderError: ``argument``.