Configuration

class EasyCo.EasyCoConfig

Control behaviour of EasyCo

Variables
  • lower_case_keys (bool) – this will create and enforce lowercase keys

  • create_optional_keys (bool) – when creating a config file this will create optional keys, too

The configuration can be set by modifying EasyCo.DEFAULT_CONFIGURATION or by creating an instance of EasyCoConfig in a container

Example lowercase keys

import io
from EasyCo import ConfigFile, DEFAULT_CONFIGURATION
DEFAULT_CONFIGURATION.lower_case_keys = True

class MyConfigFile(ConfigFile):
    ConfValueA: int = 5
    ConfValueB: float = 5.5

cfg = MyConfigFile()
confvaluea: 5
confvalueb: 5.5

Example lowercase keys

This example also shows a per container configuration

import io
from EasyCo import ConfigFile, EasyCoConfig, DEFAULT_CONFIGURATION
DEFAULT_CONFIGURATION.lower_case_keys = True

class MyConfigFile(ConfigFile):
    ConfValueA: int = 5
    ConfValueB: float = 5.5

    # name of config doesn't matter and can be private so it doesn't show up in auto-complete
    __cfg = EasyCoConfig()
    __cfg.lower_case_keys = False

cfg = MyConfigFile()
ConfValueA: 5
ConfValueB: 5.5