Write me.
Set default value for the given scalar config variable.
Returns the default value for the given scalar config variable.
Get the description for the given config variable or group.
Returns the type of the given config variable.
If the config variable is a scalar, non-enumerated type, then the return value will be the corresponding python type (int, str, unicode, float, etc.)
If the variable is a scalar enumerated type, the return value will be a tuple of possible values for that variable.
For non-scalar types, the return value will be one of List, Dict, or Group.
Returns the schema for a container variable (List or Dict), or None for scalar variables.
The schema is another config object (Var, List, Dict, or Group).
>>> kaa.config.get_description(cfg.movies)
u'Your favorite movies.'
>>> schema = kaa.config.get_schema(cfg.movies)
>>> kaa.config.get_description(schema)
u'A movie name.'
>>> kaa.config.get_type(schema)
<type 'str'>
Returns a Config object representing the config file provided in ‘filenane’. If module is None, the specified config file must have the module specified (in the “-- module: ... --” metadata), otherwise the supplied module (string) is used. The module must be importable.
If the config module cannot be determined and one is not specified, will raise ValueError. If import fails, will raise ImportError. Otherwise will return the Config object.
Base class for all config objects.
kaa.config.Base
add_monitor() | |
---|---|
copy() | Returns a deep-copy of the object. Monitor callbacks are not copied. |
remove_monitor() |
parent | read-only |
---|
Returns a deep-copy of the object. Monitor callbacks are not copied.
Parameters: | copy_on_write (bool) – if False, values are copied as well, so that if the original is modified, the copy will retain the old value. If True, fetching values in the copy will fetch the original’s current value, until and unless the copy’s value has been modified. |
---|---|
Returns: | a new cloned instance of the same type. |
Note that only values may be copy-on-write. Any changes to the original’s schema (including type information and defaults) will not be reflected in the copy.
A config variable that represents some scalar value such as int, str, unicode, or bool.
kaa.config.Base
└─ kaa.config.Var
copy() |
---|
A config list.
kaa.config.Base
└─ kaa.config.Container
└─ kaa.config.List
append() | |
---|---|
extend() | |
insert() | |
pop() | |
remove() |
A config dict.
kaa.config.Base
└─ kaa.config.Container
└─ kaa.config.Dict
get() | Get group or variable with the given index. Return None if it does not exist. |
---|---|
items() | Return key,value list (sorted by key name) |
keys() | Return the keys (sorted by name) |
values() | Return value list (sorted by key name) |
Get group or variable with the given index. Return None if it does not exist.
Return key,value list (sorted by key name)
Return the keys (sorted by name)
Return value list (sorted by key name)
A config group.
kaa.config.Base
└─ kaa.config.Group
add_variable() | Add a variable to the group. The name will be set into the given value. The object will _not_ be copied. |
---|---|
copy() |
variables | read-only | List of variables for this group. |
---|
Add a variable to the group. The name will be set into the given value. The object will _not_ be copied.
List of variables for this group.
A config object. This is a group with functions to load and save a file.
kaa.config.Base
└─ kaa.Object
└─ kaa.config.Group
└─ kaa.config.Config
copy() | |
---|---|
load() | Load values from a config file previously saved for this schema. |
save() | Save configuration file. |
watch() | If argument is True (default), adds a watch to the config file and will reload the config if it changes. If INotify is available, use that, otherwise stat the file every 3 seconds. |
autosave | read/write | Whether or not changes are automatically save. |
---|
reloaded | Emitted when the configuration file is automatically reloaded from disk due to watch(). |
---|
Load values from a config file previously saved for this schema.
Parameters: |
|
---|
If no filename has been previously set with the filename property then the filename argument is required, and in that case the filename property will be set to this value.
Save configuration file.
Parameters: |
|
---|
If argument is True (default), adds a watch to the config file and will reload the config if it changes. If INotify is available, use that, otherwise stat the file every 3 seconds.
If argument is False, disable any watches.
Whether or not changes are automatically save.
If True, will write the config filename (either previously passed to load() or defined by the filename property) 5 seconds after the last config value update (or program exit, whichever comes first).
Default is False.
Emitted when the configuration file is automatically reloaded from disk due to watch().
Param changed_names: | |
---|---|
the names of the variables that changed | |
Type changed_names: | |
list |