csbot.config module¶
-
class
csbot.config.
Config
(raw_data=None, trusted_data=None, deserialize_mapping=None, init=True, partial=True, strict=True, validate=False, app_data=None, lazy=False, **kwargs)[source]¶ Bases:
schematics.deprecated.Model
Base class for configuration schemas.
Use
option()
,option_list()
andoption_map()
to create fields in the schema. Schemas are also valid option types, so deeper structures can be defined.>>> class MyConfig(Config): ... delay = option(float, default=0.5, help="Number of seconds to wait") ... notify = option_list(str, help="Users to notify")
-
csbot.config.
ConfigError
¶ alias of
schematics.exceptions.DataError
-
csbot.config.
example_mode
()[source]¶ For the duration of this context manager, try to use example values before default values.
-
class
csbot.config.
WordList
(min_size=None, max_size=None, **kwargs)[source]¶ Bases:
schematics.types.compound.ListType
A list of strings that also accepts a space-separated string instead.
-
MESSAGES
= {'choices': <schematics.translator.LazyText object>, 'required': <schematics.translator.LazyText object>}¶
-
-
csbot.config.
is_allowable_type
(cls: Type[CT_co]) → bool[source]¶ Is cls allowed as a configuration option type?
-
csbot.config.
structure
(data: Mapping[str, Any], cls: Type[csbot.config.Config]) → csbot.config.Config[source]¶ Create an instance of cls from plain Python structure data.
-
csbot.config.
unstructure
(obj: csbot.config.Config) → Mapping[str, Any][source]¶ Get plain Python structured data from obj.
-
csbot.config.
loads
(s: str, cls: Type[csbot.config.Config]) → csbot.config.Config[source]¶ Create an instance of cls from the TOML in s.
-
csbot.config.
load
(f: TextIO, cls: Type[csbot.config.Config]) → csbot.config.Config[source]¶ Create an instance of cls from the TOML in f.
-
csbot.config.
dump
(obj: csbot.config.Config, f: TextIO)[source]¶ Write TOML representation of obj to f.
-
csbot.config.
option
(cls: Type[_B], *, required: bool = None, default: Union[None, _B, Callable[[], Union[None, _B]]] = None, example: Union[None, _B, Callable[[], Union[None, _B]]] = None, env: Union[str, List[str]] = None, help: str)[source]¶ Create a configuration option that contains a value of type cls.
Parameters: - cls – Option type (see
is_allowable_type()
) - required – A non-None value is required? (default: False if default is None, otherwise True)
- default – Default value if no value is supplied (default: None)
- example – Default value when generating example configuration (default: None)
- env – Environment variables to try if no value is supplied, before using default (default: [])
- help – Description of option, included when generating example configuration
- cls – Option type (see
-
csbot.config.
option_list
(cls: Type[_B], *, default: Union[None, List[_B], Callable[[], Union[None, List[_B]]]] = None, example: Union[None, List[_B], Callable[[], Union[None, List[_B]]]] = None, help: str)[source]¶ Create a configuration option that contains a list of cls values.
Parameters: - cls – Option type (see
is_allowable_type()
) - default – Default value if no value is supplied (default: empty list)
- example – Default value when generating example configuration (default: empty list)
- help – Description of option, included when generating example configuration
- cls – Option type (see
-
csbot.config.
option_map
(cls: Type[_B], *, default: Union[None, Dict[str, _B], Callable[[], Union[None, Dict[str, _B]]]] = None, example: Union[None, Dict[str, _B], Callable[[], Union[None, Dict[str, _B]]]] = None, help: str)[source]¶ Create a configuration option that contains a mapping of string keys to cls values.
Parameters: - cls – Option type (see
is_allowable_type()
) - default – Default value if no value is supplied (default: empty list)
- example – Default value when generating example configuration (default: empty list)
- help – Description of option, included when generating example configuration
- cls – Option type (see
-
csbot.config.
make_example
(cls: Type[csbot.config.Config]) → csbot.config.Config[source]¶ Create an instance of cls without supplying data, using “example” or “default” values for each option.