Package gavo :: Package base :: Module config :: Class ProfileParser
[frames] | no frames]

Class ProfileParser

source code

object --+
         |
        ProfileParser

is a parser for DB profiles.

The profiles are specified in simple text files that have a shell-like syntax. Each line either contains an assignment (x=y) or is of the form command arg*. Recognized commands include:

>>> p = ProfileParser()
>>> p.parse(None, "x", "host=foo.bar\n").host
'foo.bar'
>>> p.parse(None, "x", "") is not None
True
>>> p.parse(None, "x", "host=\n").host
''
>>> p.parse(None, "x", "=bla\n")
Traceback (most recent call last):
ProfileParseError: "x", line 1: invalid identifier '='
>>> p.parse(None, "x", "host=bla")
Traceback (most recent call last):
ProfileParseError: "x", line 1: unexpected end of file (missing line feed?)
Instance Methods
 
__init__(self, sourcePath=['.'])
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
parse(self, profileName, sourceName, stream=None) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  profileKeys = set(['database', 'host', 'password', 'port', 'ss...
Properties

Inherited from object: __class__

Method Details

__init__(self, sourcePath=['.'])
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

Class Variable Details

profileKeys

Value:
set(['database', 'host', 'password', 'port', 'sslmode', 'user'])