anyconfig.backend.configobj

Configobj backend:

  • Format to support: configobj, http://goo.gl/JbP2Kp (readthedocs.org)
  • Requirements: configobj (https://pypi.python.org/pypi/configobj/)
  • Development Status :: 4 - Beta
  • Limitations: AFAIK, configobj does not keep the order of configuration items and not have options to change this behavior like configparser, so this backend does not keep the order of configuration items even if the ac_ordered option was used.
  • Special options:

Chnagelog:

    Changed in version 0.5.0:
  • Now loading and dumping options are detected automatically from inspection result if possible. Also these became not distinguished because these will be passed to configobj.Configuration anyway.

anyconfig.backend.configobj.make_configobj(cnf, **kwargs)

Make a configobj.ConfigObj initalized with given config cnf.

Parameters:
  • cnf – Configuration data
  • kwargs – optional keyword parameters passed to ConfigObj.__init__
Returns:

An initialized configobj.ConfigObj instance

anyconfig.backend.configobj.load(path_or_strm, container, **opts)
Parameters:
  • path_or_strm – input config file path or file/file-like object
  • container – callble to make a container object
  • opts – keyword options passed to configobj.ConfigObj
Returns:

Mapping object

class anyconfig.backend.configobj.Parser

Bases: anyconfig.backend.base.StreamParser, anyconfig.backend.base.BinaryFilesMixin

Parser for Ini-like config files which configobj supports.

_type = 'configobj'
_priority = 10
_load_opts = ['options', 'configspec', 'encoding', 'interpolation', 'raise_errorslist_values', 'create_empty', 'file_error', 'stringifyindent_type', 'default_encoding', 'unrepr', 'write_empty_values_inspec']
_dump_opts = ['options', 'configspec', 'encoding', 'interpolation', 'raise_errorslist_values', 'create_empty', 'file_error', 'stringifyindent_type', 'default_encoding', 'unrepr', 'write_empty_values_inspec']
_ordered = True
load_from_path(*args, **kwargs)
Parameters:
  • path_or_strm – input config file path or file/file-like object
  • container – callble to make a container object
  • opts – keyword options passed to configobj.ConfigObj
Returns:

Mapping object

load_from_stream(*args, **kwargs)
Parameters:
  • path_or_strm – input config file path or file/file-like object
  • container – callble to make a container object
  • opts – keyword options passed to configobj.ConfigObj
Returns:

Mapping object

dump_to_string(cnf, **kwargs)

Dump config cnf to a string.

Parameters:
  • cnf – Configuration data to dump
  • kwargs – backend-specific optional keyword parameters :: dict
Returns:

string represents the configuration

__module__ = 'anyconfig.backend.configobj'
dump_to_stream(cnf, stream, **kwargs)
Parameters:
  • cnf – Configuration data to dump
  • stream – Config file or file-like object
  • kwargs – backend-specific optional keyword parameters :: dict