yaml_include.funcs module

Contents

yaml_include.funcs module#

yaml_include.funcs.lazy_load(obj, loader_type, constructor, nested=False)[source]#

Recursively load and parse all Data instances inside obj in generative mode.

This function is similar to load(), with the following differences:

  • It returns a generator that yields each Data instance found within obj.

  • It performs in-place parsing and replacement, but does not return the fully parsed object.

Yields:

Object parsed from the Data instances as one is encountered.

Return type:

Generator[Any, None, Any]

Parameters:
  • obj (Any)

  • loader_type (Type[Union[_Loader, _CLoader]])

  • constructor (Constructor)

  • nested (bool)

yaml_include.funcs.load(obj, loader_type, constructor, inplace=False, nested=False)[source]#

Recursively load and parse all Data instances within obj.

If Constructor.autoload is set to False, yaml.load() will not open or read included files. In this case, yaml.load() returns an object containing Data instances, but the included files remain unprocessed. This function opens and parses those included files represented by Data instances within obj.

Parameters:
  • obj (Any) – An object containing Data instances.

  • loader_type (Type[Union[_Loader, _CLoader]]) – The type of PyYAML Loader used for parsing strings in included files.

  • constructor (Constructor) – A Constructor instance used to locate, open, and read included files.

  • inplace (bool) – Whether to perform in-place replacement for each Data instance in obj.

  • nested (bool) –

    Whether to recursively parse and load “include statements” inside Data instances.

    Note

    • The nested argument is used to handle scenarios of nested includes, also known as “include within include”.

    • The function is always recursive, regardless of the nested argument value.

Return type:

Any

Returns:

The fully parsed object with all included files loaded and processed.

Warning

This function is recursive and can lead to a stack overflow if obj is too deeply nested.