Package wtf :: Module config
[hide private]
[frames] | no frames]

Module config

source code

This modules handles configuration loading and provides an easy API for accessing it.


Author: André Malo

Classes [hide private]
  ConfigurationError
Configuration error
  ConfigurationIOError
Config file IO error
  ParseError
Parse error
  ContinuationError
A line continuation without a previous option line occured
  OptionSyntaxError
A option line could not be parsed
  RecursiveIncludeError
Recursive Include Detected
  OptionTypeError
An option type could not be recognized
  Parser
Simplified config file parser
  TypedIterOption
Option, typed dynamically
  Config
Config access class
  Section
Config section container
Functions [hide private]
Section
merge_sections(*sections)
Merge sections together
source code
int
human_bool(value)
Interpret human readable boolean value
source code
 
dump(config, stream=None)
Dump config object
source code
Config
load(name, charset='latin-1')
Load configuration
source code
Variables [hide private]
  __package__ = 'wtf'
Function Details [hide private]

merge_sections(*sections)

source code 
Merge sections together
Parameters:
  • sections (tuple) - The sections to merge, later sections take more priority
Returns: Section
The merged section
Raises:
  • TypeError - Either one of the section was not a section or the sections contained unmergable attributes (subsections vs. plain values)

human_bool(value)

source code 

Interpret human readable boolean value

True
yes, true, on, any number other than 0
False
no, false, off, 0, empty, none

The return value is not a boolean on purpose. It's a number, so you can pass more than just boolean values (by passing a number)

Parameters:
  • value (str) - The value to interpret
Returns: int
number

dump(config, stream=None)

source code 
Dump config object
Parameters:
  • stream (file) - The stream to dump to. If omitted or None, it's dumped to sys.stdout.

load(name, charset='latin-1')

source code 

Load configuration

It is not a failure if the file does not exist.

Parameters:
  • name (basestring) - The name of the file
  • charset (str) - Default charset of config files
Returns: Config
A config object