easycore.common.config¶
-
class
easycore.common.config.
CfgNode
(init_dict: dict = None, copy=True)[source]¶ Bases:
dict
Config Node
-
freeze
(frozen: bool = True)[source]¶ freeze or unfreeze the CfgNode and all of its children
Parameters: frozen (bool) – freeze or unfreeze the config
-
merge
(cfg)[source]¶ merge another CfgNode into this CfgNode, the another CfgNode will override this CfgNode.
Parameters: cfg (CfgNode) –
-
classmethod
open
(file, encoding='utf-8')[source]¶ load a CfgNode from file.
Parameters: Returns: CfgNode
-
classmethod
load
(yaml_str: str)[source]¶ load a CfgNode from a string of yaml format
Parameters: yaml_str (str) – Returns: CfgNode
-
classmethod
dump
(cfg, stream=None, encoding=None, **kwargs)[source]¶ dump CfgNode into yaml str or yaml file
Note
if stream option is set to non-None object, the CfgNode will be dumpped into stream and return None, if stream option is not given or set to None, return a string instead.
Parameters: - cfg (CfgNode) –
- stream (io.IOBase or None) – if set to a file object, the CfgNode will be dumpped into stream and return None, if set to None, return a string instead.
- encoding (str or None) –
- **kwargs –
options of the yaml dumper.
Some useful options: [“allow_unicode”, “line_break”, “explicit_start”, “explicit_end”, “version”, “tags”].
See more details at https://github.com/yaml/pyyaml/blob/2f463cf5b0e98a52bc20e348d1e69761bf263b86/lib3/yaml/__init__.py#L252
Returns: None or str
-