Commit 4fdc2673 authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

Merge branch 'development' of https://gitlab.lrz.de/badw-it/DHParser into development

# Conflicts:
#	DHParser/ebnf.py
parents daf0ac66 faf6b810
......@@ -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))
if items:
return items if len(items) >= 2 else items[0]
raise IndexError('index out of range') if isinstance(key, int) \
else KeyError(str(key))
raise IndexError('index out of range') if isinstance(key, int) else KeyError(str(key))
def __delitem__(self, key: Union[int, slice, CriteriaType]):
"""
......
......@@ -75,8 +75,10 @@ __all__ = ('typing',
'ThreadLocalSingletonFactory',
'RX_NEVER_MATCH',
'RX_ENTITY',
'RX_NON_ASCII',
'validate_XML_attribute_value',
'fix_XML_attribute_value',
'fix_lxml_attribute_value',
'RxPatternType',
're_find',
'escape_re',
......@@ -574,7 +576,7 @@ def validate_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
XML-entities."""
value = str(value)
......@@ -593,6 +595,22 @@ def fix_XML_attribute_value(value: Any) -> str:
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
......
@literalws = right
definitions = ~ definition { definition } EOF
definition = definiendum ":=" definiens
definiendum = word
definiens = word { word }
word = /[A-Z]?[a-z]*/
EOF = /$/
......@@ -53,7 +53,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.5"
regex = { version = "^2.5", optional = true }
regex = { version = "*", optional = true }
cython = { version = "^0.29", optional = true }
......
Markdown is supported
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