ds_common_placeholder_py_lib.resolve¶
File: resolve.py
Region: ds-common-placeholder-py-lib
Description¶
Walks a JSON value and resolves every placeholder (contract §8.1, §8.2).
Attributes¶
How many context values can be read inside one another, each through a |
|
paths, each a dotted string |
|
a dotted string ( |
|
The shortest string in a function's result over a secret that is |
Functions¶
|
Append key to a JSON Pointer. |
|
The JSON Pointer of a value in the context: |
|
Whether the value at the pointer at is, or is inside, a verbatim path. |
|
The JSON Pointers of the verbatim paths a caller passed. |
|
The keys of path, array indexes as strings. |
|
A verbatim value: a copy, with plain |
|
|
|
Reject a placeholder in an object key (contract §3). |
|
|
|
Render a value inside a longer string (contract §8.1). |
|
value as compact JSON text, non-ASCII escaped: |
|
Check the argument count of a registered function. |
|
Run each parameter's own check on its argument's value, a reference's |
|
For |
Module Contents¶
- ds_common_placeholder_py_lib.resolve.pointer(path: str, key: str | int) str[source]¶
Append key to a JSON Pointer.
- ds_common_placeholder_py_lib.resolve.context_pointer(namespace: str, path: tuple[str, ...]) str[source]¶
The JSON Pointer of a value in the context:
/<namespace>/<path…>.
- ds_common_placeholder_py_lib.resolve.is_verbatim(at: str, verbatim: frozenset[str]) bool[source]¶
Whether the value at the pointer at is, or is inside, a verbatim path.
- ds_common_placeholder_py_lib.resolve.READ_DEPTH_MAX = 64¶
How many context values can be read inside one another, each through a placeholder the one before it holds.
- ds_common_placeholder_py_lib.resolve.Paths¶
paths, each a dotted string (
tasks.0.settings.'a.b') or a list of keys (["tasks", 0, "a.b"]).- Type:
The
verbatimargument
- ds_common_placeholder_py_lib.resolve.verbatim_pointers(paths: Paths) frozenset[str][source]¶
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.
ValueError – If a string path is not a path, or a list of keys is empty.
- ds_common_placeholder_py_lib.resolve.Path¶
a dotted string (
tasks.0.settings.'a.b') or a list of keys (["tasks", 0, "a.b"]).- Type:
A path to a value
- ds_common_placeholder_py_lib.resolve.path_keys(path: Path) tuple[str, ...][source]¶
The keys of path, array indexes as strings.
- Raises:
TypeError – If path is neither a string nor a list of keys.
ValueError – If a string is not a path, or a list of keys is empty.
- ds_common_placeholder_py_lib.resolve.as_written(value: Any) Any[source]¶
A verbatim value: a copy, with plain
dictandlistcontainers as the rest of a resolved value has.
- ds_common_placeholder_py_lib.resolve.parse_at(text: str, path: str) list[ds_common_placeholder_py_lib.grammar.Segment][source]¶
parse()with path set on any error.
- ds_common_placeholder_py_lib.resolve.check_key(key: Any, path: str) Any[source]¶
Reject a placeholder in an object key (contract §3).
- Returns:
The key.
- Raises:
PlaceholderError –
syntax.
- ds_common_placeholder_py_lib.resolve.is_missing(value: Any) bool[source]¶
Noneand empty or blank strings are missing (contract §8.2).
- ds_common_placeholder_py_lib.resolve.as_text(value: Any) str[source]¶
Render a value inside a longer string (contract §8.1).
- Raises:
PlaceholderError –
typefor an object, array, or non-JSON value.
- ds_common_placeholder_py_lib.resolve.json_text(value: Any) str[source]¶
value as compact JSON text, non-ASCII escaped:
lookup’sjsonformat. A DataFrame, at any depth, is its rows, asdataframe_to_json_arraygives them.- Raises:
PlaceholderError –
typeif the value, or a value in it, is not JSON.
- ds_common_placeholder_py_lib.resolve.SECRET_PART_MIN = 6¶
The shortest string in a function’s result over a secret that is recorded as a secret.
- ds_common_placeholder_py_lib.resolve.check_arity(call: ds_common_placeholder_py_lib.grammar.Call, spec: ds_common_placeholder_py_lib.functions.FunctionSpec) None[source]¶
Check the argument count of a registered function.
- Raises:
PlaceholderError –
arity.
- ds_common_placeholder_py_lib.resolve.check_params(call: ds_common_placeholder_py_lib.grammar.Call, spec: ds_common_placeholder_py_lib.functions.FunctionSpec, values: list[Any]) None[source]¶
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.
- ds_common_placeholder_py_lib.resolve.check_lazy_literals(call: ds_common_placeholder_py_lib.grammar.Call) None[source]¶
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.