plugin XEP-0384: Implementation of Automatic Trust Management:
- Implementation of Trust Messages (XEP-0434) - Implementation of Automatic Trust Management (XEP-0450) - Implementations directly as part of the OMEMO plugin, since omemo:2 is the only protocol supported by ATM at the moment - Trust system selection updated to allow choice between manual trust with ATM and BTBV - dev-requirements.txt updated to include additional requirements for the e2e tests fix 376
This commit is contained in:
parent
289855c9d1
commit
e062c2f0e5
1 changed files with 818 additions and 161 deletions
|
|
@ -20,7 +20,7 @@
|
|||
from collections import OrderedDict
|
||||
import html.entities
|
||||
import re
|
||||
from typing import Optional, Tuple, Union, Literal, overload
|
||||
from typing import Dict, Optional, Tuple, Union, Literal, overload
|
||||
from xml.dom import NotFoundErr, minidom
|
||||
import xml.etree.ElementTree as ET
|
||||
from lxml import etree
|
||||
|
|
@ -2030,3 +2030,37 @@ def domish_elt_2_et_elt(elt, lxml = False):
|
|||
for child in elt.elements():
|
||||
et_elt.append(domish_elt_2_et_elt(child, lxml=lxml))
|
||||
return et_elt
|
||||
|
||||
|
||||
def domish_elt_2_et_elt2(element: domish.Element) -> ET.Element:
|
||||
"""
|
||||
WIP, originally from the OMEMO plugin
|
||||
"""
|
||||
|
||||
element_name = element.name
|
||||
if element.uri is not None:
|
||||
element_name = "{" + element.uri + "}" + element_name
|
||||
|
||||
attrib: Dict[str, str] = {}
|
||||
for qname, value in element.attributes.items():
|
||||
attribute_name = qname[1] if isinstance(qname, tuple) else qname
|
||||
attribute_namespace = qname[0] if isinstance(qname, tuple) else None
|
||||
if attribute_namespace is not None:
|
||||
attribute_name = "{" + attribute_namespace + "}" + attribute_name
|
||||
|
||||
attrib[attribute_name] = value
|
||||
|
||||
result = ET.Element(element_name, attrib)
|
||||
|
||||
last_child: Optional[ET.Element] = None
|
||||
for child in element.children:
|
||||
if isinstance(child, str):
|
||||
if last_child is None:
|
||||
result.text = child
|
||||
else:
|
||||
last_child.tail = child
|
||||
else:
|
||||
last_child = domish_elt_2_et_elt2(child)
|
||||
result.append(last_child)
|
||||
|
||||
return result
|
||||
|
|
|
|||
Loading…
Reference in a new issue