Module inifile
source code
Functions to read/write a Windows-style INI file
format:
aa = "bb"
cc = 11
[eee]
ff = "gg"
decodes to:
d = { '': {'aa':'bb','cc':'11'}, 'eee': {'ff':'gg'} }
the encoder can also take this as input:
d = { 'aa': 'bb, 'cc': 11, 'eee': {'ff':'gg'} }
though it will only decode in the above format. Keywords must be
strings. Values that are strings are written surrounded by quotes, and
the decoding routine automatically strips any quotes from the values.
Booleans are written as integers. Anything other than strings, integers,
and floats may have unpredictable results.
boolean
|
|
|
|
errfunc(lineno,
line,
err)
Display an error message when reading the ini file fails. |
source code
|
|
dictionary
|
|
logging.Logger
|
logger = logging.getLogger('DebTorrent.inifile')
the logger to send all log messages to for this module
|
Imports:
cStringIO.StringIO,
types.DictType,
types.StringType,
logging,
types.BooleanType
Write the ini file.
- Parameters:
f (string) - the file name to write
d (dictionary) - the data to write to the ini file
comment (string) - a comment to write at the top of the file, hash marks will be
prefixed (optional, default is no comment)
- Returns:
boolean
- whether the write succeeded
|
Display an error message when reading the ini file fails.
- Parameters:
lineno (int) - the line number that caused the error
line (string) - the line that caused the error
err (string) - the error that was generated
|
Read the ini file.
- Parameters:
f (string) - the file name to read
- Returns:
dictionary
- the data read from the ini file
|