| |
- exceptions.Exception
-
- SettingError
- NoDefaultClass
- Setting
class NoDefaultClass |
|
Special class used for implementing "no default". Doing the
standard "default=None" thing makes it hard to set the default
to None. |
|
Methods defined here:
- __repr__(self)
- __str__(self)
|
class Setting |
|
Class for implementing settings.
Basically, this should be instantiated from within a module, and then
never directly touched again. The constructor takes several arguments:
name
the name of the setting, both from the irc interface, and for
internal access.
default
default value for the setting. Note that you need to apply the
defaults, usually with init_settings.
doc
documentation for the setting
get_cperm
cperm required to get the current value
set_cperm
cperm required to set a new value
conv_func
function for converting the value. This should take a string
and return the converted value, which can be anything.
get_conv_func
like conv_func, but is used at get time (after get_func). For
example, if you use string.split for conv_func, you might want
to use string.join for get_conv_func.
set_func
a function called to set the new values. The first arg will be
the kibot module instance (the python class instance). The
second will be the name of the setting (so you can use the same
function for multiple settings if you like) and the third will
be the value returned by conv_func (or the original string if
conv_func is not defined). If you define set_func, the
attribute WILL NOT be set in your mudule unless you do it
yourself in the function.
get_func
this should return the current value. It will be passed the
kibot module instance and name of the setting.
update_func
a function that will be called AFTER the setting is set. It
will be passed the kibot module instance and the name of the
setting. You may want to use this instead of set_func if you
want to save the value normally, but then take some action. |
|
Methods defined here:
- __init__(self, name, default=No Default, doc=None, get_cperm=1, set_cperm='manager', get_func=None, set_func=None, conv_func=None, get_conv_func=None, update_func=None)
- get(self, module)
- set(self, module, new_value)
- set_default(self, module)
- update_default(self, module)
|
|