Commit faf6b810 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

Korrekturen

parent 19d0fa48
...@@ -1379,8 +1379,7 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil ...@@ -1379,8 +1379,7 @@ class Node: # (collections.abc.Sized): Base class omitted for cython-compatibil
items = tuple(child for child in self._children if mf(child)) items = tuple(child for child in self._children if mf(child))
if items: if items:
return items if len(items) >= 2 else items[0] return items if len(items) >= 2 else items[0]
raise IndexError('index out of range') if isinstance(key, int) \ raise IndexError('index out of range') if isinstance(key, int) else KeyError(str(key))
else KeyError(str(key))
def __delitem__(self, key: Union[int, slice, CriteriaType]): def __delitem__(self, key: Union[int, slice, CriteriaType]):
""" """
......
...@@ -75,8 +75,10 @@ __all__ = ('typing', ...@@ -75,8 +75,10 @@ __all__ = ('typing',
'ThreadLocalSingletonFactory', 'ThreadLocalSingletonFactory',
'RX_NEVER_MATCH', 'RX_NEVER_MATCH',
'RX_ENTITY', 'RX_ENTITY',
'RX_NON_ASCII',
'validate_XML_attribute_value', 'validate_XML_attribute_value',
'fix_XML_attribute_value', 'fix_XML_attribute_value',
'fix_lxml_attribute_value',
'RxPatternType', 'RxPatternType',
're_find', 're_find',
'escape_re', 'escape_re',
...@@ -574,7 +576,7 @@ def validate_XML_attribute_value(value: Any) -> str: ...@@ -574,7 +576,7 @@ def validate_XML_attribute_value(value: Any) -> str:
def fix_XML_attribute_value(value: Any) -> str: def fix_XML_attribute_value(value: Any) -> str:
"""Returns the quotes XML-attribute value. In case the values """Returns the quoted XML-attribute value. In case the values
contains illegal characters, like '<', these will be replaced by contains illegal characters, like '<', these will be replaced by
XML-entities.""" XML-entities."""
value = str(value) value = str(value)
...@@ -593,6 +595,22 @@ def fix_XML_attribute_value(value: Any) -> str: ...@@ -593,6 +595,22 @@ def fix_XML_attribute_value(value: Any) -> str:
return value return value
RX_NON_ASCII = re.compile(r'[^\U00000000-\U00000100]')
def lxml_XML_attribute_value(value: Any) -> str:
"""Makes sure that the attribute value works with the lxml-library,
at the cost of replacing all characters with a code > 256 by
a quesiton mark.
:param value: the original attribute value
:return: the quoted and lxml-compatible attribute value.
"""
value = str(value)
value = RX_NON_ASCII.sub('?', value)
return fix_XML_attribute_value(value)
####################################################################### #######################################################################
# #
# type system support # type system support
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment