AttributeDictionary

class caris.AttributeDictionary

A mutable dictionary of attributes

clear((AttributeDictionary)self) → None :

Remove all items from the container.

from_xml((AttributeDictionary)self, (str)xml) → None :

Updates attributes from an XML formatted string.

The format of the XML string must match the format of the string returned from AttributeDictionary.to_xml()

Parameters:xml (str) – The xml formatted string of attributes
get((AttributeDictionary)self, (str)key[, (object)default=None]) → object :

Return the value for key if key is in the container

Parameters:
  • key (str) – The key of the item to return
  • default (object) – If the key is not found this value will be returned
Returns:

A object object. None if they key is not found and default was not specified

items((AttributeDictionary)self) → list :

Return a new view of the container’s items

Returns:A new view of the container’s items (key, value) pairs
keys((AttributeDictionary)self) → list :

Return a new view of the container’s keys

Returns:A new view of the container’s keys
pop((AttributeDictionary)self, (str)key, (object)default) → object :

Remove an item

Args:
key (str): The key of the item to remove default (object, optional): If the key is not found this value will be returned
Returns:
A object object if the key is found
Raises:
A KeyError if the key is not found and a default value was not specified

pop( (AttributeDictionary)arg1, (str)arg2) -> object

popitem((AttributeDictionary)self) → tuple :

Remove and return an arbitrary (key, value) pair

Returns:An arbitrary (key, value) pair
Raises:A KeyError if the container is empty
setdefault((AttributeDictionary)self, (str)key[, (object)default=None]) → object :

If key is found, return its value. If not, insert key with a value of default and return default.

Parameters:
  • key (str) – The key
  • default (object) – If the key is not found this value will be inserted and returned
Returns:

A object object

to_xml((AttributeDictionary)self) → str :

Returns the AttributeDictionary as an XML formatted string.

Returns:The xml represenation of the AttributeDictionary
Return type:str
update((AttributeDictionary)self, (object)other) → None :

Update the container with the key/value pairs from other, overwriting existing keys.

Parameters:other (AttributeDictionary) – The other container to insert the key/value pairs from
validate((AttributeDictionary)self) → None :

Verify that the attribute values in the AttributeDictionary are valid.

values((AttributeDictionary)self) → list :

Return a new view of the container’s items

Returns:A new view of the container’s items (key, value) pairs