Python Paste


Config

A configuration object. Acts a little like a dictionary, but not really.

Configuration can be nested with [section] markers, or can be flat (everything globally available). If in sections then section.key is used, otherwise just key.


Attributes

a false_values

['f', 'false', '0', 'n', 'no', 'off']

a true_values

['t', 'true', '1', 'y', 'yes', 'on']

Methods

f __init__(self, filename, file=None, allow_empty_sections=<class initools.configwrapper.NoDefault at 0xb74dd02c>) ...

f keys(self, section=<class initools.configwrapper.NoDefault at 0xb74dd02c>) ...

f sections(self) ...

f getraw(self, key, section=None) ...

Mostly for internal use, returns a list of all matching keys.

f clean_section(self, section_name) ...

f get(self, key, default=None, section=None) ...

Get a single value, returning default if none found.

f getlist(self, key, default=(), section=None) ...

Get a list of all matching keys. Example:

System Message: WARNING/2 (initools.configwrapper.Config.getlist, line 2)

Literal block expected; none found.

foo = bar
foo = baz

Then:

>>> config.getlist('foo')
['bar', 'baz']

f getbool(self, key, default=False, section=None) ...

Get a single boolean value. Boolean values are things like true, false, etc.

f getint(self, key, default=None, section=None) ...

Get an integer value.

f getinlinelist(self, key, default=(), section=None) ...

Get a list, where the list is defined like:

System Message: WARNING/2 (initools.configwrapper.Config.getinlinelist, line 2)

Literal block expected; none found.

foo = bar, baz

Gives:

>>> config.getinlinelist('foo')
['bar', 'baz']

f getstartswith(self, startswith, section) ...

Returns a list of [(key, value), ...] for all keys in the section that start with startswith.

See the source for more information.