Previous topic

ginsfsm.smachine

Next topic

ginsfsm.c_timer

ginsfsm.gconfig

This module implements a flexible global configuration system.

class ginsfsm.gconfig.GConfig(templates, logger=None)[source]

Global configuration system.

Parameters:template

a dictionary or a list of dictionary describing the template of configuration parameters, with key/value as:

'parameter_name':
[type, default_value, flag, validate_function, description]

Each parameter is defined with a template, that it’s a list of 4 elements:

  • type: must be a type of: str, int, bool, list, dict or tuple.
  • default_value: default value.
  • flag: modify behaviour.
  • validate_function: None or a callable. The callable must return True if validates the value, otherwise False. If the callable return False a GConfigValidateError will be raised.
  • description: String describing the parameter.

If the template is not valid, a GConfigTemplateError exception is raised.

reset_all_parameters()[source]

Reset all parameters to default values.

reset_parameter(parameter)[source]

Reset one parameter to his default value.

write_parameters(**kw)[source]

Write parameters.

Parameters:kw – keyword arguments with parameter_name:value pairs.

Warning

Only the parameters defined in the template are writted, the remaining are ignored.

write_few_parameters(parameter_list, **kw)[source]

Write a few parameters.

Parameters:
  • parameters – write only the parameters in parameter_list.
  • kw – keyword arguments with parameter_name:value pairs.

Warning

Only the parameters defined in the template are writted, the remaining are ignored.

read_parameters()[source]

Return a dictionary with the current parameter:value pairs.

read_parameter(parameter)[source]

Return the current value of parameter.

exception ginsfsm.gconfig.GConfigTemplateError[source]

Raised when something is wrong in the gconfig-template definition.

exception ginsfsm.gconfig.GConfigValidateError[source]

Raised when something is a parameter is not validated.