OscConfigParser

This is the osc config parser.

basic structures

class osc.OscConfigParser.ConfigLineOrder

A ConfigLineOrder() instance task is to preserve the order of a config file. It keeps track of all lines (including comments) in the _lines list. This list either contains SectionLine() instances or CommentLine() instances.

class osc.OscConfigParser.Line(name, type)

Base class for all line objects

class osc.OscConfigParser.SectionLine(sectname)

This class represents a [section]. It stores all lines which belongs to this certain section in the _lines list. The _lines list either contains CommentLine() or OptionLine() instances.

class osc.OscConfigParser.CommentLine(line)

Store a commentline

class osc.OscConfigParser.OptionLine(optname, line)

This class represents an option. The class’ name attribute is used to store the option’s name and the “value” attribute contains the option’s value. The frmt attribute preserves the format which was used in the configuration file.

Example:

optionx:<SPACE><SPACE>value
=> self.frmt = '%s:<SPACE><SPACE>%s'
optiony<SPACE>=<SPACE>value<SPACE>;<SPACE>some_comment
=> self.frmt = '%s<SPACE>=<SPACE><SPACE>%s<SPACE>;<SPACE>some_comment
class osc.OscConfigParser.OscConfigParser(defaults=None)

OscConfigParser() behaves like a normal ConfigParser() object. The only differences is that it preserves the order+format of configuration entries and that it stores comments. In order to keep the order and the format it makes use of the ConfigLineOrder() class.

write(fp, comments=False)

write the configuration file. If comments is True all comments etc. will be written to fp otherwise the ConfigParsers’ default write method will be called.

has_option(section, option, proper=False, **kwargs)

Returns True, if the passed section contains the specified option. If proper is True, True is only returned if the option is owned by this section and not “inherited” from the default.