Package svnmailer :: Package settings :: Module _fileparser :: Class FileParser
[show private | hide private]
[frames | no frames]

Class FileParser

object --+
         |
        FileParser


Simplified config file parser

The ConfigParser module does too much magic (partially not even documented). Further we don't need all the set and save stuff here, so we write our own - clean - variant. This variant just reads the stuff and does not apply any typing or transformation. It also uses a better design...


Method Summary
  __init__(self)
Initialization
bool __contains__(self, section)
Decides if section is a parsed section name
  __delitem__(self, name)
Removes the section specified by name
Section __getitem__(self, name)
Returns the section specified by name
iter __iter__(self)
Returns a section iterator
Option _createOption(self, name, value)
Returns a new Option instance
Section _createSection(self, name)
Returns a new Section instance
bool _isComment(self, line)
Decides if line is comment
tuple _parseOption(self, line)
Parses line as option (name [:=] value)
str _trySectionHeader(self, line)
Tries to extract a section header from line
  slurp(self, fp, filename)
Reads from fp until EOF and parses line by line
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name...
  __getattribute__(...)
x.__getattribute__('name') <==> x.name...
  __hash__(x)
x.__hash__() <==> hash(x)...
  __reduce__(...)
helper for pickle...
  __reduce_ex__(...)
helper for pickle...
  __repr__(x)
x.__repr__() <==> repr(x)...
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value...
  __str__(x)
x.__str__() <==> str(x)...
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T...

Instance Variable Summary
dict _sections: The parsed sections

Method Details

__init__(self)
(Constructor)

Initialization
Overrides:
__builtin__.object.__init__

__contains__(self, section)
(In operator)

Decides if section is a parsed section name
Parameters:
section - The section name to process
           (type=str)
Returns:
Is section available?
           (type=bool)

__delitem__(self, name)
(Index deletion operator)

Removes the section specified by name
Parameters:
name - The name of the section to remove (or None to specifiy the presection section)
           (type=str)
Raises:
KeyError - The option does not exist

__getitem__(self, name)
(Indexing operator)

Returns the section specified by name
Parameters:
name - The name of the section. May be None to specify the presection section
           (type=str)
Returns:
The specified section
           (type=Section)
Raises:
KeyError - The requested section does not exist

__iter__(self)

Returns a section iterator
Returns:
iterator object
           (type=iter)

_createOption(self, name, value)

Returns a new Option instance
Parameters:
name - The option name
           (type=str)
value - The option value
           (type=str)
Returns:
The new Option instance
           (type=Option)

_createSection(self, name=None)

Returns a new Section instance
Returns:
The new Section instance
           (type=Section)

_isComment(self, line)

Decides if line is comment
Parameters:
line - The line to inspect
           (type=str)
Returns:
Is line is comment line?
           (type=bool)

_parseOption(self, line)

Parses line as option (name [:=] value)
Parameters:
line - The line to process
           (type=str)
Returns:
The name and the value (both None if an error occured)
           (type=tuple)

_trySectionHeader(self, line)

Tries to extract a section header from line
Parameters:
line - The line to process
           (type=str)
Returns:
The section header name or None
           (type=str)

slurp(self, fp, filename)

Reads from fp until EOF and parses line by line
Parameters:
fp - The stream to read from
           (type=file)
filename - The filename used for error messages
           (type=basestring)
Raises:
ContinuationError - An invalid line continuation occured
OptionSyntaxError - An option line could not be parsed
IOError - An I/O error occured while reading the stream

Instance Variable Details

_sections

The parsed sections
Type:
dict

Generated by Epydoc 2.0 on Sun Sep 25 20:49:14 2005 http://epydoc.sf.net