Package gavo :: Package utils :: Module fancyconfig :: Class MagicSection
[frames] | no frames]

Class MagicSection

source code

object --+    
         |    
   Section --+
             |
            MagicSection

A section that creates new keys on the fly.

Use this a dictionary-like thing when successive edits are necessary or the DictConfigItem becomes too unwieldy.

A MagicSection is constructed with the section name, an item factory, which has to be a subclass of ConfigItem (you may want to write a special constructor to provide documentation, etc.), and defaults as a sequence of pairs of keys and values. And there should be documentation, too, of course.

Instance Methods
 
__init__(self, name, documentation='Undocumented', itemFactory=<class 'gavo.utils.fancyconfig.StringConfigItem'>, defaults=[])
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
set(self, name, value, origin='user')
set the value of the configuration item name.
source code

Inherited from Section: __iter__, get, getitem, setParent

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, name, documentation='Undocumented', itemFactory=<class 'gavo.utils.fancyconfig.StringConfigItem'>, defaults=[])
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

set(self, name, value, origin='user')

source code 

set the value of the configuration item name.

value must always be a string, regardless of the item's actual type.

Overrides: Section.set
(inherited documentation)