yaml_include.funcs module#
- yaml_include.funcs.lazy_load(obj, loader_type, constructor, nested=False)[source]#
Recursively load and parse all
Datainstances insideobjin generative mode.This function is similar to
load(), with the following differences:It returns a generator that yields each
Datainstance found withinobj.It performs in-place parsing and replacement, but does not return the fully parsed object.
- Yields:
Object parsed from the
Datainstances 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
Datainstances withinobj.If
Constructor.autoloadis set toFalse,yaml.load()will not open or read included files. In this case,yaml.load()returns an object containingDatainstances, but the included files remain unprocessed. This function opens and parses those included files represented byDatainstances withinobj.- Parameters:
obj (Any) – An object containing
Datainstances.loader_type (Type[Union[_Loader, _CLoader]]) – The type of PyYAML Loader used for parsing strings in included files.
constructor (Constructor) – A
Constructorinstance used to locate, open, and read included files.inplace (bool) – Whether to perform in-place replacement for each
Datainstance inobj.nested (bool) –
Whether to recursively parse and load “include statements” inside
Datainstances.Note
The
nestedargument is used to handle scenarios of nested includes, also known as “include within include”.The function is always recursive, regardless of the
nestedargument 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
objis too deeply nested.