Package gavo :: Package utils :: Module fancyconfig :: Class Configuration
[frames] | no frames]

Class Configuration

source code

object --+
         |
        Configuration
Known Subclasses:

A collection of config Sections and provides an interface to access them and their items.

You construct it with the Sections you want and then use the get method to access their content. You can either use get(section, name) or just get(name), which implies the defaultSection section defined at the top (right now, "general").

To read configuration items, use addFromFp. addFromFp should only raise subclasses of ConfigError.

You can also set individual items using set.

The class follows the default behaviour of configparser in that section and item names are lowercased.

Note that direct access to sections is not forbidden, but you have to keep case mangling of keys into account when doing so.

Instance Methods
 
__init__(self, *sections)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__iter__(self) source code
 
getitem(self, arg1, arg2=None)
returns the *item* described by section, name or just name.
source code
 
get(self, arg1, arg2=None, default=<class 'gavo.utils.fancyconfig._Undefined'>) source code
 
set(self, arg1, arg2, arg3=None, origin='user')
sets a configuration item to a value.
source code
 
addFromFp(self, fp, origin='user', fName='<internal>')
adds the config items in the file fp to self.
source code
 
getUserConfig(self)
returns a configparser containing the user set config items.
source code
 
saveUserConfig(self, destName)
writes the config items changed by the user to destName.
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, *sections)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

set(self, arg1, arg2, arg3=None, origin='user')

source code 

sets a configuration item to a value.

arg1 can be a section, in which case arg2 is a key and arg3 is a value; alternatively, if arg3 is not given, arg1 is a key in the defaultSection, and arg2 is the value.

All arguments are strings that must be parseable by the referenced item's _parse method.

Origin is a tag you can use to, e.g., determine what to save.