Package skytools :: Module config :: Class Config
[frames] | no frames]

Class Config

source code

object --+
         |
        Config

Bit improved ConfigParser.

Additional features:

Instance Methods
 
__init__(self, main_section, filename, sane_config=1)
Initialize Config and read from file.
source code
 
reload(self)
Re-reads config file.
source code
 
get(self, key, default=None)
Reads string value, if not set then default.
source code
 
getint(self, key, default=None)
Reads int value, if not set then default.
source code
 
getboolean(self, key, default=None)
Reads boolean value, if not set then default.
source code
 
getfloat(self, key, default=None)
Reads float value, if not set then default.
source code
 
getlist(self, key, default=None)
Reads comma-separated list from key.
source code
 
getfile(self, key, default=None)
Reads filename from config.
source code
 
get_wildcard(self, key, values=[], default=None)
Reads a wildcard property from conf and returns its string value, if not set then default.
source code
 
sections(self)
Returns list of sections in config file, excluding DEFAULT.
source code
 
clone(self, main_section)
Return new Config() instance with new main section on same config file.
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, main_section, filename, sane_config=1)
(Constructor)

source code 
Initialize Config and read from file.
Parameters:
  • sane_config - chooses between ConfigParser/SafeConfigParser.
Overrides: object.__init__

getfile(self, key, default=None)

source code 

Reads filename from config.

In addition to reading string value, expands ~ to user directory.