granular_configuration_language .yaml.decorators.interpolate

granular_configuration_language.yaml.decorators.interpolate.interpolate_value_eager_io(
func: Callable[[Concatenate[str, P]], RT],
/,
) Callable[[Concatenate[str, P]], RT][source]

Replaces the 1st parameter with the interpolated value before calling the function.

This version is for Eager IO functions.

This does a limited interpolation that does not support references (e.g. ${$.value} and ${/value})

This is not for Tags functions.

  • This decorator is for functions passed to .as_eager_io() and .as_eager_io_with_root_and_load_options(), not wrapped by.

  • For Tags, use interpolate_value_without_ref()

Parameters:

func (Callable[Concatenate[str, P], RT]) – Function to be wrapped

Returns:

Wrapped Function

Return type:

Callable[Concatenate[str, P], RT]

granular_configuration_language.yaml.decorators.interpolate.interpolation_needs_ref_condition(value: str) bool[source]

A needs_root_condition usable by as_lazy_with_root().

Works with interpolate_value_with_ref() to check if value uses a JSON Path or JSON Pointer interpolation.

Used by !Sub.

Parameters:

value (str) – Unprocessed YAML str

Returns:

True, if the value contains an interpolation that uses JSON Path or Pointer

Return type:

bool

granular_configuration_language.yaml.decorators.interpolate.interpolate_value_with_ref(
func: Callable[[Concatenate[str, Root, P]], RT],
/,
) Callable[[Concatenate[str, Root, P]], RT][source]

Replaces the YAML string value with the interpolated value before calling the tag function

“with_ref” does full interpolation, supporting references (e.g. ${$.value} and ${/value}).

Parameters:

func (Callable[Concatenate[str, Root, P], RT]) – Function to be wrapped

Returns:

Wrapped Function

Return type:

Callable[Concatenate[str, Root, P], RT]

Example:
@string_tag(Tag("!Tag"))
@as_lazy_with_root
@interpolate_value_with_ref
def tag(value: str, root: Root) -> Any: ...


@string_tag(Tag("!Tag"))
@as_lazy_with_root_and_load_options
@interpolate_value_with_ref
def tag_with_options(value: str, root: Root, options: LoadOptions) -> Any: ...
granular_configuration_language.yaml.decorators.interpolate.interpolate_value_without_ref(
func: Callable[[Concatenate[str, P]], RT],
/,
) Callable[[Concatenate[str, P]], RT][source]

Replaces the YAML string value with the interpolated value before calling the tag function

“without_ref” does a limited interpolation that does not support references (e.g. ${$.value} and ${/value})

Parameters:

func (Callable[Concatenate[str, P], RT]) – Function to be wrapped

Returns:

Wrapped Function

Return type:

Callable[Concatenate[str, P], RT]

Example:
@string_tag(Tag("!Tag"))
@as_lazy
@interpolate_value_with_ref
def tag(value: str) -> Any: ...


@string_tag(Tag("!Tag"))
@as_lazy_with_load_options
@interpolate_value_with_ref
def tag_with_options(value: str, options: LoadOptions) -> Any: ...