Configuration plugin

Configuration management plugins provide a way to store an application configuration. Openpaperwork_core provides the plugin openpaperwork_core.config that acts a frontend for backend plugins (openpaperowkr_core.config.backend.*). It provides some high level operations (like registering options and their default value). Other plugins and applications should use this frontend only.

When initialized, plugins are expected to register any setting they need. Only the plugin responsible for a setting register it ; Plugins depending on settings registered by one of their dependency do not need to register them.

Backends provide access to the configuration storage (Python’s ConfigParser, Windows registry, Android Content Provider, etc). Reference implementation for backends is openpaperwork_core.config.backend.configparser (based on Python’s ConfigParser).


Frontend plugin

Paperwork configuration management code

class openpaperwork_core.config.Plugin[source]

Translate values from the configuration into more usable ones. Provides default values (except for plugins).

config_add_observer(key: str, callback)[source]
config_add_plugin(plugin, plugin_list_name=None)[source]
config_build_simple(section, token, default_value_func)[source]

Provide a default simple implementation for a new setting that can be registered using ‘config_register’.

Arguments:
  • section: Section in which option must be stored (see ConfigParser)

  • token: token name for the option (see ConfigParser)

  • default_value_func: function to call to get the default value if none is stored in the file.

config_get(key: str)[source]
config_get_default(key: str)[source]
config_get_plugin_list_name()[source]
config_get_setting(key: str)[source]
config_list_options()[source]
config_list_plugins(plugin_list_name=None)[source]
config_load()[source]
config_load_plugins(plugin_list_name, default_plugins=[])[source]
config_put(key: str, value)[source]

Store a setting value. Warning: You must call config_save() so the changes are actually saved.

Arguments:
  • key: configuration key,

  • value: can be of many types (str, int, etc).

config_register(key: str, setting)[source]

Add another setting to manage. Make this setting available to other components.

Arguments:
  • key: configuration key

  • setting: Setting must be an object providing a method get() and a method put(value). See config_build_simple() to get quickly a default implementation.

config_remove_observer(key: str, callback)[source]
config_remove_plugin(plugin, plugin_list_name=None)[source]
config_reset_plugins(plugin_list_name=None)[source]
config_save()[source]
get_deps()[source]
get_interfaces()[source]
init(core)[source]
class openpaperwork_core.config.Setting(core, section, token, default_value_func)[source]
get()[source]
put(value)[source]

Backend plugin: File

Manages a configuration file using configparser.

class openpaperwork_core.config.backend.configparser.ConfigBool(value=False)[source]
get_value()[source]
class openpaperwork_core.config.backend.configparser.ConfigDate(value=datetime.datetime(1971, 1, 1, 0, 0))[source]
DATE_FORMAT = '%Y-%m-%d'
get_value()[source]
class openpaperwork_core.config.backend.configparser.ConfigDict(value=None, elements={})[source]
SEPARATOR_ITEMS = ';'
SEPARATOR_KEYVALS = '='
get_value()[source]
class openpaperwork_core.config.backend.configparser.ConfigList(value=None, elements=None)[source]
SEPARATOR = ';'
append(value)[source]
get_value()[source]
remove(value)[source]
class openpaperwork_core.config.backend.configparser.Plugin[source]
TEST_FILE_URL = None
bug_report_get_attachments(out: dict)[source]
config_backend_add_observer(section, callback)[source]
config_backend_add_plugin(opt_name, module_name)[source]
config_backend_del(section, key)[source]
config_backend_get(section, key, default=None)[source]
config_backend_list_active_plugins(opt_name)[source]
config_backend_load(application_name)[source]
config_backend_load_plugins(opt_name, default=[])[source]

Load and init the plugin list from the configuration.

config_backend_put(section, key, value)[source]

Section must be a string. Key must be a string.

config_backend_remove_observer(section, callback)[source]
config_backend_remove_plugin(opt_name, module_name)[source]
config_backend_reset_plugins(opt_name)[source]
config_backend_save(application_name=None)[source]
get_deps()[source]
get_interfaces()[source]
init(core)[source]