Package mrv :: Module conf :: Class DictToINIFile
[hide private]
[frames] | no frames]

Class DictToINIFile

source code

StringIO.StringIO --+
                    |
                   DictToINIFile
Known Subclasses:

Wraps a dictionary into an objects returning an INI file when read

This class can be used to make configuration information as supplied by os.environ natively available to the configuration system


Notes:
Instance Methods [hide private]
 
__init__(self, option_dict, section='DEFAULT', description='')
Initialize the file-like object
source code

Inherited from StringIO.StringIO: __iter__, close, flush, getvalue, isatty, next, read, readline, readlines, seek, tell, truncate, write, writelines

Class Methods [hide private]
 
_checkstr(cls, string)
Returns: unaltered string if there was not issue
source code
Method Details [hide private]

_checkstr(cls, string)
Class Method

source code 
Returns:
unaltered string if there was not issue
Raises:
  • ValueError - if string contains newline

__init__(self, option_dict, section='DEFAULT', description='')
(Constructor)

source code 
Initialize the file-like object
Parameters:
  • option_dict - dictionary with simple key-value pairs - the keys and values must translate to meaningful strings ! Empty dicts are allowed
  • section - the parent section of the key-value pairs
  • description - will be used as comment directly below the section, it must be a single line only
Raises:
  • ValueError - newlines are are generally not allowed and will cause a parsing error later on
Overrides: StringIO.StringIO.__init__