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

Class DictConfigItem

source code

  object --+            
           |            
  ConfigItem --+        
               |        
StringConfigItem --+    
                   |    
      ListConfigItem --+
                       |
                      DictConfigItem

A config item that contains a concise representation of a string-string mapping.

The literal format is {<key>:<value>,}, where whitespace is ignored between tokens and the last comma may be ommitted.

No commas and colons are allowed within keys and values. To lift this, I'd probably go for backslash escaping.

>>> ci = DictConfigItem("foo"); ci.value
{}
>>> ci.set("ab:cd, foo:Fu\xc3\x9f"); ci.value
{u'ab': u'cd', u'foo': u'Fu\xdf'}
>>> ci.getAsString();ci.set(ci.getAsString()); ci.value
'ab:cd, foo:Fu\xc3\x9f, '
{u'ab': u'cd', u'foo': u'Fu\xdf'}
>>> ci.set("ab:cd, rubbish")
Traceback (most recent call last):
ParseError: 'rubbish' is not a valid mapping literal element
Instance Methods

Inherited from ConfigItem: __init__, getAsString, set

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

Class Variables
  typedesc = 'mapping'
  default = ""
hash(x)
Properties

Inherited from object: __class__