mopidy.config
--- Config API¶
-
mopidy.config.
read
(config_file)[source]¶ Helper to load config defaults in same way across core and extensions
Config section schemas¶
-
class
mopidy.config.schemas.
ConfigSchema
(name)[source]¶ Logical group of config values that correspond to a config section.
Schemas are set up by assigning config keys with config values to instances. Once setup
deserialize()
can be called with a dict of values to process. For convienience we also supportformat()
method that can used for converting the values to a dict that can be printed andserialize()
for converting the values to a form suitable for persistence.
-
class
mopidy.config.schemas.
MapConfigSchema
(name, value_type)[source]¶ Schema for handling multiple unknown keys with the same type.
Does not sub-class
ConfigSchema
, but implements the same serialize/deserialize interface.
Config value types¶
-
class
mopidy.config.types.
Boolean
(optional=False)[source]¶ Boolean value.
Accepts
1
,yes
,true
, andon
with any casing asTrue
.Accepts
0
,no
,false
, andoff
with any casing asFalse
.
-
class
mopidy.config.types.
ConfigValue
[source]¶ Represents a config key's value and how to handle it.
Normally you will only be interacting with sub-classes for config values that encode either deserialization behavior and/or validation.
Each config value should be used for the following actions:
- Deserializing from a raw string and validating, raising ValueError on failure.
- Serializing a value back to a string that can be stored in a config.
- Formatting a value to a printable form (useful for masking secrets).
None
values should not be deserialized, serialized or formatted, the code interacting with the config should simply skip None config values.
-
class
mopidy.config.types.
Deprecated
[source]¶ Deprecated value
Used for ignoring old config values that are no longer in use, but should not cause the config parser to crash.
-
class
mopidy.config.types.
Integer
(minimum=None, maximum=None, choices=None, optional=False)[source]¶ Integer value.
-
class
mopidy.config.types.
List
(optional=False)[source]¶ List value.
Supports elements split by commas or newlines. Newlines take presedence and empty list items will be filtered out.
-
class
mopidy.config.types.
LogLevel
[source]¶ Log level value.
Expects one of
critical
,error
,warning
,info
,debug
, orall
, with any casing.
-
class
mopidy.config.types.
Path
(optional=False)[source]¶ File system path
The following expansions of the path will be done:
~
to the current user's home directory$XDG_CACHE_DIR
according to the XDG spec$XDG_CONFIG_DIR
according to the XDG spec$XDG_DATA_DIR
according to the XDG spec$XDG_MUSIC_DIR
according to the XDG spec
-
class
mopidy.config.types.
Port
(choices=None, optional=False)[source]¶ Network port value.
Expects integer in the range 0-65535, zero tells the kernel to simply allocate a port for us.
Config value validators¶
-
mopidy.config.validators.
validate_choice
(value, choices)[source]¶ Validate that
value
is one of thechoices
Normally called in
deserialize()
.
-
mopidy.config.validators.
validate_maximum
(value, maximum)[source]¶ Validate that
value
is at mostmaximum
Normally called in
deserialize()
.
-
mopidy.config.validators.
validate_minimum
(value, minimum)[source]¶ Validate that
value
is at leastminimum
Normally called in
deserialize()
.
-
mopidy.config.validators.
validate_required
(value, required)[source]¶ Validate that
value
is set ifrequired
Normally called in
deserialize()
on the raw string, _not_ the converted value.