This class represents a configuration entry in the config file that is loaded before module initalisation.
More...
|
def | __init__ (self, name=None, default=None, var_name=None, missing='nothing', constructor=None, checker=None, converter=None) |
| Create a ConfigOption object. More...
|
|
def | copy (self, kwargs) |
| Create a new instance of ConfigOption with copied values and update. More...
|
|
def | check (self, value) |
| If checker function set, check value. More...
|
|
def | convert (self, value) |
| If converter function set, convert value. More...
|
|
def | constructor (self, func) |
| This is the decorator for declaring a constructor function for this ConfigOption. More...
|
|
|
| missing |
|
| var_name |
|
| name |
|
| default |
|
| constructor_function |
|
| checker |
|
| converter |
|
This class represents a configuration entry in the config file that is loaded before module initalisation.
◆ __init__()
def core.module.ConfigOption.__init__ |
( |
|
self, |
|
|
|
name = None , |
|
|
|
default = None , |
|
|
|
var_name = None , |
|
|
|
missing = 'nothing' , |
|
|
|
constructor = None , |
|
|
|
checker = None , |
|
|
|
converter = None |
|
) |
| |
Create a ConfigOption object.
- Parameters
-
name | identifier of the option in the configuration file |
default | default value for the case that the option is not set in the config file |
var_name | name of the variable inside a running module. Only set this if you know what you are doing! |
missing | action to take when the option is not set. 'nothing' does nothing, 'warn' logs a warning, 'error' logs an error and prevents the module from loading |
constructor | constructor function for complex config option behaviour |
checker | static function that checks if value is ok |
converter | static function that forces type interpretation |
◆ check()
def core.module.ConfigOption.check |
( |
|
self, |
|
|
|
value |
|
) |
| |
If checker function set, check value.
Else assume everything is ok.
◆ constructor()
def core.module.ConfigOption.constructor |
( |
|
self, |
|
|
|
func |
|
) |
| |
This is the decorator for declaring a constructor function for this ConfigOption.
- Parameters
-
- Returns
- : return the original function so this can be used as a decorator
◆ convert()
def core.module.ConfigOption.convert |
( |
|
self, |
|
|
|
value |
|
) |
| |
If converter function set, convert value.
Needs to raise exception on error.
@param value: value to convert (or not)
@return: converted value (or passthrough)
◆ copy()
def core.module.ConfigOption.copy |
( |
|
self, |
|
|
|
kwargs |
|
) |
| |
Create a new instance of ConfigOption with copied values and update.
- Parameters
-
kwargs | extra arguments or overrides for the constructor of this class |
The documentation for this class was generated from the following file: