Home | Trees | Indices | Help |
|
---|
|
object --+ | dict --+ | Section --+ | ConfigObj
An object to read, create, and write config files.
|
|||
new empty dictionary |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from Inherited from Inherited from |
|
|||
_keyword = re.compile(r'
|
|||
_sectionmarker = re.compile(r'
|
|||
_valueexp = re.compile(r'
|
|||
_listvalueexp = re.compile(r'
|
|||
_nolistvalue = re.compile(r'
|
|||
_single_line_single = re.compile(r'^\'\'\'
|
|||
_single_line_double = re.compile(r'^"""
|
|||
_multi_line_single = re.compile(r'^
|
|||
_multi_line_double = re.compile(r'^
|
|||
_triple_quote =
|
|||
_bools =
|
|
|||
Inherited from |
|
Parse a config file or create a config file object. ``ConfigObj(infile=None, configspec=None, encoding=None, interpolation=True, raise_errors=False, list_values=True, create_empty=False, file_error=False, stringify=True, indent_type=None, default_encoding=None, unrepr=False, write_empty_values=False, _inspec=False)``
|
|
str(x)
|
Handle any BOM, and decode if necessary. If an encoding is specified, that *must* be used - but the BOM should still be removed (and the BOM attribute set). (If the encoding is wrongly specified, then a BOM for an alternative encoding won't be discovered or removed.) If an encoding is not specified, UTF8 or UTF16 BOM will be detected and removed. The BOM attribute will be set. UTF16 will be decoded to unicode. NOTE: This method must not be called with an empty ``infile``. Specifying the *wrong* encoding is likely to cause a ``UnicodeDecodeError``. ``infile`` must always be returned as a list of lines, but may be passed in as a single string. |
Decode infile to unicode. Using the specified encoding. if is a string, it also needs converting to a list. |
Given a section and a depth level, walk back through the sections parents to see if the depth level matches a previous section. Return a reference to the right section, or raise a SyntaxError. |
Handle an error according to the error settings. Either raise the error or store it. The error will have occured at ``cur_index`` |
Return a safely quoted version of a value. Raise a ConfigObjError if the value cannot be safely quoted. If multiline is ``True`` (default) then use triple quotes if necessary. * Don't quote values that don't need it. * Recursively quote members of a list and return a comma joined list. * Multiline is ``False`` for lists. * Obey list syntax for empty and single member lists. If ``list_values=False`` then the value is only quoted if it contains a ``\n`` (is multiline) or '#'. If ``write_empty_values`` is set, and the value is an empty string, it won't be quoted. |
Given a value string, unquote, remove comment, handle lists. (including empty and single member lists) |
Called by validate. Handles setting the configspec on subsections including sections to be validated by __many__ |
Write the current ConfigObj as a file tekNico: FIXME: use StringIO instead of real files >>> filename = a.filename >>> a.filename = 'test.ini' >>> a.write() >>> a.filename = filename >>> a == ConfigObj('test.ini', raise_errors=True) 1 >>> import os >>> os.remove('test.ini') |
Test the ConfigObj against a configspec. It uses the ``validator`` object from *validate.py*. To run ``validate`` on the current ConfigObj, call: : test = config.validate(validator) (Normally having previously passed in the configspec when the ConfigObj was created - you can dynamically assign a dictionary of checks to the ``configspec`` attribute of a section though). It returns ``True`` if everything passes, or a dictionary of pass/fails (True/False). If every member of a subsection passes, it will just have the value ``True``. (It also returns ``False`` if all members fail). In addition, it converts the values from strings to their native types if their checks pass (and ``stringify`` is set). If ``preserve_errors`` is ``True`` (``False`` is default) then instead of a marking a fail with a ``False``, it will preserve the actual exception object. This can contain info about the reason for failure. For example the ``VdtValueTooSmallError`` indicates that the value supplied was too small. If a value (or section) is missing it will still be marked as ``False``. You must have the validate module to use ``preserve_errors=True``. You can then use the ``flatten_errors`` function to turn your nested results dictionary into a flattened list of failures - useful for displaying meaningful error messages. |
Reload a ConfigObj from file. This method raises a ``ReloadError`` if the ConfigObj doesn't have a filename attribute pointing to a file. |
|
_keyword
|
_sectionmarker
|
_valueexp
|
_listvalueexp
|
_nolistvalue
|
_triple_quote
|
_bools
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Mar 5 19:49:24 2010 | http://epydoc.sourceforge.net |