X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/8550d172b829f29b2fcd4723789fb2a5d9fff6eb..e67fee0ec88f99401f5add011bf801ec10181e37:/src/librarian/parser.py diff --git a/src/librarian/parser.py b/src/librarian/parser.py index 2bb9509..3ae081b 100644 --- a/src/librarian/parser.py +++ b/src/librarian/parser.py @@ -19,7 +19,27 @@ import re import six +from .elements import WL_ELEMENTS + + +class WLElementLookup(etree.CustomElementClassLookup): + def lookup(self, node_type, document, namespace, name): + if node_type != 'element': + return + if namespace: + return + return WL_ELEMENTS[name] + + +parser = etree.XMLParser() +parser.set_element_class_lookup( + WLElementLookup() +) + + + class WLDocument(object): + """Legacy class, to be replaced with documents.WLDocument.""" LINE_SWAP_EXPR = re.compile(r'/\s', re.MULTILINE | re.UNICODE) provider = None