Skip to content

settings

de_wiktio.settings

Settings module.

Classes:

  • Settings

    Settings class for the de_wiktio package.

Classes

Settings

Settings class for the de_wiktio package.

Allowed keys:
- XML_FILE, for path to the XML dump file
- DICT_PATH, for path to the dictionary folder

Settings are saved in the config.json file in the package folder.
If the configuration file does not exist, it will be created when get or set methods are called.

Methods:

  • get

    Get a value from the configuration file.

  • set

    Set a value in the configuration file.

Functions
get(key, default=None) classmethod

Get a value from the configuration file.

Allowed keys are: XML_FILE, DICT_PATH.

Source code in de_wiktio\settings.py
41
42
43
44
45
46
47
@classmethod
def get(cls, key, default=None) -> str:
    """Get a value from the configuration file.

    Allowed keys are: `XML_FILE`, `DICT_PATH`."""
    config = cls._load()
    return config.get(key, default)
set(key, value) classmethod

Set a value in the configuration file.

Allowed keys
  • XML_FILE, for path to the XML dump file
  • DICT_PATH, for path to the dictionary folder

To delete a value, set it to None.

Source code in de_wiktio\settings.py
49
50
51
52
53
54
55
56
57
58
59
60
61
@classmethod
def set(cls, key, value):
    """Set a value in the configuration file.

    Allowed keys: 
        - `XML_FILE`, for path to the XML dump file 
        - `DICT_PATH`, for path to the dictionary folder 

    To delete a value, set it to `None`.
    """
    config = cls._load()
    config[key] = value
    cls._save_config(config)