util.persistence.serializeXML module

Inheritance diagram of XMLSerializationStrategy

class util.persistence.serializeXML.XMLSerializationStrategy

Bases: SerializationStrategy[Element]

The SerializationStrategy for the original, verbose XML format (see serializeXML2 for the compact one).

SerializableTypesInAttrs = (<class 'int'>, <class 'float'>, <class 'bool'>, <class 'str'>)
SerializableTypesInSubs = (<class 'util.persistence.serialize.Serializable'>, <class 'list'>, <class 'dict'>, <class 'tuple'>, <class 'set'>)
classmethod protocolName() → str
Returns:

Return type:

str

classmethod protocolVersion() → str
Returns:

Return type:

str

classmethod defaultExtension() → str
Returns:

Return type:

str

_encodeStr(obj: str) → Element
Parameters:

obj (str)

Returns:

Return type:

Element

_decodeStr(elem: Element) → str
Parameters:

elem (Element)

Returns:

Return type:

str

_encodeList() → Element
Returns:

Return type:

Element

_decodeList(elem: Element) → list[Element]
Parameters:

elem (Element)

Returns:

Return type:

list[Element]

_setAttr(elem: Element, name: str, value: str)
Parameters:
  • elem (Element)

  • name (str)

  • value (str)

_getAttr(elem: Element, name: str, default: Any = <class 'KeyError'>) → Any
Parameters:
  • elem (Element)

  • name (str)

  • default (Any)

Returns:

Return type:

Any

_appendItem(elem: Element, newItem: Element) → None
Parameters:
  • elem (Element)

  • newItem (Element)

_getItems(elem: Element) → list[Element]
Parameters:

elem (Element)

Returns:

Return type:

list[Element]

_setKVPair(elem: Element, key: Element | str, value: Element) → None
Parameters:
  • elem (Element)

  • key (Element | str)

  • value (Element)

_getKVPair(elem: Element, key: str) → Element | None
Parameters:
  • elem (Element)

  • key (str)

Returns:

Return type:

Optional[Element]

_getKVPairs(elem: Element) → list[tuple[Element, Element]] | dict[str, Element]
Parameters:

elem (Element)

Returns:

Return type:

list[tuple[Element, Element]] | dict[str, Element]

_tostring(elem: Element, kwargs: dict[str, Any]) → str

Return the data as a strategy-specific formatted string.

Parameters:
  • elem (Element) – The Element to serialise and returned.

  • kwargs (dict[str,Any]) –

    Supports:

    • ”indent”:str|int|NoneType for “pretty print” indentation: A str is prefixed for every level, or an int indents that many spaces per level, or None will be a compace format.

Returns:

The serialized object as a string.

Return type:

str

_fromstring(string: str, kwargs: dict[str, Any]) → Element

Return an object made from a strategy-specific formatted string.

Parameters:
  • string (str) – The string to interpret.

  • kwargs (dict[str, Any])

Returns:

The object interpreted from string.

Return type:

SerializableTypes

_abc_impl = <_abc._abc_data object>