Package mrv :: Module conf :: Class Key
[hide private]
[frames] | no frames]

Class Key

source code

         object --+    
                  |    
_PropertyHolderBase --+
                      |
                     Key

Key with an associated values and an optional set of propterties
Notes:

To Do: add support for escpaing comas within quotes - currently it split at comas, no matter what

Instance Methods [hide private]
 
__init__(self, name, value, order)
Basic Field Initialization
source code
 
__hash__(self)
hash(x)
source code
 
__eq__(self, other) source code
 
__repr__(self)
Returns: ini string representation
source code
 
__str__(self)
Returns: key name
source code
 
_excPrependNameAndRaise(self) source code
 
_setName(self, name)
Set the name :raise ValueError: incorrect name
source code
 
_getName(self) source code
 
_setValue(self, value) source code
 
_getValue(self) source code
 
_getValueSingle(self) source code
 
_addRemoveValue(self, value, mode)
Append or remove value to/from our value according to mode
source code

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

    Utilities
 
appendValue(self, value)
Append the given value or list of values to the list of current values
source code
 
removeValue(self, value)
remove the given value or list of values from the list of current values
source code
 
valueString(self)
Convert our value to a string suitable for the INI format
source code
 
mergeWith(self, otherkey)
Merge self with otherkey according to our properties
source code
Class Methods [hide private]
 
_parseObject(cls, valuestr)
Returns: int,float or str from valuestring
source code
Class Variables [hide private]
  validchars = '[\\w\\(\\)]'
  _re_checkName = re.compile(r'[\w\(\)]+')
  _re_checkValue = re.compile(r'[^\n\t\r]+')
Properties [hide private]
  _name
  _values

Inherited from _PropertyHolderBase: order, properties

Inherited from object: __class__

    Properties
  name
Access the name of the key
  values
read: values of the key as list write: write single values or llist of values
  value
read: first value if the key's values write: same effect as write of 'values'
Method Details [hide private]

__init__(self, name, value, order)
(Constructor)

source code 
Basic Field Initialization
Parameters:
  • order - -1 = will be written to end of list, or to given position otherwise
Overrides: object.__init__

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: object.__hash__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Returns:
ini string representation
Overrides: object.__repr__

__str__(self)
(Informal representation operator)

source code 

str(x)

Returns:
key name
Overrides: object.__str__

_parseObject(cls, valuestr)
Class Method

source code 
Returns:
int,float or str from valuestring

_setValue(self, value)

source code 
Raises:
  • TypeError
  • ValueError

Note: internally, we always store a list

_addRemoveValue(self, value, mode)

source code 
Append or remove value to/from our value according to mode
Parameters:
  • mode - 0 = remove, 1 = add

appendValue(self, value)

source code 
Append the given value or list of values to the list of current values
Parameters:
  • value - list, tuple or scalar value

To Do: this implementation could be faster (costing more code)

removeValue(self, value)

source code 
remove the given value or list of values from the list of current values
Parameters:
  • value - list, tuple or scalar value

To Do: this implementation could be faster (costing more code)

mergeWith(self, otherkey)

source code 
Merge self with otherkey according to our properties

Note: self will be altered


Property Details [hide private]

name

Access the name of the key
Get Method:
_getName(self)
Set Method:
_setName(self, name) - Set the name :raise ValueError: incorrect name

values

read: values of the key as list write: write single values or llist of values
Get Method:
_getValue(self)
Set Method:
_setValue(self, value)

value

read: first value if the key's values write: same effect as write of 'values'
Get Method:
_getValueSingle(self)
Set Method:
_setValue(self, value)