marsh.config
¶
Tools for reading and writing config files.
Support for new file extensions may be added by registering more config schemas.
- meta_key: str = '_meta_'¶
This key is used to store any metadata in a config.
The metadata is typically dropped after variable interpolations have been performed.
- load(name, *names, root=None, resolve=True, keep_meta=False, concatenate=False)[source]¶
Load one or more config files.
When more than one config is loaded their contents are merged and the values of the succeeding config takes priority for fields where a merge can not be performed.
File extensions may be omitted.
- Parameters:
name (
str
) – Name of a config file.*names (
str
) – Any additional config files.root (
Optional
[str
]) – A root working directory for the config files. Defaults to the current working directory.resolve (
bool
) – Resolve omegaconf interpolations.keep_meta (
bool
) – Keep meta field if it exists.concatenate (
bool
) – Concatenate sequences when multiple configs are loaded and merged instead of replacing the previous value.
- Return type:
Union
[None
,int
,float
,bool
,str
,Sequence
[Any
],Mapping
[str
,Any
]]- Returns:
The loaded config.
- write(config, path='-')[source]¶
Write a config to a file.
By default the config is written to stdout in YAML format.