Previous topic

CFG_SECTION_node_rules

This Page

NepidemiXConfigParser

class nepidemix.utilities.nepidemixconfigparser.NepidemiXConfigParser

NepidemiX ini-file reader.

Written to have similar interface as Python 2.x RawConfigParser, but with some added improvements, and most importantly using collections.OrderedDict for the option, value pairs within a section. This will guarantee that options are presented by the Parser in the same order as they are listed in the file. There are also other improvements to the interface used by ConfigParser. Among them are the option of default values for the get-methods, as well as general data types, and parsing of special ranges et c.

The options and sections in the ini files are case sensitive.

Methods

add_section(section) Add a section, if it does not already exist.
evaluateSection(section) Interpretate option values in a section as expressions, evaluates them, and return a the results as a dictionary.
get(section, option[, default, ...]) Get a value from an option in a section.
getboolean(section, option[, default, ...]) Get a boolean value.
getfloat(section, option[, default, ...]) Get a float value.
getint(section, option[, default, ...]) Get an integer value.
getrange(section, option[, default, ...]) Create a range of values from option string.
has_option(section, option) Returns true if the parser has the option in the section.
has_section(section) Returns true if the parser has the section.
items(section) Return the list of (option,value) pair from a specific section.
options(section) Return all options in a section.
parseMapping(mapStr[, dtype]) Parse a mapping string on the form src->dest.
parseRange(rstring[, dtype]) Create a range of values from a string.
parseTuple(lstring[, dtype]) Create a tuple from a comma separated string.
read(fileName) Read a file.
readfp(fp) Read a file.
sections() Return all section names.
set(section, option, value[, createSection]) Sets the option in section to value.
write(fileobject) Write file to file object.
__init__()

Init method.

Methods

__init__() Init method.
add_section(section) Add a section, if it does not already exist.
evaluateSection(section) Interpretate option values in a section as expressions, evaluates them, and return a the results as a dictionary.
get(section, option[, default, ...]) Get a value from an option in a section.
getboolean(section, option[, default, ...]) Get a boolean value.
getfloat(section, option[, default, ...]) Get a float value.
getint(section, option[, default, ...]) Get an integer value.
getrange(section, option[, default, ...]) Create a range of values from option string.
has_option(section, option) Returns true if the parser has the option in the section.
has_section(section) Returns true if the parser has the section.
items(section) Return the list of (option,value) pair from a specific section.
options(section) Return all options in a section.
parseMapping(mapStr[, dtype]) Parse a mapping string on the form src->dest.
parseRange(rstring[, dtype]) Create a range of values from a string.
parseTuple(lstring[, dtype]) Create a tuple from a comma separated string.
read(fileName) Read a file.
readfp(fp) Read a file.
sections() Return all section names.
set(section, option, value[, createSection]) Sets the option in section to value.
write(fileobject) Write file to file object.