b3j0f.conf.configurable package¶
Subpackages¶
Submodules¶
Module contents¶
-
class
b3j0f.conf.configurable.
Configurable
(unified_category=None, to_configure=None, conf_paths=None, drivers='b3j0f.conf.driver.file._json.JSONConfDriver, b3j0f.conf.driver.file._ini.INIConfDriver', auto_conf=True, reconf_once=False, log_lvl='INFO', log_name=None, log_path='.', log_info_format='[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s', log_debug_format='[%(asctime)s] [%(levelname)s] [%(name)s] [%(process)d] [%(thread)d] [%(pathname)s] [%(lineno)d] %(message)s', log_warning_format='[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s', log_error_format='[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s', log_critical_format='[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s')[source]¶ Bases:
object
Manages class conf synchronisation with conf resources.
-
AUTO_CONF
= 'auto_conf'¶
-
CONF
= 'CONFIGURATION'¶
-
CONF_PATH
= 'configuration/configurable.conf'¶
-
CONF_PATHS
= 'conf_paths'¶
-
CRITICAL_FORMAT
= '[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s'¶
-
DEBUG_FORMAT
= '[%(asctime)s] [%(levelname)s] [%(name)s] [%(process)d] [%(thread)d] [%(pathname)s] [%(lineno)d] %(message)s'¶
-
DEFAULT_DRIVERS
= 'b3j0f.conf.driver.file._json.JSONConfDriver,b3j0f.conf.driver.file._ini.INIConfDriver'¶
-
DRIVERS
= 'drivers'¶
-
ERROR_FORMAT
= '[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s'¶
-
INFO_FORMAT
= '[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s'¶
-
INIT_CAT
= 'init_cat'¶
-
LOG
= 'LOG'¶
-
LOG_CRITICAL_FORMAT
= 'log_critical_format'¶
-
LOG_DEBUG_FORMAT
= 'log_debug_format'¶
-
LOG_ERROR_FORMAT
= 'log_error_format'¶
-
LOG_INFO_FORMAT
= 'log_info_format'¶
-
LOG_LVL
= 'log_lvl'¶
-
LOG_NAME
= 'log_name'¶
-
LOG_PATH
= 'log_path'¶
-
LOG_WARNING_FORMAT
= 'log_warning_format'¶
-
RECONF_ONCE
= 'reconf_once'¶
-
WARNING_FORMAT
= '[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s'¶
-
apply_configuration
(conf=None, conf_paths=None, drivers=None, logger=None, override=True, to_configure=None)[source]¶ Apply conf on a destination in 5 phases:
identify the right driver to use with conf_paths to parse.
- for all conf_paths, get conf which match
with input conf.
apply parsing rules on conf_path params.
put values and parsing errors in two different dictionaries.
returns both dictionaries of param values and errors.
Parameters: - conf (Configuration) – conf from where get conf
- conf_paths (list of str) – conf files to parse. If conf_paths is a str, it is automatically putted into a list
- override (bool) – if True (by default), override self configuration
- to_configure – object to configure. self by default.
-
auto_conf
¶
-
conf
¶ Get conf with parsers and self property values
-
configure
(conf, logger=None, to_configure=None)[source]¶ Update self properties with input params only if: - self.configure is True - self.auto_conf is True - param conf ‘configure’ is True - param conf ‘auto_conf’ is True
This method may not be overriden. see _configure instead
Parameters: - conf (Configuration) – object from where get paramters
- to_configure – object to configure. self if equals None.
-
drivers
¶
-
get_conf
(conf=None, conf_paths=None, drivers=None, logger=None, override=True)[source]¶ Get a dictionary of params by name from conf, conf_paths and drivers
Parameters: - conf (Configuration) – conf to update. If None, use self.conf
- conf_paths (list of str) – list of conf files. If None, use self.conf_paths
- logger (Logger) – logger to use for logging info/error messages. If None, use self.logger
- drivers (list) – ConfDriver to use. If None, use self drivers.
- override (bool) – if True (by default), override self configuration
- to_configure – object to configure. self by default.
-
log_critical_format
¶
-
log_debug_format
¶
-
log_error_format
¶
-
log_info_format
¶
-
log_name
¶
-
log_path
¶
-
log_warning_format
¶
-
logger
¶
-
reconf_once
¶
-
-
class
b3j0f.conf.configurable.
ConfigurableRegistry
(configurables=None, configurable_types=None, *args, **kwargs)[source]¶ Bases:
b3j0f.conf.configurable.core.Configurable
Manage a set of configurables which are accessibles from self configurables.
Each configurable can be defined in conf parameters where names are like {name}_configurable={configurable_path, configurable_class, configurable}.
And a configurable configuration are in categories {NAME}_CONF.
Then all sub-configurables are accessibles from item accessors with name as item key.
-
CATEGORY
= 'MANAGER'¶
-
CONFIGURABLE_SUFFIX
= '_value'¶
-
CONFIGURABLE_TYPE_SUFFIX
= '_type'¶
-
CONF_PATH
= 'configuration/registry.conf'¶
-
exception
Error
[source]¶ Bases:
exceptions.Exception
handle ConfigurableRegistry errors
-
ConfigurableRegistry.
apply_configuration
(conf=None, conf_paths=None, drivers=None, logger=None, override=True, *args, **kwargs)[source]¶
-
ConfigurableRegistry.
configurable_types
¶ ConfigurableTypes which manages restriction of sub-configurable types.
-
ConfigurableRegistry.
configurables
¶ Configurable which manages sub-configurables.
-
static
ConfigurableRegistry.
get_configurable
(configurable, *args, **kwargs)[source]¶ Get a configurable instance from a configurable class/path/instance and args, kwargs, None otherwise.
Parameters: configurable (str, class or Configurable) – configurable path, class or instance. Returns: configurable instance or None if input configurable can not be solved such as a configurable.
-