yaml_include.data module¶
- class yaml_include.data.Data(urlpath: str, flatten: bool = False, sequence_params: ~typing.Sequence[~typing.Any] = <factory>, mapping_params: ~typing.Mapping[str, ~typing.Any] = <factory>)[source]¶
Bases:
objectA
dataclasses.dataclass()store YAML include statement- Parameters:
- urlpath: str¶
url/path of the YAML include statement
urlpathcan be either absolute (like /usr/src/Python-1.5/*.yml) or relative (like ../../Tools/*/*.yml), and can contain shell-style wildcards.We support
"**","?"and"[..]". We do not support"^"for pattern negation. Themaxdepthoption is applied on the first"**"found in the path.Warning
Using the
"**"pattern in large directory trees or remote files may consume an inordinate amount of time.
- flatten: bool = False¶
Whether to flatten sequence object pared from multiple matched YAML files.
Only available when multiple files were matched
Every matched file should have a Sequence object in its top level, or a
TypeErrorexception may be thrown.
Example
Consider we have such a YAML:
items: !include "*.yaml"
If every file matches *.yaml contains a sequence object at the top level in it, what parsed and loaded will be:
items: [ [item 0 of 1st file, item 1 of 1st file, ... , item n of 1st file, ...], [item 0 of 2nd file, item 1 of 2nd file, ... , item n of 2nd file, ...], # .... [item 0 of nth file, item 1 of nth file, ... , item n of nth file, ...], # ... ]
It’s a 2-dim array, because YAML content of each matched file is treated as a member of the list(sequence).
But if
flattenparameter was set totrue, like:items: !include {urlpath: "*.yaml", flatten: true}
we’ll get:
items: [ item 0 of 1st file, item 1 of 1st file, ... , item n of 1st file, # ... item 0 of 2nd file, item 1 of 2nd file, ... , item n of 2nd file, # ... # .... item 0 of n-th file, item 1 of n-th file, ... , item n of n-th file, # ... # ... ]