Module: etree

twomemo.etree.serialize_device_list(device_list)[source]
Parameters:

device_list (Dict[int, SignedLabel | None]) – The device list to serialize. The first entry of each tuple is the device id, and the second entry is the optional signed label.

Return type:

Element

Returns:

The serialized device list as an XML element.

twomemo.etree.parse_device_list(element)[source]
Parameters:

element (Element) – The XML element to parse the device list from.

Return type:

Dict[int, SignedLabel | None]

Returns:

The extracted device list. The first entry of each tuple is the device id, and the second entry is the optional signed label.

Raises:

xmlschema.XMLSchemaValidationError – in case the element does not conform to the XML schema given in the specification.

twomemo.etree.serialize_bundle(bundle)[source]
Parameters:

bundle (BundleImpl) – The bundle to serialize.

Return type:

Element

Returns:

The serialized bundle as an XML element.

twomemo.etree.parse_bundle(element, bare_jid, device_id)[source]
Parameters:
  • element (Element) – The XML element to parse the bundle from.

  • bare_jid (str) – The bare JID this bundle belongs to.

  • device_id (int) – The device id of the specific device this bundle belongs to.

Return type:

BundleImpl

Returns:

The extracted bundle.

Raises:

xmlschema.XMLSchemaValidationError – in case the element does not conform to the XML schema given in the specification.

twomemo.etree.serialize_message(message)[source]
Parameters:

message (Message) – The message to serialize.

Return type:

Element

Returns:

The serialized message as an XML element.

twomemo.etree.parse_message(element, bare_jid)[source]
Parameters:
  • element (Element) – The XML element to parse the message from.

  • bare_jid (str) – The bare JID of the sender.

Return type:

Message

Returns:

The extracted message.

Raises: