43
43
logging.warn("A name used in condition %r is unknown! You have to define it. I only know of %s", expression_string, local_variables.keys())
45
45
return condition_result
48
from xml.etree import ElementTree as ET
49
from collections import OrderedDict
51
ET.Element =ET._Element_Py
54
def __init__(self, *args, **kwargs):
55
super().__init__(*args, **kwargs)
59
print("Ignoring request to sort.")
62
class _OrderedDictWithItemsNoSort(OrderedDict):
63
def __init__(self, *args, **kwargs):
64
super().__init__(*args, **kwargs)
67
return _L(super().items())
69
class OrderedXMLParser(ET.XMLParser):
70
def __init__(self, *args, **kwargs):
71
super().__init__(*args, **kwargs)
73
def _start(self, tag, attr_list):
74
# Handler for expat's StartElementHandler. Since ordered_attributes
75
# is set, the attributes are reported as a list of alternating
76
# attribute name,value.
77
fixname = self._fixname
79
attrib = _OrderedDictWithItemsNoSort()
81
for i in range(0, len(attr_list), 2):
82
attrib[fixname(attr_list[i])] = attr_list[i+1]
83
return self.target.start(tag, attrib)