Cement configparser extension module.

class cement.ext.ext_configparser.ConfigParserConfigHandler(**kw)[source]

Bases: cement.core.config.ConfigHandler, configparser.RawConfigParser

This class is an implementation of the Config interface. It handles configuration file parsing and the like by sub-classing from the standard ConfigParser library. Please see the ConfigParser documentation for full usage of the class.

Additional arguments and keyword arguments are passed directly to RawConfigParser on initialization.

class Meta[source]

Bases: object

Handler meta-data.

label = 'configparser'

The string identifier of this handler.


Parse a configuration file at file_path and store it.

Parameters:file_path (str) – The file system path to the configuration file.
Returns:True if file was read properly, False otherwise
Return type:bool

Adds a block section to the config.

Parameters:section (str) – The section to add.
get(section, key)[source]

Return a configuration value based on section.key. Must honor environment variables if they exist to override the config… for example config['myapp']['foo']['bar'] must be overridable by the environment variable MYAPP_FOO_BAR…. Note that MYAPP_ must prefix all vars, therefore config['redis']['foo'] would be overridable by MYAPP_REDIS_FOO … but config['myapp']['foo']['bar'] would not have a double prefix of MYAPP_MYAPP_FOO_BAR.

  • section (str) – The section of the configuration to pull key values from.
  • key (str) – The configuration key to get the value for.

The value of the key in section.

Return type:



Return a dict of the entire configuration.

Returns:A dictionary of the entire config.
Return type:dict

Return a dict representation of a section.

Parameters:section – The section of the configuration.
Returns:Dictionary reprisentation of the config section.
Return type:dict

Return a list of configuration sections.

Returns:List of sections
Return type:list

Returns whether or not the section exists.

Parameters:section (str) – The section to test for.
True if the configuration section exists, False
Return type:bool

Return a list of keys within section.

Parameters:section (str) – The config section
Returns:List of keys in the section.
Return type:list
merge(dict_obj, override=True)[source]

Merge a dictionary into our config. If override is True then existing config values are overridden by those passed in.

Parameters:dict_obj (dict) – A dictionary of configuration keys/values to merge into our existing config (self).
Keyword Arguments:
 override (bool) – Whether or not to override existing values in the config.
set(section, key, value)[source]

Set a configuration value based at section.key.

  • section (str) – The section of the configuration to pull key value from.
  • key (str) – The configuration key to set the value at.
  • value – The value to set.