class INIConfigFile(SectionedConfigDict): (source)
Known subclasses: zim.config.manager.ConfigManagerINIConfigFile
Dict to represent a configuration file in "ini-style". Since the ini-file is divided in section this is represented as a dict of dicts. This class represents the top-level with a key for each section. The values are in turn ConfigDict
s which contain the key value pairs in that section.
A typical file might look like:
[Section1] param1=foo param2=bar [Section2] enabled=True data={'foo': 1, 'bar': 2}
(The values are parsed by the ConfigDefinition
for each key)
By default when parsing sections of the same name they will be merged and values that appear under the same section name later in the file will overwrite values that appeared earlier. As a special case we can support sections that repeat under the same section name. To do this assign the section name a list before parsing.
Sections and parameters whose name start with '_' are considered as private and are not stored when the config is written to file. This can be used for caching values that should not be persistent across instances.
Method | __init__ |
No summary |
Method | dump |
Serialize the config to a "ini-style" config file. @returns: a list of lines with text in "ini-style" formatting |
Method | on_file_changed |
Undocumented |
Method | parse |
No summary |
Method | read |
Read data from file |
Method | write |
Write data and set modified to False |
Instance Variable | file |
Undocumented |
Inherited from SectionedConfigDict
:
Method | __getitem__ |
Undocumented |
Method | __setitem__ |
Undocumented |
Inherited from ControlledDict
(via SectionedConfigDict
):
Method | __delitem__ |
Undocumented |
Method | changed |
Undocumented |
Method | do_changed |
Undocumented |
Method | on_child_changed |
Undocumented |
Method | set_modified |
Set the modified state. Used to reset modified to False after the configuration has been saved to file. @param modified: True or False |
Method | update |
Undocumented |
Class Variable | __signals__ |
Undocumented |
Property | modified |
True when the values were modified, used to e.g. track when a config needs to be written back to file |
Instance Variable | _modified |
Undocumented |
Inherited from SignalEmitter
(via SectionedConfigDict
, ControlledDict
):
Method | __new__ |
Undocumented |
Method | block_signals |
Returns a context manager for blocking one or more signals |
Method | connect |
Register a handler for a specific object. |
Method | connect_after |
Like connect() but handler will be called after default handler |
Method | disconnect |
Undocumented |
Method | emit |
Undocumented |
Method | emit_return_first |
Emits a signal and stops emission on the first handler that returns a not-None value. |
Method | emit_return_iter |
Returns an generator that calls one handler on each iteration and yields the return values. This allows aggregating return values. |
Method | _connect |
Undocumented |
Method | _setup_signal |
Undocumented |
Method | _teardown_signal |
Undocumented |
Inherited from ConnectorMixin
(via SectionedConfigDict
, ControlledDict
):
Method | connectto |
Connect to signals of another object E.g.: |
Method | connectto_all |
Convenience method to combine multiple calls to connectto() . |
Method | disconnect_all |
Disconnect all signals that have been connected with connectto and friends. Typically called when you want to destroy this object. |
Method | disconnect_from |
Disc all signals that have been connected with connectto and friends to a specific object. |
Method | _disconnect_from |
Undocumented |
Instance Variable | _connected_signals |
Undocumented |
zim.config.dicts.ControlledDict.__init__
zim.config.manager.ConfigManagerINIConfigFile
Parameters | |
file | a File or ConfigFile object for reading and writing the config. |
monitor | if True will listen to the changed signal of the file object and update the dict accordingly. Leave False for objects with a short life span. |
Returns | |
a list of lines with text in "ini-style" formatting |