diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/ElementInclude.py b/llmeval-env/lib/python3.10/site-packages/lxml/ElementInclude.py
new file mode 100644
index 0000000000000000000000000000000000000000..21884336f534cd2013165934111146684c9909cf
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/ElementInclude.py
@@ -0,0 +1,244 @@
+#
+# ElementTree
+# $Id: ElementInclude.py 1862 2004-06-18 07:31:02Z Fredrik $
+#
+# limited xinclude support for element trees
+#
+# history:
+# 2003-08-15 fl created
+# 2003-11-14 fl fixed default loader
+#
+# Copyright (c) 2003-2004 by Fredrik Lundh. All rights reserved.
+#
+# fredrik@pythonware.com
+# http://www.pythonware.com
+#
+# --------------------------------------------------------------------
+# The ElementTree toolkit is
+#
+# Copyright (c) 1999-2004 by Fredrik Lundh
+#
+# By obtaining, using, and/or copying this software and/or its
+# associated documentation, you agree that you have read, understood,
+# and will comply with the following terms and conditions:
+#
+# Permission to use, copy, modify, and distribute this software and
+# its associated documentation for any purpose and without fee is
+# hereby granted, provided that the above copyright notice appears in
+# all copies, and that both that copyright notice and this permission
+# notice appear in supporting documentation, and that the name of
+# Secret Labs AB or the author not be used in advertising or publicity
+# pertaining to distribution of the software without specific, written
+# prior permission.
+#
+# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
+# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
+# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
+# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+# --------------------------------------------------------------------
+
+"""
+Limited XInclude support for the ElementTree package.
+
+While lxml.etree has full support for XInclude (see
+`etree.ElementTree.xinclude()`), this module provides a simpler, pure
+Python, ElementTree compatible implementation that supports a simple
+form of custom URL resolvers.
+"""
+
+from lxml import etree
+try:
+ from urlparse import urljoin
+ from urllib2 import urlopen
+except ImportError:
+ # Python 3
+ from urllib.parse import urljoin
+ from urllib.request import urlopen
+
+XINCLUDE = "{http://www.w3.org/2001/XInclude}"
+
+XINCLUDE_INCLUDE = XINCLUDE + "include"
+XINCLUDE_FALLBACK = XINCLUDE + "fallback"
+XINCLUDE_ITER_TAG = XINCLUDE + "*"
+
+# For security reasons, the inclusion depth is limited to this read-only value by default.
+DEFAULT_MAX_INCLUSION_DEPTH = 6
+
+
+##
+# Fatal include error.
+
+class FatalIncludeError(etree.LxmlSyntaxError):
+ pass
+
+
+class LimitedRecursiveIncludeError(FatalIncludeError):
+ pass
+
+
+##
+# ET compatible default loader.
+# This loader reads an included resource from disk.
+#
+# @param href Resource reference.
+# @param parse Parse mode. Either "xml" or "text".
+# @param encoding Optional text encoding.
+# @return The expanded resource. If the parse mode is "xml", this
+# is an ElementTree instance. If the parse mode is "text", this
+# is a Unicode string. If the loader fails, it can return None
+# or raise an IOError exception.
+# @throws IOError If the loader fails to load the resource.
+
+def default_loader(href, parse, encoding=None):
+ file = open(href, 'rb')
+ if parse == "xml":
+ data = etree.parse(file).getroot()
+ else:
+ data = file.read()
+ if not encoding:
+ encoding = 'utf-8'
+ data = data.decode(encoding)
+ file.close()
+ return data
+
+
+##
+# Default loader used by lxml.etree - handles custom resolvers properly
+#
+
+def _lxml_default_loader(href, parse, encoding=None, parser=None):
+ if parse == "xml":
+ data = etree.parse(href, parser).getroot()
+ else:
+ if "://" in href:
+ f = urlopen(href)
+ else:
+ f = open(href, 'rb')
+ data = f.read()
+ f.close()
+ if not encoding:
+ encoding = 'utf-8'
+ data = data.decode(encoding)
+ return data
+
+
+##
+# Wrapper for ET compatibility - drops the parser
+
+def _wrap_et_loader(loader):
+ def load(href, parse, encoding=None, parser=None):
+ return loader(href, parse, encoding)
+ return load
+
+
+##
+# Expand XInclude directives.
+#
+# @param elem Root element.
+# @param loader Optional resource loader. If omitted, it defaults
+# to {@link default_loader}. If given, it should be a callable
+# that implements the same interface as default_loader.
+# @param base_url The base URL of the original file, to resolve
+# relative include file references.
+# @param max_depth The maximum number of recursive inclusions.
+# Limited to reduce the risk of malicious content explosion.
+# Pass None to disable the limitation.
+# @throws LimitedRecursiveIncludeError If the {@link max_depth} was exceeded.
+# @throws FatalIncludeError If the function fails to include a given
+# resource, or if the tree contains malformed XInclude elements.
+# @throws IOError If the function fails to load a given resource.
+# @returns the node or its replacement if it was an XInclude node
+
+def include(elem, loader=None, base_url=None,
+ max_depth=DEFAULT_MAX_INCLUSION_DEPTH):
+ if max_depth is None:
+ max_depth = -1
+ elif max_depth < 0:
+ raise ValueError("expected non-negative depth or None for 'max_depth', got %r" % max_depth)
+
+ if base_url is None:
+ if hasattr(elem, 'getroot'):
+ tree = elem
+ elem = elem.getroot()
+ else:
+ tree = elem.getroottree()
+ if hasattr(tree, 'docinfo'):
+ base_url = tree.docinfo.URL
+ elif hasattr(elem, 'getroot'):
+ elem = elem.getroot()
+ _include(elem, loader, base_url, max_depth)
+
+
+def _include(elem, loader=None, base_url=None,
+ max_depth=DEFAULT_MAX_INCLUSION_DEPTH, _parent_hrefs=None):
+ if loader is not None:
+ load_include = _wrap_et_loader(loader)
+ else:
+ load_include = _lxml_default_loader
+
+ if _parent_hrefs is None:
+ _parent_hrefs = set()
+
+ parser = elem.getroottree().parser
+
+ include_elements = list(
+ elem.iter(XINCLUDE_ITER_TAG))
+
+ for e in include_elements:
+ if e.tag == XINCLUDE_INCLUDE:
+ # process xinclude directive
+ href = urljoin(base_url, e.get("href"))
+ parse = e.get("parse", "xml")
+ parent = e.getparent()
+ if parse == "xml":
+ if href in _parent_hrefs:
+ raise FatalIncludeError(
+ "recursive include of %r detected" % href
+ )
+ if max_depth == 0:
+ raise LimitedRecursiveIncludeError(
+ "maximum xinclude depth reached when including file %s" % href)
+ node = load_include(href, parse, parser=parser)
+ if node is None:
+ raise FatalIncludeError(
+ "cannot load %r as %r" % (href, parse)
+ )
+ node = _include(node, loader, href, max_depth - 1, {href} | _parent_hrefs)
+ if e.tail:
+ node.tail = (node.tail or "") + e.tail
+ if parent is None:
+ return node # replaced the root node!
+ parent.replace(e, node)
+ elif parse == "text":
+ text = load_include(href, parse, encoding=e.get("encoding"))
+ if text is None:
+ raise FatalIncludeError(
+ "cannot load %r as %r" % (href, parse)
+ )
+ predecessor = e.getprevious()
+ if predecessor is not None:
+ predecessor.tail = (predecessor.tail or "") + text
+ elif parent is None:
+ return text # replaced the root node!
+ else:
+ parent.text = (parent.text or "") + text + (e.tail or "")
+ parent.remove(e)
+ else:
+ raise FatalIncludeError(
+ "unknown parse type in xi:include tag (%r)" % parse
+ )
+ elif e.tag == XINCLUDE_FALLBACK:
+ parent = e.getparent()
+ if parent is not None and parent.tag != XINCLUDE_INCLUDE:
+ raise FatalIncludeError(
+ "xi:fallback tag must be child of xi:include (%r)" % e.tag
+ )
+ else:
+ raise FatalIncludeError(
+ "Invalid element found in XInclude namespace (%r)" % e.tag
+ )
+ return elem
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__init__.py b/llmeval-env/lib/python3.10/site-packages/lxml/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..65a92c2faef38686ee59bfd6f6a08bdae73eece0
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/__init__.py
@@ -0,0 +1,22 @@
+# this is a package
+
+__version__ = "5.2.1"
+
+
+def get_include():
+ """
+ Returns a list of header include paths (for lxml itself, libxml2
+ and libxslt) needed to compile C code against lxml if it was built
+ with statically linked libraries.
+ """
+ import os
+ lxml_path = __path__[0]
+ include_path = os.path.join(lxml_path, 'includes')
+ includes = [include_path, lxml_path]
+
+ for name in os.listdir(include_path):
+ path = os.path.join(include_path, name)
+ if os.path.isdir(path):
+ includes.append(path)
+
+ return includes
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/ElementInclude.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/ElementInclude.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..5810ccaef436f8ce9e25e01e238c1e5a7952f663
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/ElementInclude.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/__init__.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/__init__.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..5cb01beb9d4504d4ef7aa958dcaf04a95175cb84
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/__init__.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/_elementpath.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/_elementpath.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..b846e25d952c7d96a3b97e76678690a99f27b93e
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/_elementpath.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/builder.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/builder.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..a5139766a2e41989c9c57cc53a5c3aa84b8a12af
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/builder.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/cssselect.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/cssselect.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..c35ba1cdd949c62ec8135888e773c1709e7861c9
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/cssselect.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/doctestcompare.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/doctestcompare.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..4b845760f99fa4a24aa156a130752d4a5d5f5719
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/doctestcompare.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/pyclasslookup.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/pyclasslookup.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..b0f91aa4d77a720f8c02fce78144a8380de68bd0
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/pyclasslookup.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/sax.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/sax.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..8688056ece4a86c229d7c07c6d5d1c8e074e3767
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/sax.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/usedoctest.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/usedoctest.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..9f0c5ffe1cf0daf608f4b2fc61aec57cbf38e5de
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/__pycache__/usedoctest.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/builder.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/lxml/builder.cpython-310-x86_64-linux-gnu.so
new file mode 100644
index 0000000000000000000000000000000000000000..e6a43a3fa8f2b6b43e51c8d51e1af9668d13018f
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/builder.cpython-310-x86_64-linux-gnu.so differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/builder.py b/llmeval-env/lib/python3.10/site-packages/lxml/builder.py
new file mode 100644
index 0000000000000000000000000000000000000000..cff67b0bc006f7f7c184d74f76913c3e2c1a557b
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/builder.py
@@ -0,0 +1,232 @@
+# cython: language_level=2
+
+#
+# Element generator factory by Fredrik Lundh.
+#
+# Source:
+# http://online.effbot.org/2006_11_01_archive.htm#et-builder
+# http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py
+#
+# --------------------------------------------------------------------
+# The ElementTree toolkit is
+#
+# Copyright (c) 1999-2004 by Fredrik Lundh
+#
+# By obtaining, using, and/or copying this software and/or its
+# associated documentation, you agree that you have read, understood,
+# and will comply with the following terms and conditions:
+#
+# Permission to use, copy, modify, and distribute this software and
+# its associated documentation for any purpose and without fee is
+# hereby granted, provided that the above copyright notice appears in
+# all copies, and that both that copyright notice and this permission
+# notice appear in supporting documentation, and that the name of
+# Secret Labs AB or the author not be used in advertising or publicity
+# pertaining to distribution of the software without specific, written
+# prior permission.
+#
+# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
+# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
+# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
+# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+# --------------------------------------------------------------------
+
+"""
+The ``E`` Element factory for generating XML documents.
+"""
+
+
+import lxml.etree as ET
+_QName = ET.QName
+
+from functools import partial
+
+try:
+ basestring
+except NameError:
+ basestring = str
+
+try:
+ unicode
+except NameError:
+ unicode = str
+
+
+class ElementMaker:
+ """Element generator factory.
+
+ Unlike the ordinary Element factory, the E factory allows you to pass in
+ more than just a tag and some optional attributes; you can also pass in
+ text and other elements. The text is added as either text or tail
+ attributes, and elements are inserted at the right spot. Some small
+ examples::
+
+ >>> from lxml import etree as ET
+ >>> from lxml.builder import E
+
+ >>> ET.tostring(E("tag"))
+ ''
+ >>> ET.tostring(E("tag", "text"))
+ 'text'
+ >>> ET.tostring(E("tag", "text", key="value"))
+ 'text'
+ >>> ET.tostring(E("tag", E("subtag", "text"), "tail"))
+ 'texttail'
+
+ For simple tags, the factory also allows you to write ``E.tag(...)`` instead
+ of ``E('tag', ...)``::
+
+ >>> ET.tostring(E.tag())
+ ''
+ >>> ET.tostring(E.tag("text"))
+ 'text'
+ >>> ET.tostring(E.tag(E.subtag("text"), "tail"))
+ 'texttail'
+
+ Here's a somewhat larger example; this shows how to generate HTML
+ documents, using a mix of prepared factory functions for inline elements,
+ nested ``E.tag`` calls, and embedded XHTML fragments::
+
+ # some common inline elements
+ A = E.a
+ I = E.i
+ B = E.b
+
+ def CLASS(v):
+ # helper function, 'class' is a reserved word
+ return {'class': v}
+
+ page = (
+ E.html(
+ E.head(
+ E.title("This is a sample document")
+ ),
+ E.body(
+ E.h1("Hello!", CLASS("title")),
+ E.p("This is a paragraph with ", B("bold"), " text in it!"),
+ E.p("This is another paragraph, with a ",
+ A("link", href="http://www.python.org"), "."),
+ E.p("Here are some reserved characters: ."),
+ ET.XML("
And finally, here is an embedded XHTML fragment.
"),
+ )
+ )
+ )
+
+ print ET.tostring(page)
+
+ Here's a prettyprinted version of the output from the above script::
+
+
+
+ This is a sample document
+
+
+
+
+
+
+ For namespace support, you can pass a namespace map (``nsmap``)
+ and/or a specific target ``namespace`` to the ElementMaker class::
+
+ >>> E = ElementMaker(namespace="http://my.ns/")
+ >>> print(ET.tostring( E.test ))
+
+
+ >>> E = ElementMaker(namespace="http://my.ns/", nsmap={'p':'http://my.ns/'})
+ >>> print(ET.tostring( E.test ))
+
+ """
+
+ def __init__(self, typemap=None,
+ namespace=None, nsmap=None, makeelement=None):
+ self._namespace = '{' + namespace + '}' if namespace is not None else None
+ self._nsmap = dict(nsmap) if nsmap else None
+
+ assert makeelement is None or callable(makeelement)
+ self._makeelement = makeelement if makeelement is not None else ET.Element
+
+ # initialize the default type map functions for this element factory
+ typemap = dict(typemap) if typemap else {}
+
+ def add_text(elem, item):
+ try:
+ last_child = elem[-1]
+ except IndexError:
+ elem.text = (elem.text or "") + item
+ else:
+ last_child.tail = (last_child.tail or "") + item
+
+ def add_cdata(elem, cdata):
+ if elem.text:
+ raise ValueError("Can't add a CDATA section. Element already has some text: %r" % elem.text)
+ elem.text = cdata
+
+ if str not in typemap:
+ typemap[str] = add_text
+ if unicode not in typemap:
+ typemap[unicode] = add_text
+ if ET.CDATA not in typemap:
+ typemap[ET.CDATA] = add_cdata
+
+ def add_dict(elem, item):
+ attrib = elem.attrib
+ for k, v in item.items():
+ if isinstance(v, basestring):
+ attrib[k] = v
+ else:
+ attrib[k] = typemap[type(v)](None, v)
+
+ if dict not in typemap:
+ typemap[dict] = add_dict
+
+ self._typemap = typemap
+
+ def __call__(self, tag, *children, **attrib):
+ typemap = self._typemap
+
+ # We'll usually get a 'str', and the compiled type check is very fast.
+ if not isinstance(tag, str) and isinstance(tag, _QName):
+ # A QName is explicitly qualified, do not look at self._namespace.
+ tag = tag.text
+ elif self._namespace is not None and tag[0] != '{':
+ tag = self._namespace + tag
+ elem = self._makeelement(tag, nsmap=self._nsmap)
+ if attrib:
+ typemap[dict](elem, attrib)
+
+ for item in children:
+ if callable(item):
+ item = item()
+ t = typemap.get(type(item))
+ if t is None:
+ if ET.iselement(item):
+ elem.append(item)
+ continue
+ for basetype in type(item).__mro__:
+ # See if the typemap knows of any of this type's bases.
+ t = typemap.get(basetype)
+ if t is not None:
+ break
+ else:
+ raise TypeError("bad argument type: %s(%r)" %
+ (type(item).__name__, item))
+ v = t(elem, item)
+ if v:
+ typemap.get(type(v))(elem, v)
+
+ return elem
+
+ def __getattr__(self, tag):
+ return partial(self, tag)
+
+
+# create factory object
+E = ElementMaker()
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/cleanup.pxi b/llmeval-env/lib/python3.10/site-packages/lxml/cleanup.pxi
new file mode 100644
index 0000000000000000000000000000000000000000..8e266b33f0f3aef34f3448276abfb2cb8b1e4772
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/cleanup.pxi
@@ -0,0 +1,215 @@
+# functions for tree cleanup and removing elements from subtrees
+
+def cleanup_namespaces(tree_or_element, top_nsmap=None, keep_ns_prefixes=None):
+ """cleanup_namespaces(tree_or_element, top_nsmap=None, keep_ns_prefixes=None)
+
+ Remove all namespace declarations from a subtree that are not used
+ by any of the elements or attributes in that tree.
+
+ If a 'top_nsmap' is provided, it must be a mapping from prefixes
+ to namespace URIs. These namespaces will be declared on the top
+ element of the subtree before running the cleanup, which allows
+ moving namespace declarations to the top of the tree.
+
+ If a 'keep_ns_prefixes' is provided, it must be a list of prefixes.
+ These prefixes will not be removed as part of the cleanup.
+ """
+ element = _rootNodeOrRaise(tree_or_element)
+ c_element = element._c_node
+
+ if top_nsmap:
+ doc = element._doc
+ # declare namespaces from nsmap, then apply them to the subtree
+ _setNodeNamespaces(c_element, doc, None, top_nsmap)
+ moveNodeToDocument(doc, c_element.doc, c_element)
+
+ keep_ns_prefixes = (
+ set([_utf8(prefix) for prefix in keep_ns_prefixes])
+ if keep_ns_prefixes else None)
+
+ _removeUnusedNamespaceDeclarations(c_element, keep_ns_prefixes)
+
+
+def strip_attributes(tree_or_element, *attribute_names):
+ """strip_attributes(tree_or_element, *attribute_names)
+
+ Delete all attributes with the provided attribute names from an
+ Element (or ElementTree) and its descendants.
+
+ Attribute names can contain wildcards as in `_Element.iter`.
+
+ Example usage::
+
+ strip_attributes(root_element,
+ 'simpleattr',
+ '{http://some/ns}attrname',
+ '{http://other/ns}*')
+ """
+ cdef _MultiTagMatcher matcher
+ element = _rootNodeOrRaise(tree_or_element)
+ if not attribute_names:
+ return
+
+ matcher = _MultiTagMatcher.__new__(_MultiTagMatcher, attribute_names)
+ matcher.cacheTags(element._doc)
+ if matcher.rejectsAllAttributes():
+ return
+ _strip_attributes(element._c_node, matcher)
+
+
+cdef _strip_attributes(xmlNode* c_node, _MultiTagMatcher matcher):
+ cdef xmlAttr* c_attr
+ cdef xmlAttr* c_next_attr
+ tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_node, c_node, 1)
+ if c_node.type == tree.XML_ELEMENT_NODE:
+ c_attr = c_node.properties
+ while c_attr is not NULL:
+ c_next_attr = c_attr.next
+ if matcher.matchesAttribute(c_attr):
+ tree.xmlRemoveProp(c_attr)
+ c_attr = c_next_attr
+ tree.END_FOR_EACH_ELEMENT_FROM(c_node)
+
+
+def strip_elements(tree_or_element, *tag_names, bint with_tail=True):
+ """strip_elements(tree_or_element, *tag_names, with_tail=True)
+
+ Delete all elements with the provided tag names from a tree or
+ subtree. This will remove the elements and their entire subtree,
+ including all their attributes, text content and descendants. It
+ will also remove the tail text of the element unless you
+ explicitly set the ``with_tail`` keyword argument option to False.
+
+ Tag names can contain wildcards as in `_Element.iter`.
+
+ Note that this will not delete the element (or ElementTree root
+ element) that you passed even if it matches. It will only treat
+ its descendants. If you want to include the root element, check
+ its tag name directly before even calling this function.
+
+ Example usage::
+
+ strip_elements(some_element,
+ 'simpletagname', # non-namespaced tag
+ '{http://some/ns}tagname', # namespaced tag
+ '{http://some/other/ns}*' # any tag from a namespace
+ lxml.etree.Comment # comments
+ )
+ """
+ cdef _MultiTagMatcher matcher
+ doc = _documentOrRaise(tree_or_element)
+ element = _rootNodeOrRaise(tree_or_element)
+ if not tag_names:
+ return
+
+ matcher = _MultiTagMatcher.__new__(_MultiTagMatcher, tag_names)
+ matcher.cacheTags(doc)
+ if matcher.rejectsAll():
+ return
+
+ if isinstance(tree_or_element, _ElementTree):
+ # include PIs and comments next to the root node
+ if matcher.matchesType(tree.XML_COMMENT_NODE):
+ _removeSiblings(element._c_node, tree.XML_COMMENT_NODE, with_tail)
+ if matcher.matchesType(tree.XML_PI_NODE):
+ _removeSiblings(element._c_node, tree.XML_PI_NODE, with_tail)
+ _strip_elements(doc, element._c_node, matcher, with_tail)
+
+cdef _strip_elements(_Document doc, xmlNode* c_node, _MultiTagMatcher matcher,
+ bint with_tail):
+ cdef xmlNode* c_child
+ cdef xmlNode* c_next
+
+ tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_node, c_node, 1)
+ if c_node.type == tree.XML_ELEMENT_NODE:
+ # we run through the children here to prevent any problems
+ # with the tree iteration which would occur if we unlinked the
+ # c_node itself
+ c_child = _findChildForwards(c_node, 0)
+ while c_child is not NULL:
+ c_next = _nextElement(c_child)
+ if matcher.matches(c_child):
+ if c_child.type == tree.XML_ELEMENT_NODE:
+ if not with_tail:
+ tree.xmlUnlinkNode(c_child)
+ _removeNode(doc, c_child)
+ else:
+ if with_tail:
+ _removeText(c_child.next)
+ tree.xmlUnlinkNode(c_child)
+ attemptDeallocation(c_child)
+ c_child = c_next
+ tree.END_FOR_EACH_ELEMENT_FROM(c_node)
+
+
+def strip_tags(tree_or_element, *tag_names):
+ """strip_tags(tree_or_element, *tag_names)
+
+ Delete all elements with the provided tag names from a tree or
+ subtree. This will remove the elements and their attributes, but
+ *not* their text/tail content or descendants. Instead, it will
+ merge the text content and children of the element into its
+ parent.
+
+ Tag names can contain wildcards as in `_Element.iter`.
+
+ Note that this will not delete the element (or ElementTree root
+ element) that you passed even if it matches. It will only treat
+ its descendants.
+
+ Example usage::
+
+ strip_tags(some_element,
+ 'simpletagname', # non-namespaced tag
+ '{http://some/ns}tagname', # namespaced tag
+ '{http://some/other/ns}*' # any tag from a namespace
+ Comment # comments (including their text!)
+ )
+ """
+ cdef _MultiTagMatcher matcher
+ doc = _documentOrRaise(tree_or_element)
+ element = _rootNodeOrRaise(tree_or_element)
+ if not tag_names:
+ return
+
+ matcher = _MultiTagMatcher.__new__(_MultiTagMatcher, tag_names)
+ matcher.cacheTags(doc)
+ if matcher.rejectsAll():
+ return
+
+ if isinstance(tree_or_element, _ElementTree):
+ # include PIs and comments next to the root node
+ if matcher.matchesType(tree.XML_COMMENT_NODE):
+ _removeSiblings(element._c_node, tree.XML_COMMENT_NODE, 0)
+ if matcher.matchesType(tree.XML_PI_NODE):
+ _removeSiblings(element._c_node, tree.XML_PI_NODE, 0)
+ _strip_tags(doc, element._c_node, matcher)
+
+cdef _strip_tags(_Document doc, xmlNode* c_node, _MultiTagMatcher matcher):
+ cdef xmlNode* c_child
+ cdef xmlNode* c_next
+
+ tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_node, c_node, 1)
+ if c_node.type == tree.XML_ELEMENT_NODE:
+ # we run through the children here to prevent any problems
+ # with the tree iteration which would occur if we unlinked the
+ # c_node itself
+ c_child = _findChildForwards(c_node, 0)
+ while c_child is not NULL:
+ if not matcher.matches(c_child):
+ c_child = _nextElement(c_child)
+ continue
+ if c_child.type == tree.XML_ELEMENT_NODE:
+ c_next = _findChildForwards(c_child, 0) or _nextElement(c_child)
+ _replaceNodeByChildren(doc, c_child)
+ if not attemptDeallocation(c_child):
+ if c_child.nsDef is not NULL:
+ # make namespaces absolute
+ moveNodeToDocument(doc, doc._c_doc, c_child)
+ c_child = c_next
+ else:
+ c_next = _nextElement(c_child)
+ tree.xmlUnlinkNode(c_child)
+ attemptDeallocation(c_child)
+ c_child = c_next
+ tree.END_FOR_EACH_ELEMENT_FROM(c_node)
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/debug.pxi b/llmeval-env/lib/python3.10/site-packages/lxml/debug.pxi
new file mode 100644
index 0000000000000000000000000000000000000000..e5bb061958f29a875e7df043f3b2aec9f550233f
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/debug.pxi
@@ -0,0 +1,90 @@
+@cython.final
+@cython.internal
+cdef class _MemDebug:
+ """Debugging support for the memory allocation in libxml2.
+ """
+ def bytes_used(self):
+ """bytes_used(self)
+
+ Returns the total amount of memory (in bytes) currently used by libxml2.
+ Note that libxml2 constrains this value to a C int, which limits
+ the accuracy on 64 bit systems.
+ """
+ return tree.xmlMemUsed()
+
+ def blocks_used(self):
+ """blocks_used(self)
+
+ Returns the total number of memory blocks currently allocated by libxml2.
+ Note that libxml2 constrains this value to a C int, which limits
+ the accuracy on 64 bit systems.
+ """
+ return tree.xmlMemBlocks()
+
+ def dict_size(self):
+ """dict_size(self)
+
+ Returns the current size of the global name dictionary used by libxml2
+ for the current thread. Each thread has its own dictionary.
+ """
+ c_dict = __GLOBAL_PARSER_CONTEXT._getThreadDict(NULL)
+ if c_dict is NULL:
+ raise MemoryError()
+ return tree.xmlDictSize(c_dict)
+
+ def dump(self, output_file=None, byte_count=None):
+ """dump(self, output_file=None, byte_count=None)
+
+ Dumps the current memory blocks allocated by libxml2 to a file.
+
+ The optional parameter 'output_file' specifies the file path. It defaults
+ to the file ".memorylist" in the current directory.
+
+ The optional parameter 'byte_count' limits the number of bytes in the dump.
+ Note that this parameter is ignored when lxml is compiled against a libxml2
+ version before 2.7.0.
+ """
+ cdef Py_ssize_t c_count
+ if output_file is None:
+ output_file = b'.memorylist'
+ elif isinstance(output_file, unicode):
+ output_file.encode(sys.getfilesystemencoding())
+
+ f = stdio.fopen(output_file, "w")
+ if f is NULL:
+ raise IOError(f"Failed to create file {output_file.decode(sys.getfilesystemencoding())}")
+ try:
+ if byte_count is None:
+ tree.xmlMemDisplay(f)
+ else:
+ c_count = byte_count
+ tree.xmlMemDisplayLast(f, c_count)
+ finally:
+ stdio.fclose(f)
+
+ def show(self, output_file=None, block_count=None):
+ """show(self, output_file=None, block_count=None)
+
+ Dumps the current memory blocks allocated by libxml2 to a file.
+ The output file format is suitable for line diffing.
+
+ The optional parameter 'output_file' specifies the file path. It defaults
+ to the file ".memorydump" in the current directory.
+
+ The optional parameter 'block_count' limits the number of blocks
+ in the dump.
+ """
+ if output_file is None:
+ output_file = b'.memorydump'
+ elif isinstance(output_file, unicode):
+ output_file.encode(sys.getfilesystemencoding())
+
+ f = stdio.fopen(output_file, "w")
+ if f is NULL:
+ raise IOError(f"Failed to create file {output_file.decode(sys.getfilesystemencoding())}")
+ try:
+ tree.xmlMemShow(f, block_count if block_count is not None else tree.xmlMemBlocks())
+ finally:
+ stdio.fclose(f)
+
+memory_debugger = _MemDebug()
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/docloader.pxi b/llmeval-env/lib/python3.10/site-packages/lxml/docloader.pxi
new file mode 100644
index 0000000000000000000000000000000000000000..7b38f43838592445d2618440b178bd9c8557073c
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/docloader.pxi
@@ -0,0 +1,178 @@
+# Custom resolver API
+
+ctypedef enum _InputDocumentDataType:
+ PARSER_DATA_INVALID
+ PARSER_DATA_EMPTY
+ PARSER_DATA_STRING
+ PARSER_DATA_FILENAME
+ PARSER_DATA_FILE
+
+@cython.final
+@cython.internal
+cdef class _InputDocument:
+ cdef _InputDocumentDataType _type
+ cdef bytes _data_bytes
+ cdef object _filename
+ cdef object _file
+ cdef bint _close_file
+
+ def __cinit__(self):
+ self._type = PARSER_DATA_INVALID
+
+
+cdef class Resolver:
+ "This is the base class of all resolvers."
+ def resolve(self, system_url, public_id, context):
+ """resolve(self, system_url, public_id, context)
+
+ Override this method to resolve an external source by
+ ``system_url`` and ``public_id``. The third argument is an
+ opaque context object.
+
+ Return the result of one of the ``resolve_*()`` methods.
+ """
+ return None
+
+ def resolve_empty(self, context):
+ """resolve_empty(self, context)
+
+ Return an empty input document.
+
+ Pass context as parameter.
+ """
+ cdef _InputDocument doc_ref
+ doc_ref = _InputDocument()
+ doc_ref._type = PARSER_DATA_EMPTY
+ return doc_ref
+
+ def resolve_string(self, string, context, *, base_url=None):
+ """resolve_string(self, string, context, base_url=None)
+
+ Return a parsable string as input document.
+
+ Pass data string and context as parameters. You can pass the
+ source URL or filename through the ``base_url`` keyword
+ argument.
+ """
+ cdef _InputDocument doc_ref
+ if isinstance(string, unicode):
+ string = (string).encode('utf8')
+ elif not isinstance(string, bytes):
+ raise TypeError, "argument must be a byte string or unicode string"
+ doc_ref = _InputDocument()
+ doc_ref._type = PARSER_DATA_STRING
+ doc_ref._data_bytes = string
+ if base_url is not None:
+ doc_ref._filename = _encodeFilename(base_url)
+ return doc_ref
+
+ def resolve_filename(self, filename, context):
+ """resolve_filename(self, filename, context)
+
+ Return the name of a parsable file as input document.
+
+ Pass filename and context as parameters. You can also pass a
+ URL with an HTTP, FTP or file target.
+ """
+ cdef _InputDocument doc_ref
+ doc_ref = _InputDocument()
+ doc_ref._type = PARSER_DATA_FILENAME
+ doc_ref._filename = _encodeFilename(filename)
+ return doc_ref
+
+ def resolve_file(self, f, context, *, base_url=None, bint close=True):
+ """resolve_file(self, f, context, base_url=None, close=True)
+
+ Return an open file-like object as input document.
+
+ Pass open file and context as parameters. You can pass the
+ base URL or filename of the file through the ``base_url``
+ keyword argument. If the ``close`` flag is True (the
+ default), the file will be closed after reading.
+
+ Note that using ``.resolve_filename()`` is more efficient,
+ especially in threaded environments.
+ """
+ cdef _InputDocument doc_ref
+ try:
+ f.read
+ except AttributeError:
+ raise TypeError, "Argument is not a file-like object"
+ doc_ref = _InputDocument()
+ doc_ref._type = PARSER_DATA_FILE
+ if base_url is not None:
+ doc_ref._filename = _encodeFilename(base_url)
+ else:
+ doc_ref._filename = _getFilenameForFile(f)
+ doc_ref._close_file = close
+ doc_ref._file = f
+ return doc_ref
+
+@cython.final
+@cython.internal
+cdef class _ResolverRegistry:
+ cdef object _resolvers
+ cdef Resolver _default_resolver
+ def __cinit__(self, Resolver default_resolver=None):
+ self._resolvers = set()
+ self._default_resolver = default_resolver
+
+ def add(self, Resolver resolver not None):
+ """add(self, resolver)
+
+ Register a resolver.
+
+ For each requested entity, the 'resolve' method of the resolver will
+ be called and the result will be passed to the parser. If this method
+ returns None, the request will be delegated to other resolvers or the
+ default resolver. The resolvers will be tested in an arbitrary order
+ until the first match is found.
+ """
+ self._resolvers.add(resolver)
+
+ def remove(self, resolver):
+ "remove(self, resolver)"
+ self._resolvers.discard(resolver)
+
+ cdef _ResolverRegistry _copy(self):
+ cdef _ResolverRegistry registry
+ registry = _ResolverRegistry(self._default_resolver)
+ registry._resolvers = self._resolvers.copy()
+ return registry
+
+ def copy(self):
+ "copy(self)"
+ return self._copy()
+
+ def resolve(self, system_url, public_id, context):
+ "resolve(self, system_url, public_id, context)"
+ for resolver in self._resolvers:
+ result = resolver.resolve(system_url, public_id, context)
+ if result is not None:
+ return result
+ if self._default_resolver is None:
+ return None
+ return self._default_resolver.resolve(system_url, public_id, context)
+
+ def __repr__(self):
+ return repr(self._resolvers)
+
+
+@cython.internal
+cdef class _ResolverContext(_ExceptionContext):
+ cdef _ResolverRegistry _resolvers
+ cdef _TempStore _storage
+
+ cdef int clear(self) except -1:
+ _ExceptionContext.clear(self)
+ self._storage.clear()
+ return 0
+
+
+cdef _initResolverContext(_ResolverContext context,
+ _ResolverRegistry resolvers):
+ if resolvers is None:
+ context._resolvers = _ResolverRegistry()
+ else:
+ context._resolvers = resolvers
+ context._storage = _TempStore()
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/doctestcompare.py b/llmeval-env/lib/python3.10/site-packages/lxml/doctestcompare.py
new file mode 100644
index 0000000000000000000000000000000000000000..8099771de906a37ed007c779f152fe96f182060d
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/doctestcompare.py
@@ -0,0 +1,488 @@
+"""
+lxml-based doctest output comparison.
+
+Note: normally, you should just import the `lxml.usedoctest` and
+`lxml.html.usedoctest` modules from within a doctest, instead of this
+one::
+
+ >>> import lxml.usedoctest # for XML output
+
+ >>> import lxml.html.usedoctest # for HTML output
+
+To use this module directly, you must call ``lxmldoctest.install()``,
+which will cause doctest to use this in all subsequent calls.
+
+This changes the way output is checked and comparisons are made for
+XML or HTML-like content.
+
+XML or HTML content is noticed because the example starts with ``<``
+(it's HTML if it starts with ```` or include an ``any``
+attribute in the tag. An ``any`` tag matches any tag, while the
+attribute matches any and all attributes.
+
+When a match fails, the reformatted example and gotten text is
+displayed (indented), and a rough diff-like output is given. Anything
+marked with ``+`` is in the output but wasn't supposed to be, and
+similarly ``-`` means its in the example but wasn't in the output.
+
+You can disable parsing on one line with ``# doctest:+NOPARSE_MARKUP``
+"""
+
+from lxml import etree
+import sys
+import re
+import doctest
+try:
+ from html import escape as html_escape
+except ImportError:
+ from cgi import escape as html_escape
+
+__all__ = ['PARSE_HTML', 'PARSE_XML', 'NOPARSE_MARKUP', 'LXMLOutputChecker',
+ 'LHTMLOutputChecker', 'install', 'temp_install']
+
+PARSE_HTML = doctest.register_optionflag('PARSE_HTML')
+PARSE_XML = doctest.register_optionflag('PARSE_XML')
+NOPARSE_MARKUP = doctest.register_optionflag('NOPARSE_MARKUP')
+
+OutputChecker = doctest.OutputChecker
+
+def strip(v):
+ if v is None:
+ return None
+ else:
+ return v.strip()
+
+def norm_whitespace(v):
+ return _norm_whitespace_re.sub(' ', v)
+
+_html_parser = etree.HTMLParser(recover=False, remove_blank_text=True)
+
+def html_fromstring(html):
+ return etree.fromstring(html, _html_parser)
+
+# We use this to distinguish repr()s from elements:
+_repr_re = re.compile(r'^<[^>]+ (at|object) ')
+_norm_whitespace_re = re.compile(r'[ \t\n][ \t\n]+')
+
+class LXMLOutputChecker(OutputChecker):
+
+ empty_tags = (
+ 'param', 'img', 'area', 'br', 'basefont', 'input',
+ 'base', 'meta', 'link', 'col')
+
+ def get_default_parser(self):
+ return etree.XML
+
+ def check_output(self, want, got, optionflags):
+ alt_self = getattr(self, '_temp_override_self', None)
+ if alt_self is not None:
+ super_method = self._temp_call_super_check_output
+ self = alt_self
+ else:
+ super_method = OutputChecker.check_output
+ parser = self.get_parser(want, got, optionflags)
+ if not parser:
+ return super_method(
+ self, want, got, optionflags)
+ try:
+ want_doc = parser(want)
+ except etree.XMLSyntaxError:
+ return False
+ try:
+ got_doc = parser(got)
+ except etree.XMLSyntaxError:
+ return False
+ return self.compare_docs(want_doc, got_doc)
+
+ def get_parser(self, want, got, optionflags):
+ parser = None
+ if NOPARSE_MARKUP & optionflags:
+ return None
+ if PARSE_HTML & optionflags:
+ parser = html_fromstring
+ elif PARSE_XML & optionflags:
+ parser = etree.XML
+ elif (want.strip().lower().startswith('' % el.tag
+ return '<%s %s>' % (el.tag, ' '.join(attrs))
+
+ def format_end_tag(self, el):
+ if isinstance(el, etree.CommentBase):
+ # FIXME: probably PIs should be handled specially too?
+ return '-->'
+ return '%s>' % el.tag
+
+ def collect_diff(self, want, got, html, indent):
+ parts = []
+ if not len(want) and not len(got):
+ parts.append(' '*indent)
+ parts.append(self.collect_diff_tag(want, got))
+ if not self.html_empty_tag(got, html):
+ parts.append(self.collect_diff_text(want.text, got.text))
+ parts.append(self.collect_diff_end_tag(want, got))
+ parts.append(self.collect_diff_text(want.tail, got.tail))
+ parts.append('\n')
+ return ''.join(parts)
+ parts.append(' '*indent)
+ parts.append(self.collect_diff_tag(want, got))
+ parts.append('\n')
+ if strip(want.text) or strip(got.text):
+ parts.append(' '*indent)
+ parts.append(self.collect_diff_text(want.text, got.text))
+ parts.append('\n')
+ want_children = list(want)
+ got_children = list(got)
+ while want_children or got_children:
+ if not want_children:
+ parts.append(self.format_doc(got_children.pop(0), html, indent+2, '+'))
+ continue
+ if not got_children:
+ parts.append(self.format_doc(want_children.pop(0), html, indent+2, '-'))
+ continue
+ parts.append(self.collect_diff(
+ want_children.pop(0), got_children.pop(0), html, indent+2))
+ parts.append(' '*indent)
+ parts.append(self.collect_diff_end_tag(want, got))
+ parts.append('\n')
+ if strip(want.tail) or strip(got.tail):
+ parts.append(' '*indent)
+ parts.append(self.collect_diff_text(want.tail, got.tail))
+ parts.append('\n')
+ return ''.join(parts)
+
+ def collect_diff_tag(self, want, got):
+ if not self.tag_compare(want.tag, got.tag):
+ tag = '%s (got: %s)' % (want.tag, got.tag)
+ else:
+ tag = got.tag
+ attrs = []
+ any = want.tag == 'any' or 'any' in want.attrib
+ for name, value in sorted(got.attrib.items()):
+ if name not in want.attrib and not any:
+ attrs.append('+%s="%s"' % (name, self.format_text(value, False)))
+ else:
+ if name in want.attrib:
+ text = self.collect_diff_text(want.attrib[name], value, False)
+ else:
+ text = self.format_text(value, False)
+ attrs.append('%s="%s"' % (name, text))
+ if not any:
+ for name, value in sorted(want.attrib.items()):
+ if name in got.attrib:
+ continue
+ attrs.append('-%s="%s"' % (name, self.format_text(value, False)))
+ if attrs:
+ tag = '<%s %s>' % (tag, ' '.join(attrs))
+ else:
+ tag = '<%s>' % tag
+ return tag
+
+ def collect_diff_end_tag(self, want, got):
+ if want.tag != got.tag:
+ tag = '%s (got: %s)' % (want.tag, got.tag)
+ else:
+ tag = got.tag
+ return '%s>' % tag
+
+ def collect_diff_text(self, want, got, strip=True):
+ if self.text_compare(want, got, strip):
+ if not got:
+ return ''
+ return self.format_text(got, strip)
+ text = '%s (got: %s)' % (want, got)
+ return self.format_text(text, strip)
+
+class LHTMLOutputChecker(LXMLOutputChecker):
+ def get_default_parser(self):
+ return html_fromstring
+
+def install(html=False):
+ """
+ Install doctestcompare for all future doctests.
+
+ If html is true, then by default the HTML parser will be used;
+ otherwise the XML parser is used.
+ """
+ if html:
+ doctest.OutputChecker = LHTMLOutputChecker
+ else:
+ doctest.OutputChecker = LXMLOutputChecker
+
+def temp_install(html=False, del_module=None):
+ """
+ Use this *inside* a doctest to enable this checker for this
+ doctest only.
+
+ If html is true, then by default the HTML parser will be used;
+ otherwise the XML parser is used.
+ """
+ if html:
+ Checker = LHTMLOutputChecker
+ else:
+ Checker = LXMLOutputChecker
+ frame = _find_doctest_frame()
+ dt_self = frame.f_locals['self']
+ checker = Checker()
+ old_checker = dt_self._checker
+ dt_self._checker = checker
+ # The unfortunate thing is that there is a local variable 'check'
+ # in the function that runs the doctests, that is a bound method
+ # into the output checker. We have to update that. We can't
+ # modify the frame, so we have to modify the object in place. The
+ # only way to do this is to actually change the func_code
+ # attribute of the method. We change it, and then wait for
+ # __record_outcome to be run, which signals the end of the __run
+ # method, at which point we restore the previous check_output
+ # implementation.
+ check_func = frame.f_locals['check'].__func__
+ checker_check_func = checker.check_output.__func__
+ # Because we can't patch up func_globals, this is the only global
+ # in check_output that we care about:
+ doctest.etree = etree
+ _RestoreChecker(dt_self, old_checker, checker,
+ check_func, checker_check_func,
+ del_module)
+
+class _RestoreChecker:
+ def __init__(self, dt_self, old_checker, new_checker, check_func, clone_func,
+ del_module):
+ self.dt_self = dt_self
+ self.checker = old_checker
+ self.checker._temp_call_super_check_output = self.call_super
+ self.checker._temp_override_self = new_checker
+ self.check_func = check_func
+ self.clone_func = clone_func
+ self.del_module = del_module
+ self.install_clone()
+ self.install_dt_self()
+ def install_clone(self):
+ self.func_code = self.check_func.__code__
+ self.func_globals = self.check_func.__globals__
+ self.check_func.__code__ = self.clone_func.__code__
+ def uninstall_clone(self):
+ self.check_func.__code__ = self.func_code
+ def install_dt_self(self):
+ self.prev_func = self.dt_self._DocTestRunner__record_outcome
+ self.dt_self._DocTestRunner__record_outcome = self
+ def uninstall_dt_self(self):
+ self.dt_self._DocTestRunner__record_outcome = self.prev_func
+ def uninstall_module(self):
+ if self.del_module:
+ import sys
+ del sys.modules[self.del_module]
+ if '.' in self.del_module:
+ package, module = self.del_module.rsplit('.', 1)
+ package_mod = sys.modules[package]
+ delattr(package_mod, module)
+ def __call__(self, *args, **kw):
+ self.uninstall_clone()
+ self.uninstall_dt_self()
+ del self.checker._temp_override_self
+ del self.checker._temp_call_super_check_output
+ result = self.prev_func(*args, **kw)
+ self.uninstall_module()
+ return result
+ def call_super(self, *args, **kw):
+ self.uninstall_clone()
+ try:
+ return self.check_func(*args, **kw)
+ finally:
+ self.install_clone()
+
+def _find_doctest_frame():
+ import sys
+ frame = sys._getframe(1)
+ while frame:
+ l = frame.f_locals
+ if 'BOOM' in l:
+ # Sign of doctest
+ return frame
+ frame = frame.f_back
+ raise LookupError(
+ "Could not find doctest (only use this function *inside* a doctest)")
+
+__test__ = {
+ 'basic': '''
+ >>> temp_install()
+ >>> print """stuff"""
+ ...
+ >>> print """"""
+
+
+
+ >>> print """blahblahblah""" # doctest: +NOPARSE_MARKUP, +ELLIPSIS
+ ...foo />
+ '''}
+
+if __name__ == '__main__':
+ import doctest
+ doctest.testmod()
+
+
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/dtd.pxi b/llmeval-env/lib/python3.10/site-packages/lxml/dtd.pxi
new file mode 100644
index 0000000000000000000000000000000000000000..348212c3dccaa4c70f57b572ebec9229a16981d9
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/dtd.pxi
@@ -0,0 +1,478 @@
+# support for DTD validation
+from lxml.includes cimport dtdvalid
+
+cdef class DTDError(LxmlError):
+ """Base class for DTD errors.
+ """
+
+cdef class DTDParseError(DTDError):
+ """Error while parsing a DTD.
+ """
+
+cdef class DTDValidateError(DTDError):
+ """Error while validating an XML document with a DTD.
+ """
+
+
+cdef inline int _assertValidDTDNode(node, void *c_node) except -1:
+ assert c_node is not NULL, "invalid DTD proxy at %s" % id(node)
+
+
+@cython.final
+@cython.internal
+@cython.freelist(8)
+cdef class _DTDElementContentDecl:
+ cdef DTD _dtd
+ cdef tree.xmlElementContent* _c_node
+
+ def __repr__(self):
+ return "<%s.%s object name=%r type=%r occur=%r at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, self.type, self.occur, id(self))
+
+ @property
+ def name(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.name)
+
+ @property
+ def type(self):
+ _assertValidDTDNode(self, self._c_node)
+ cdef int type = self._c_node.type
+ if type == tree.XML_ELEMENT_CONTENT_PCDATA:
+ return "pcdata"
+ elif type == tree.XML_ELEMENT_CONTENT_ELEMENT:
+ return "element"
+ elif type == tree.XML_ELEMENT_CONTENT_SEQ:
+ return "seq"
+ elif type == tree.XML_ELEMENT_CONTENT_OR:
+ return "or"
+ else:
+ return None
+
+ @property
+ def occur(self):
+ _assertValidDTDNode(self, self._c_node)
+ cdef int occur = self._c_node.ocur
+ if occur == tree.XML_ELEMENT_CONTENT_ONCE:
+ return "once"
+ elif occur == tree.XML_ELEMENT_CONTENT_OPT:
+ return "opt"
+ elif occur == tree.XML_ELEMENT_CONTENT_MULT:
+ return "mult"
+ elif occur == tree.XML_ELEMENT_CONTENT_PLUS:
+ return "plus"
+ else:
+ return None
+
+ @property
+ def left(self):
+ _assertValidDTDNode(self, self._c_node)
+ c1 = self._c_node.c1
+ if c1:
+ node = <_DTDElementContentDecl>_DTDElementContentDecl.__new__(_DTDElementContentDecl)
+ node._dtd = self._dtd
+ node._c_node = c1
+ return node
+ else:
+ return None
+
+ @property
+ def right(self):
+ _assertValidDTDNode(self, self._c_node)
+ c2 = self._c_node.c2
+ if c2:
+ node = <_DTDElementContentDecl>_DTDElementContentDecl.__new__(_DTDElementContentDecl)
+ node._dtd = self._dtd
+ node._c_node = c2
+ return node
+ else:
+ return None
+
+
+@cython.final
+@cython.internal
+@cython.freelist(8)
+cdef class _DTDAttributeDecl:
+ cdef DTD _dtd
+ cdef tree.xmlAttribute* _c_node
+
+ def __repr__(self):
+ return "<%s.%s object name=%r elemname=%r prefix=%r type=%r default=%r default_value=%r at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, self.elemname, self.prefix, self.type, self.default, self.default_value, id(self))
+
+ @property
+ def name(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.name)
+
+ @property
+ def elemname(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.elem)
+
+ @property
+ def prefix(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.prefix)
+
+ @property
+ def type(self):
+ _assertValidDTDNode(self, self._c_node)
+ cdef int type = self._c_node.atype
+ if type == tree.XML_ATTRIBUTE_CDATA:
+ return "cdata"
+ elif type == tree.XML_ATTRIBUTE_ID:
+ return "id"
+ elif type == tree.XML_ATTRIBUTE_IDREF:
+ return "idref"
+ elif type == tree.XML_ATTRIBUTE_IDREFS:
+ return "idrefs"
+ elif type == tree.XML_ATTRIBUTE_ENTITY:
+ return "entity"
+ elif type == tree.XML_ATTRIBUTE_ENTITIES:
+ return "entities"
+ elif type == tree.XML_ATTRIBUTE_NMTOKEN:
+ return "nmtoken"
+ elif type == tree.XML_ATTRIBUTE_NMTOKENS:
+ return "nmtokens"
+ elif type == tree.XML_ATTRIBUTE_ENUMERATION:
+ return "enumeration"
+ elif type == tree.XML_ATTRIBUTE_NOTATION:
+ return "notation"
+ else:
+ return None
+
+ @property
+ def default(self):
+ _assertValidDTDNode(self, self._c_node)
+ cdef int default = self._c_node.def_
+ if default == tree.XML_ATTRIBUTE_NONE:
+ return "none"
+ elif default == tree.XML_ATTRIBUTE_REQUIRED:
+ return "required"
+ elif default == tree.XML_ATTRIBUTE_IMPLIED:
+ return "implied"
+ elif default == tree.XML_ATTRIBUTE_FIXED:
+ return "fixed"
+ else:
+ return None
+
+ @property
+ def default_value(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.defaultValue)
+
+ def itervalues(self):
+ _assertValidDTDNode(self, self._c_node)
+ cdef tree.xmlEnumeration *c_node = self._c_node.tree
+ while c_node is not NULL:
+ yield funicode(c_node.name)
+ c_node = c_node.next
+
+ def values(self):
+ return list(self.itervalues())
+
+
+@cython.final
+@cython.internal
+@cython.freelist(8)
+cdef class _DTDElementDecl:
+ cdef DTD _dtd
+ cdef tree.xmlElement* _c_node
+
+ def __repr__(self):
+ return "<%s.%s object name=%r prefix=%r type=%r at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, self.prefix, self.type, id(self))
+
+ @property
+ def name(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.name)
+
+ @property
+ def prefix(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.prefix)
+
+ @property
+ def type(self):
+ _assertValidDTDNode(self, self._c_node)
+ cdef int type = self._c_node.etype
+ if type == tree.XML_ELEMENT_TYPE_UNDEFINED:
+ return "undefined"
+ elif type == tree.XML_ELEMENT_TYPE_EMPTY:
+ return "empty"
+ elif type == tree.XML_ELEMENT_TYPE_ANY:
+ return "any"
+ elif type == tree.XML_ELEMENT_TYPE_MIXED:
+ return "mixed"
+ elif type == tree.XML_ELEMENT_TYPE_ELEMENT:
+ return "element"
+ else:
+ return None
+
+ @property
+ def content(self):
+ _assertValidDTDNode(self, self._c_node)
+ cdef tree.xmlElementContent *content = self._c_node.content
+ if content:
+ node = <_DTDElementContentDecl>_DTDElementContentDecl.__new__(_DTDElementContentDecl)
+ node._dtd = self._dtd
+ node._c_node = content
+ return node
+ else:
+ return None
+
+ def iterattributes(self):
+ _assertValidDTDNode(self, self._c_node)
+ cdef tree.xmlAttribute *c_node = self._c_node.attributes
+ while c_node:
+ node = <_DTDAttributeDecl>_DTDAttributeDecl.__new__(_DTDAttributeDecl)
+ node._dtd = self._dtd
+ node._c_node = c_node
+ yield node
+ c_node = c_node.nexth
+
+ def attributes(self):
+ return list(self.iterattributes())
+
+
+@cython.final
+@cython.internal
+@cython.freelist(8)
+cdef class _DTDEntityDecl:
+ cdef DTD _dtd
+ cdef tree.xmlEntity* _c_node
+ def __repr__(self):
+ return "<%s.%s object name=%r at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, id(self))
+
+ @property
+ def name(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.name)
+
+ @property
+ def orig(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.orig)
+
+ @property
+ def content(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.content)
+
+ @property
+ def system_url(self):
+ _assertValidDTDNode(self, self._c_node)
+ return funicodeOrNone(self._c_node.SystemID)
+
+
+################################################################################
+# DTD
+
+cdef class DTD(_Validator):
+ """DTD(self, file=None, external_id=None)
+ A DTD validator.
+
+ Can load from filesystem directly given a filename or file-like object.
+ Alternatively, pass the keyword parameter ``external_id`` to load from a
+ catalog.
+ """
+ cdef tree.xmlDtd* _c_dtd
+ def __init__(self, file=None, *, external_id=None):
+ _Validator.__init__(self)
+ if file is not None:
+ file = _getFSPathOrObject(file)
+ if _isString(file):
+ file = _encodeFilename(file)
+ with self._error_log:
+ orig_loader = _register_document_loader()
+ self._c_dtd = xmlparser.xmlParseDTD(NULL, _xcstr(file))
+ _reset_document_loader(orig_loader)
+ elif hasattr(file, 'read'):
+ orig_loader = _register_document_loader()
+ self._c_dtd = _parseDtdFromFilelike(file)
+ _reset_document_loader(orig_loader)
+ else:
+ raise DTDParseError, "file must be a filename, file-like or path-like object"
+ elif external_id is not None:
+ with self._error_log:
+ orig_loader = _register_document_loader()
+ self._c_dtd = xmlparser.xmlParseDTD(external_id, NULL)
+ _reset_document_loader(orig_loader)
+ else:
+ raise DTDParseError, "either filename or external ID required"
+
+ if self._c_dtd is NULL:
+ raise DTDParseError(
+ self._error_log._buildExceptionMessage("error parsing DTD"),
+ self._error_log)
+
+ @property
+ def name(self):
+ if self._c_dtd is NULL:
+ return None
+ return funicodeOrNone(self._c_dtd.name)
+
+ @property
+ def external_id(self):
+ if self._c_dtd is NULL:
+ return None
+ return funicodeOrNone(self._c_dtd.ExternalID)
+
+ @property
+ def system_url(self):
+ if self._c_dtd is NULL:
+ return None
+ return funicodeOrNone(self._c_dtd.SystemID)
+
+ def iterelements(self):
+ cdef tree.xmlNode *c_node = self._c_dtd.children if self._c_dtd is not NULL else NULL
+ while c_node is not NULL:
+ if c_node.type == tree.XML_ELEMENT_DECL:
+ node = _DTDElementDecl()
+ node._dtd = self
+ node._c_node = c_node
+ yield node
+ c_node = c_node.next
+
+ def elements(self):
+ return list(self.iterelements())
+
+ def iterentities(self):
+ cdef tree.xmlNode *c_node = self._c_dtd.children if self._c_dtd is not NULL else NULL
+ while c_node is not NULL:
+ if c_node.type == tree.XML_ENTITY_DECL:
+ node = _DTDEntityDecl()
+ node._dtd = self
+ node._c_node = c_node
+ yield node
+ c_node = c_node.next
+
+ def entities(self):
+ return list(self.iterentities())
+
+ def __dealloc__(self):
+ tree.xmlFreeDtd(self._c_dtd)
+
+ def __call__(self, etree):
+ """__call__(self, etree)
+
+ Validate doc using the DTD.
+
+ Returns true if the document is valid, false if not.
+ """
+ cdef _Document doc
+ cdef _Element root_node
+ cdef xmlDoc* c_doc
+ cdef dtdvalid.xmlValidCtxt* valid_ctxt
+ cdef int ret = -1
+
+ assert self._c_dtd is not NULL, "DTD not initialised"
+ doc = _documentOrRaise(etree)
+ root_node = _rootNodeOrRaise(etree)
+
+ valid_ctxt = dtdvalid.xmlNewValidCtxt()
+ if valid_ctxt is NULL:
+ raise DTDError("Failed to create validation context")
+
+ # work around error reporting bug in libxml2 <= 2.9.1 (and later?)
+ # https://bugzilla.gnome.org/show_bug.cgi?id=724903
+ valid_ctxt.error = _nullGenericErrorFunc
+ valid_ctxt.userData = NULL
+
+ try:
+ with self._error_log:
+ c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
+ ret = dtdvalid.xmlValidateDtd(valid_ctxt, c_doc, self._c_dtd)
+ _destroyFakeDoc(doc._c_doc, c_doc)
+ finally:
+ dtdvalid.xmlFreeValidCtxt(valid_ctxt)
+
+ if ret == -1:
+ raise DTDValidateError("Internal error in DTD validation",
+ self._error_log)
+ return ret == 1
+
+
+cdef tree.xmlDtd* _parseDtdFromFilelike(file) except NULL:
+ cdef _ExceptionContext exc_context
+ cdef _FileReaderContext dtd_parser
+ cdef _ErrorLog error_log
+ cdef tree.xmlDtd* c_dtd = NULL
+ exc_context = _ExceptionContext()
+ dtd_parser = _FileReaderContext(file, exc_context, None)
+ error_log = _ErrorLog()
+
+ with error_log:
+ c_dtd = dtd_parser._readDtd()
+
+ exc_context._raise_if_stored()
+ if c_dtd is NULL:
+ raise DTDParseError("error parsing DTD", error_log)
+ return c_dtd
+
+cdef DTD _dtdFactory(tree.xmlDtd* c_dtd):
+ # do not run through DTD.__init__()!
+ cdef DTD dtd
+ if c_dtd is NULL:
+ return None
+ dtd = DTD.__new__(DTD)
+ dtd._c_dtd = _copyDtd(c_dtd)
+ _Validator.__init__(dtd)
+ return dtd
+
+
+cdef tree.xmlDtd* _copyDtd(tree.xmlDtd* c_orig_dtd) except NULL:
+ """
+ Copy a DTD. libxml2 (currently) fails to set up the element->attributes
+ links when copying DTDs, so we have to rebuild them here.
+ """
+ c_dtd = tree.xmlCopyDtd(c_orig_dtd)
+ if not c_dtd:
+ raise MemoryError
+ cdef tree.xmlNode* c_node = c_dtd.children
+ while c_node:
+ if c_node.type == tree.XML_ATTRIBUTE_DECL:
+ _linkDtdAttribute(c_dtd, c_node)
+ c_node = c_node.next
+ return c_dtd
+
+
+cdef void _linkDtdAttribute(tree.xmlDtd* c_dtd, tree.xmlAttribute* c_attr) noexcept:
+ """
+ Create the link to the DTD attribute declaration from the corresponding
+ element declaration.
+ """
+ c_elem = dtdvalid.xmlGetDtdElementDesc(c_dtd, c_attr.elem)
+ if not c_elem:
+ # no such element? something is wrong with the DTD ...
+ return
+ c_pos = c_elem.attributes
+ if not c_pos:
+ c_elem.attributes = c_attr
+ c_attr.nexth = NULL
+ return
+ # libxml2 keeps namespace declarations first, and we need to make
+ # sure we don't re-insert attributes that are already there
+ if _isDtdNsDecl(c_attr):
+ if not _isDtdNsDecl(c_pos):
+ c_elem.attributes = c_attr
+ c_attr.nexth = c_pos
+ return
+ while c_pos != c_attr and c_pos.nexth and _isDtdNsDecl(c_pos.nexth):
+ c_pos = c_pos.nexth
+ else:
+ # append at end
+ while c_pos != c_attr and c_pos.nexth:
+ c_pos = c_pos.nexth
+ if c_pos == c_attr:
+ return
+ c_attr.nexth = c_pos.nexth
+ c_pos.nexth = c_attr
+
+
+cdef bint _isDtdNsDecl(tree.xmlAttribute* c_attr) noexcept:
+ if cstring_h.strcmp(c_attr.name, "xmlns") == 0:
+ return True
+ if (c_attr.prefix is not NULL and
+ cstring_h.strcmp(c_attr.prefix, "xmlns") == 0):
+ return True
+ return False
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/etree_api.h b/llmeval-env/lib/python3.10/site-packages/lxml/etree_api.h
new file mode 100644
index 0000000000000000000000000000000000000000..b0ebb13dbd535c0b4bcb4ef39536aaf0aa0f0ffe
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/etree_api.h
@@ -0,0 +1,195 @@
+/* Generated by Cython 3.0.10 */
+
+#ifndef __PYX_HAVE_API__lxml__etree
+#define __PYX_HAVE_API__lxml__etree
+#ifdef __MINGW64__
+#define MS_WIN64
+#endif
+#include "Python.h"
+#include "etree.h"
+
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument)(struct LxmlDocument *, xmlNode *) = 0;
+#define deepcopyNodeToDocument __pyx_api_f_4lxml_5etree_deepcopyNodeToDocument
+static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_elementTreeFactory)(struct LxmlElement *) = 0;
+#define elementTreeFactory __pyx_api_f_4lxml_5etree_elementTreeFactory
+static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_newElementTree)(struct LxmlElement *, PyObject *) = 0;
+#define newElementTree __pyx_api_f_4lxml_5etree_newElementTree
+static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_adoptExternalDocument)(xmlDoc *, PyObject *, int) = 0;
+#define adoptExternalDocument __pyx_api_f_4lxml_5etree_adoptExternalDocument
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_elementFactory)(struct LxmlDocument *, xmlNode *) = 0;
+#define elementFactory __pyx_api_f_4lxml_5etree_elementFactory
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_makeElement)(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *) = 0;
+#define makeElement __pyx_api_f_4lxml_5etree_makeElement
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_makeSubElement)(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *) = 0;
+#define makeSubElement __pyx_api_f_4lxml_5etree_makeSubElement
+static void (*__pyx_api_f_4lxml_5etree_setElementClassLookupFunction)(_element_class_lookup_function, PyObject *) = 0;
+#define setElementClassLookupFunction __pyx_api_f_4lxml_5etree_setElementClassLookupFunction
+static PyObject *(*__pyx_api_f_4lxml_5etree_lookupDefaultElementClass)(PyObject *, PyObject *, xmlNode *) = 0;
+#define lookupDefaultElementClass __pyx_api_f_4lxml_5etree_lookupDefaultElementClass
+static PyObject *(*__pyx_api_f_4lxml_5etree_lookupNamespaceElementClass)(PyObject *, PyObject *, xmlNode *) = 0;
+#define lookupNamespaceElementClass __pyx_api_f_4lxml_5etree_lookupNamespaceElementClass
+static PyObject *(*__pyx_api_f_4lxml_5etree_callLookupFallback)(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *) = 0;
+#define callLookupFallback __pyx_api_f_4lxml_5etree_callLookupFallback
+static int (*__pyx_api_f_4lxml_5etree_tagMatches)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
+#define tagMatches __pyx_api_f_4lxml_5etree_tagMatches
+static struct LxmlDocument *(*__pyx_api_f_4lxml_5etree_documentOrRaise)(PyObject *) = 0;
+#define documentOrRaise __pyx_api_f_4lxml_5etree_documentOrRaise
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_rootNodeOrRaise)(PyObject *) = 0;
+#define rootNodeOrRaise __pyx_api_f_4lxml_5etree_rootNodeOrRaise
+static int (*__pyx_api_f_4lxml_5etree_hasText)(xmlNode *) = 0;
+#define hasText __pyx_api_f_4lxml_5etree_hasText
+static int (*__pyx_api_f_4lxml_5etree_hasTail)(xmlNode *) = 0;
+#define hasTail __pyx_api_f_4lxml_5etree_hasTail
+static PyObject *(*__pyx_api_f_4lxml_5etree_textOf)(xmlNode *) = 0;
+#define textOf __pyx_api_f_4lxml_5etree_textOf
+static PyObject *(*__pyx_api_f_4lxml_5etree_tailOf)(xmlNode *) = 0;
+#define tailOf __pyx_api_f_4lxml_5etree_tailOf
+static int (*__pyx_api_f_4lxml_5etree_setNodeText)(xmlNode *, PyObject *) = 0;
+#define setNodeText __pyx_api_f_4lxml_5etree_setNodeText
+static int (*__pyx_api_f_4lxml_5etree_setTailText)(xmlNode *, PyObject *) = 0;
+#define setTailText __pyx_api_f_4lxml_5etree_setTailText
+static PyObject *(*__pyx_api_f_4lxml_5etree_attributeValue)(xmlNode *, xmlAttr *) = 0;
+#define attributeValue __pyx_api_f_4lxml_5etree_attributeValue
+static PyObject *(*__pyx_api_f_4lxml_5etree_attributeValueFromNsName)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
+#define attributeValueFromNsName __pyx_api_f_4lxml_5etree_attributeValueFromNsName
+static PyObject *(*__pyx_api_f_4lxml_5etree_getAttributeValue)(struct LxmlElement *, PyObject *, PyObject *) = 0;
+#define getAttributeValue __pyx_api_f_4lxml_5etree_getAttributeValue
+static PyObject *(*__pyx_api_f_4lxml_5etree_iterattributes)(struct LxmlElement *, int) = 0;
+#define iterattributes __pyx_api_f_4lxml_5etree_iterattributes
+static PyObject *(*__pyx_api_f_4lxml_5etree_collectAttributes)(xmlNode *, int) = 0;
+#define collectAttributes __pyx_api_f_4lxml_5etree_collectAttributes
+static int (*__pyx_api_f_4lxml_5etree_setAttributeValue)(struct LxmlElement *, PyObject *, PyObject *) = 0;
+#define setAttributeValue __pyx_api_f_4lxml_5etree_setAttributeValue
+static int (*__pyx_api_f_4lxml_5etree_delAttribute)(struct LxmlElement *, PyObject *) = 0;
+#define delAttribute __pyx_api_f_4lxml_5etree_delAttribute
+static int (*__pyx_api_f_4lxml_5etree_delAttributeFromNsName)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
+#define delAttributeFromNsName __pyx_api_f_4lxml_5etree_delAttributeFromNsName
+static int (*__pyx_api_f_4lxml_5etree_hasChild)(xmlNode *) = 0;
+#define hasChild __pyx_api_f_4lxml_5etree_hasChild
+static xmlNode *(*__pyx_api_f_4lxml_5etree_findChild)(xmlNode *, Py_ssize_t) = 0;
+#define findChild __pyx_api_f_4lxml_5etree_findChild
+static xmlNode *(*__pyx_api_f_4lxml_5etree_findChildForwards)(xmlNode *, Py_ssize_t) = 0;
+#define findChildForwards __pyx_api_f_4lxml_5etree_findChildForwards
+static xmlNode *(*__pyx_api_f_4lxml_5etree_findChildBackwards)(xmlNode *, Py_ssize_t) = 0;
+#define findChildBackwards __pyx_api_f_4lxml_5etree_findChildBackwards
+static xmlNode *(*__pyx_api_f_4lxml_5etree_nextElement)(xmlNode *) = 0;
+#define nextElement __pyx_api_f_4lxml_5etree_nextElement
+static xmlNode *(*__pyx_api_f_4lxml_5etree_previousElement)(xmlNode *) = 0;
+#define previousElement __pyx_api_f_4lxml_5etree_previousElement
+static void (*__pyx_api_f_4lxml_5etree_appendChild)(struct LxmlElement *, struct LxmlElement *) = 0;
+#define appendChild __pyx_api_f_4lxml_5etree_appendChild
+static int (*__pyx_api_f_4lxml_5etree_appendChildToElement)(struct LxmlElement *, struct LxmlElement *) = 0;
+#define appendChildToElement __pyx_api_f_4lxml_5etree_appendChildToElement
+static PyObject *(*__pyx_api_f_4lxml_5etree_pyunicode)(const xmlChar *) = 0;
+#define pyunicode __pyx_api_f_4lxml_5etree_pyunicode
+static PyObject *(*__pyx_api_f_4lxml_5etree_utf8)(PyObject *) = 0;
+#define utf8 __pyx_api_f_4lxml_5etree_utf8
+static PyObject *(*__pyx_api_f_4lxml_5etree_getNsTag)(PyObject *) = 0;
+#define getNsTag __pyx_api_f_4lxml_5etree_getNsTag
+static PyObject *(*__pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs)(PyObject *) = 0;
+#define getNsTagWithEmptyNs __pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs
+static PyObject *(*__pyx_api_f_4lxml_5etree_namespacedName)(xmlNode *) = 0;
+#define namespacedName __pyx_api_f_4lxml_5etree_namespacedName
+static PyObject *(*__pyx_api_f_4lxml_5etree_namespacedNameFromNsName)(const xmlChar *, const xmlChar *) = 0;
+#define namespacedNameFromNsName __pyx_api_f_4lxml_5etree_namespacedNameFromNsName
+static void (*__pyx_api_f_4lxml_5etree_iteratorStoreNext)(struct LxmlElementIterator *, struct LxmlElement *) = 0;
+#define iteratorStoreNext __pyx_api_f_4lxml_5etree_iteratorStoreNext
+static void (*__pyx_api_f_4lxml_5etree_initTagMatch)(struct LxmlElementTagMatcher *, PyObject *) = 0;
+#define initTagMatch __pyx_api_f_4lxml_5etree_initTagMatch
+static xmlNs *(*__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix)(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *) = 0;
+#define findOrBuildNodeNsPrefix __pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix
+#ifndef __PYX_HAVE_RT_ImportFunction_3_0_10
+#define __PYX_HAVE_RT_ImportFunction_3_0_10
+static int __Pyx_ImportFunction_3_0_10(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
+ PyObject *d = 0;
+ PyObject *cobj = 0;
+ union {
+ void (*fp)(void);
+ void *p;
+ } tmp;
+ d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
+ if (!d)
+ goto bad;
+ cobj = PyDict_GetItemString(d, funcname);
+ if (!cobj) {
+ PyErr_Format(PyExc_ImportError,
+ "%.200s does not export expected C function %.200s",
+ PyModule_GetName(module), funcname);
+ goto bad;
+ }
+ if (!PyCapsule_IsValid(cobj, sig)) {
+ PyErr_Format(PyExc_TypeError,
+ "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
+ PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
+ goto bad;
+ }
+ tmp.p = PyCapsule_GetPointer(cobj, sig);
+ *f = tmp.fp;
+ if (!(*f))
+ goto bad;
+ Py_DECREF(d);
+ return 0;
+bad:
+ Py_XDECREF(d);
+ return -1;
+}
+#endif
+
+
+static int import_lxml__etree(void) {
+ PyObject *module = 0;
+ module = PyImport_ImportModule("lxml.etree");
+ if (!module) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "deepcopyNodeToDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "elementTreeFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementTreeFactory, "struct LxmlElementTree *(struct LxmlElement *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "newElementTree", (void (**)(void))&__pyx_api_f_4lxml_5etree_newElementTree, "struct LxmlElementTree *(struct LxmlElement *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "adoptExternalDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_adoptExternalDocument, "struct LxmlElementTree *(xmlDoc *, PyObject *, int)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "elementFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementFactory, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "makeElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_makeElement, "struct LxmlElement *(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "makeSubElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_makeSubElement, "struct LxmlElement *(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "setElementClassLookupFunction", (void (**)(void))&__pyx_api_f_4lxml_5etree_setElementClassLookupFunction, "void (_element_class_lookup_function, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "lookupDefaultElementClass", (void (**)(void))&__pyx_api_f_4lxml_5etree_lookupDefaultElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "lookupNamespaceElementClass", (void (**)(void))&__pyx_api_f_4lxml_5etree_lookupNamespaceElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "callLookupFallback", (void (**)(void))&__pyx_api_f_4lxml_5etree_callLookupFallback, "PyObject *(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "tagMatches", (void (**)(void))&__pyx_api_f_4lxml_5etree_tagMatches, "int (xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "documentOrRaise", (void (**)(void))&__pyx_api_f_4lxml_5etree_documentOrRaise, "struct LxmlDocument *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "rootNodeOrRaise", (void (**)(void))&__pyx_api_f_4lxml_5etree_rootNodeOrRaise, "struct LxmlElement *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "hasText", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasText, "int (xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "hasTail", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasTail, "int (xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "textOf", (void (**)(void))&__pyx_api_f_4lxml_5etree_textOf, "PyObject *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "tailOf", (void (**)(void))&__pyx_api_f_4lxml_5etree_tailOf, "PyObject *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "setNodeText", (void (**)(void))&__pyx_api_f_4lxml_5etree_setNodeText, "int (xmlNode *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "setTailText", (void (**)(void))&__pyx_api_f_4lxml_5etree_setTailText, "int (xmlNode *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "attributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_attributeValue, "PyObject *(xmlNode *, xmlAttr *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "attributeValueFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_attributeValueFromNsName, "PyObject *(xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "getAttributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_getAttributeValue, "PyObject *(struct LxmlElement *, PyObject *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "iterattributes", (void (**)(void))&__pyx_api_f_4lxml_5etree_iterattributes, "PyObject *(struct LxmlElement *, int)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "collectAttributes", (void (**)(void))&__pyx_api_f_4lxml_5etree_collectAttributes, "PyObject *(xmlNode *, int)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "setAttributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_setAttributeValue, "int (struct LxmlElement *, PyObject *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "delAttribute", (void (**)(void))&__pyx_api_f_4lxml_5etree_delAttribute, "int (struct LxmlElement *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "delAttributeFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_delAttributeFromNsName, "int (xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "hasChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasChild, "int (xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "findChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChild, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "findChildForwards", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChildForwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "findChildBackwards", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChildBackwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "nextElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_nextElement, "xmlNode *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "previousElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_previousElement, "xmlNode *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "appendChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_appendChild, "void (struct LxmlElement *, struct LxmlElement *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "appendChildToElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_appendChildToElement, "int (struct LxmlElement *, struct LxmlElement *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "pyunicode", (void (**)(void))&__pyx_api_f_4lxml_5etree_pyunicode, "PyObject *(const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "utf8", (void (**)(void))&__pyx_api_f_4lxml_5etree_utf8, "PyObject *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "getNsTag", (void (**)(void))&__pyx_api_f_4lxml_5etree_getNsTag, "PyObject *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "getNsTagWithEmptyNs", (void (**)(void))&__pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs, "PyObject *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "namespacedName", (void (**)(void))&__pyx_api_f_4lxml_5etree_namespacedName, "PyObject *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "namespacedNameFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_namespacedNameFromNsName, "PyObject *(const xmlChar *, const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "iteratorStoreNext", (void (**)(void))&__pyx_api_f_4lxml_5etree_iteratorStoreNext, "void (struct LxmlElementIterator *, struct LxmlElement *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "initTagMatch", (void (**)(void))&__pyx_api_f_4lxml_5etree_initTagMatch, "void (struct LxmlElementTagMatcher *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "findOrBuildNodeNsPrefix", (void (**)(void))&__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix, "xmlNs *(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
+ Py_DECREF(module); module = 0;
+ return 0;
+ bad:
+ Py_XDECREF(module);
+ return -1;
+}
+
+#endif /* !__PYX_HAVE_API__lxml__etree */
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/_diffcommand.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/_diffcommand.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..927c2713e13a8b2ece4459700e5df0cae7062c32
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/_diffcommand.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/_setmixin.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/_setmixin.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..0e5aef556cee4e565b98deddd012aaddead066f8
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/_setmixin.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/builder.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/builder.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..0ef4e827d07835be076f3ef9b569fea2707e6733
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/builder.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/diff.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/diff.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..ca59a4d5abfd4d02365c22d84f74aa98b72a29ab
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/diff.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/soupparser.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/soupparser.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..226340edc56f200507f985c086caea74ac860548
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/html/__pycache__/soupparser.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/_html5builder.py b/llmeval-env/lib/python3.10/site-packages/lxml/html/_html5builder.py
new file mode 100644
index 0000000000000000000000000000000000000000..a88ed944f47067f0560821c8e749c0bbb5f08e00
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/html/_html5builder.py
@@ -0,0 +1,100 @@
+"""
+Legacy module - don't use in new code!
+
+html5lib now has its own proper implementation.
+
+This module implements a tree builder for html5lib that generates lxml
+html element trees. This module uses camelCase as it follows the
+html5lib style guide.
+"""
+
+from html5lib.treebuilders import _base, etree as etree_builders
+from lxml import html, etree
+
+
+class DocumentType:
+
+ def __init__(self, name, publicId, systemId):
+ self.name = name
+ self.publicId = publicId
+ self.systemId = systemId
+
+class Document:
+
+ def __init__(self):
+ self._elementTree = None
+ self.childNodes = []
+
+ def appendChild(self, element):
+ self._elementTree.getroot().addnext(element._element)
+
+
+class TreeBuilder(_base.TreeBuilder):
+ documentClass = Document
+ doctypeClass = DocumentType
+ elementClass = None
+ commentClass = None
+ fragmentClass = Document
+
+ def __init__(self, *args, **kwargs):
+ html_builder = etree_builders.getETreeModule(html, fullTree=False)
+ etree_builder = etree_builders.getETreeModule(etree, fullTree=False)
+ self.elementClass = html_builder.Element
+ self.commentClass = etree_builder.Comment
+ _base.TreeBuilder.__init__(self, *args, **kwargs)
+
+ def reset(self):
+ _base.TreeBuilder.reset(self)
+ self.rootInserted = False
+ self.initialComments = []
+ self.doctype = None
+
+ def getDocument(self):
+ return self.document._elementTree
+
+ def getFragment(self):
+ fragment = []
+ element = self.openElements[0]._element
+ if element.text:
+ fragment.append(element.text)
+ fragment.extend(element.getchildren())
+ if element.tail:
+ fragment.append(element.tail)
+ return fragment
+
+ def insertDoctype(self, name, publicId, systemId):
+ doctype = self.doctypeClass(name, publicId, systemId)
+ self.doctype = doctype
+
+ def insertComment(self, data, parent=None):
+ if not self.rootInserted:
+ self.initialComments.append(data)
+ else:
+ _base.TreeBuilder.insertComment(self, data, parent)
+
+ def insertRoot(self, name):
+ buf = []
+ if self.doctype and self.doctype.name:
+ buf.append('')
+ buf.append('')
+ root = html.fromstring(''.join(buf))
+
+ # Append the initial comments:
+ for comment in self.initialComments:
+ root.addprevious(etree.Comment(comment))
+
+ # Create the root document and add the ElementTree to it
+ self.document = self.documentClass()
+ self.document._elementTree = root.getroottree()
+
+ # Add the root element to the internal child/open data structures
+ root_element = self.elementClass(name)
+ root_element._element = root
+ self.document.childNodes.append(root_element)
+ self.openElements.append(root_element)
+
+ self.rootInserted = True
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/clean.py b/llmeval-env/lib/python3.10/site-packages/lxml/html/clean.py
new file mode 100644
index 0000000000000000000000000000000000000000..d4b9e96d8745e99cef8d217cbddc34f60186862a
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/html/clean.py
@@ -0,0 +1,21 @@
+# cython: language_level=3str
+
+"""Backward-compatibility module for lxml_html_clean"""
+
+try:
+ from lxml_html_clean import *
+
+ __all__ = [
+ "clean_html",
+ "clean",
+ "Cleaner",
+ "autolink",
+ "autolink_html",
+ "word_break",
+ "word_break_html",
+ ]
+except ImportError:
+ raise ImportError(
+ "lxml.html.clean module is now a separate project lxml_html_clean.\n"
+ "Install lxml[html_clean] or lxml_html_clean directly."
+ ) from None
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/diff.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/lxml/html/diff.cpython-310-x86_64-linux-gnu.so
new file mode 100644
index 0000000000000000000000000000000000000000..449c670484a2d8c67a2e391e9deec687c7f8a85c
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/html/diff.cpython-310-x86_64-linux-gnu.so differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/html5parser.py b/llmeval-env/lib/python3.10/site-packages/lxml/html/html5parser.py
new file mode 100644
index 0000000000000000000000000000000000000000..2f7be1568977aff1ccc6533f0626226e0f57bec9
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/html/html5parser.py
@@ -0,0 +1,260 @@
+"""
+An interface to html5lib that mimics the lxml.html interface.
+"""
+import sys
+import string
+
+from html5lib import HTMLParser as _HTMLParser
+from html5lib.treebuilders.etree_lxml import TreeBuilder
+from lxml import etree
+from lxml.html import Element, XHTML_NAMESPACE, _contains_block_level_tag
+
+# python3 compatibility
+try:
+ _strings = basestring
+except NameError:
+ _strings = (bytes, str)
+try:
+ from urllib2 import urlopen
+except ImportError:
+ from urllib.request import urlopen
+try:
+ from urlparse import urlparse
+except ImportError:
+ from urllib.parse import urlparse
+
+
+class HTMLParser(_HTMLParser):
+ """An html5lib HTML parser with lxml as tree."""
+
+ def __init__(self, strict=False, **kwargs):
+ _HTMLParser.__init__(self, strict=strict, tree=TreeBuilder, **kwargs)
+
+
+try:
+ from html5lib import XHTMLParser as _XHTMLParser
+except ImportError:
+ pass
+else:
+ class XHTMLParser(_XHTMLParser):
+ """An html5lib XHTML Parser with lxml as tree."""
+
+ def __init__(self, strict=False, **kwargs):
+ _XHTMLParser.__init__(self, strict=strict, tree=TreeBuilder, **kwargs)
+
+ xhtml_parser = XHTMLParser()
+
+
+def _find_tag(tree, tag):
+ elem = tree.find(tag)
+ if elem is not None:
+ return elem
+ return tree.find('{%s}%s' % (XHTML_NAMESPACE, tag))
+
+
+def document_fromstring(html, guess_charset=None, parser=None):
+ """
+ Parse a whole document into a string.
+
+ If `guess_charset` is true, or if the input is not Unicode but a
+ byte string, the `chardet` library will perform charset guessing
+ on the string.
+ """
+ if not isinstance(html, _strings):
+ raise TypeError('string required')
+
+ if parser is None:
+ parser = html_parser
+
+ options = {}
+ if guess_charset is None and isinstance(html, bytes):
+ # html5lib does not accept useChardet as an argument, if it
+ # detected the html argument would produce unicode objects.
+ guess_charset = True
+ if guess_charset is not None:
+ options['useChardet'] = guess_charset
+ return parser.parse(html, **options).getroot()
+
+
+def fragments_fromstring(html, no_leading_text=False,
+ guess_charset=None, parser=None):
+ """Parses several HTML elements, returning a list of elements.
+
+ The first item in the list may be a string. If no_leading_text is true,
+ then it will be an error if there is leading text, and it will always be
+ a list of only elements.
+
+ If `guess_charset` is true, the `chardet` library will perform charset
+ guessing on the string.
+ """
+ if not isinstance(html, _strings):
+ raise TypeError('string required')
+
+ if parser is None:
+ parser = html_parser
+
+ options = {}
+ if guess_charset is None and isinstance(html, bytes):
+ # html5lib does not accept useChardet as an argument, if it
+ # detected the html argument would produce unicode objects.
+ guess_charset = False
+ if guess_charset is not None:
+ options['useChardet'] = guess_charset
+ children = parser.parseFragment(html, 'div', **options)
+ if children and isinstance(children[0], _strings):
+ if no_leading_text:
+ if children[0].strip():
+ raise etree.ParserError('There is leading text: %r' %
+ children[0])
+ del children[0]
+ return children
+
+
+def fragment_fromstring(html, create_parent=False,
+ guess_charset=None, parser=None):
+ """Parses a single HTML element; it is an error if there is more than
+ one element, or if anything but whitespace precedes or follows the
+ element.
+
+ If 'create_parent' is true (or is a tag name) then a parent node
+ will be created to encapsulate the HTML in a single element. In
+ this case, leading or trailing text is allowed.
+
+ If `guess_charset` is true, the `chardet` library will perform charset
+ guessing on the string.
+ """
+ if not isinstance(html, _strings):
+ raise TypeError('string required')
+
+ accept_leading_text = bool(create_parent)
+
+ elements = fragments_fromstring(
+ html, guess_charset=guess_charset, parser=parser,
+ no_leading_text=not accept_leading_text)
+
+ if create_parent:
+ if not isinstance(create_parent, _strings):
+ create_parent = 'div'
+ new_root = Element(create_parent)
+ if elements:
+ if isinstance(elements[0], _strings):
+ new_root.text = elements[0]
+ del elements[0]
+ new_root.extend(elements)
+ return new_root
+
+ if not elements:
+ raise etree.ParserError('No elements found')
+ if len(elements) > 1:
+ raise etree.ParserError('Multiple elements found')
+ result = elements[0]
+ if result.tail and result.tail.strip():
+ raise etree.ParserError('Element followed by text: %r' % result.tail)
+ result.tail = None
+ return result
+
+
+def fromstring(html, guess_charset=None, parser=None):
+ """Parse the html, returning a single element/document.
+
+ This tries to minimally parse the chunk of text, without knowing if it
+ is a fragment or a document.
+
+ 'base_url' will set the document's base_url attribute (and the tree's
+ docinfo.URL)
+
+ If `guess_charset` is true, or if the input is not Unicode but a
+ byte string, the `chardet` library will perform charset guessing
+ on the string.
+ """
+ if not isinstance(html, _strings):
+ raise TypeError('string required')
+ doc = document_fromstring(html, parser=parser,
+ guess_charset=guess_charset)
+
+ # document starts with doctype or , full document!
+ start = html[:50]
+ if isinstance(start, bytes):
+ # Allow text comparison in python3.
+ # Decode as ascii, that also covers latin-1 and utf-8 for the
+ # characters we need.
+ start = start.decode('ascii', 'replace')
+
+ start = start.lstrip().lower()
+ if start.startswith(' implies too much structure.
+ if _contains_block_level_tag(body):
+ body.tag = 'div'
+ else:
+ body.tag = 'span'
+ return body
+
+
+def parse(filename_url_or_file, guess_charset=None, parser=None):
+ """Parse a filename, URL, or file-like object into an HTML document
+ tree. Note: this returns a tree, not an element. Use
+ ``parse(...).getroot()`` to get the document root.
+
+ If ``guess_charset`` is true, the ``useChardet`` option is passed into
+ html5lib to enable character detection. This option is on by default
+ when parsing from URLs, off by default when parsing from file(-like)
+ objects (which tend to return Unicode more often than not), and on by
+ default when parsing from a file path (which is read in binary mode).
+ """
+ if parser is None:
+ parser = html_parser
+ if not isinstance(filename_url_or_file, _strings):
+ fp = filename_url_or_file
+ if guess_charset is None:
+ # assume that file-like objects return Unicode more often than bytes
+ guess_charset = False
+ elif _looks_like_url(filename_url_or_file):
+ fp = urlopen(filename_url_or_file)
+ if guess_charset is None:
+ # assume that URLs return bytes
+ guess_charset = True
+ else:
+ fp = open(filename_url_or_file, 'rb')
+ if guess_charset is None:
+ guess_charset = True
+
+ options = {}
+ # html5lib does not accept useChardet as an argument, if it
+ # detected the html argument would produce unicode objects.
+ if guess_charset:
+ options['useChardet'] = guess_charset
+ return parser.parse(fp, **options)
+
+
+def _looks_like_url(str):
+ scheme = urlparse(str)[0]
+ if not scheme:
+ return False
+ elif (sys.platform == 'win32' and
+ scheme in string.ascii_letters
+ and len(scheme) == 1):
+ # looks like a 'normal' absolute path
+ return False
+ else:
+ return True
+
+
+html_parser = HTMLParser()
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/html/soupparser.py b/llmeval-env/lib/python3.10/site-packages/lxml/html/soupparser.py
new file mode 100644
index 0000000000000000000000000000000000000000..b288a8a1597663ea2cbaa55bc41e46434a3a589f
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/html/soupparser.py
@@ -0,0 +1,314 @@
+"""External interface to the BeautifulSoup HTML parser.
+"""
+
+__all__ = ["fromstring", "parse", "convert_tree"]
+
+import re
+from lxml import etree, html
+
+try:
+ from bs4 import (
+ BeautifulSoup, Tag, Comment, ProcessingInstruction, NavigableString,
+ Declaration, Doctype)
+ _DECLARATION_OR_DOCTYPE = (Declaration, Doctype)
+except ImportError:
+ from BeautifulSoup import (
+ BeautifulSoup, Tag, Comment, ProcessingInstruction, NavigableString,
+ Declaration)
+ _DECLARATION_OR_DOCTYPE = Declaration
+
+
+def fromstring(data, beautifulsoup=None, makeelement=None, **bsargs):
+ """Parse a string of HTML data into an Element tree using the
+ BeautifulSoup parser.
+
+ Returns the root ```` Element of the tree.
+
+ You can pass a different BeautifulSoup parser through the
+ `beautifulsoup` keyword, and a diffent Element factory function
+ through the `makeelement` keyword. By default, the standard
+ ``BeautifulSoup`` class and the default factory of `lxml.html` are
+ used.
+ """
+ return _parse(data, beautifulsoup, makeelement, **bsargs)
+
+
+def parse(file, beautifulsoup=None, makeelement=None, **bsargs):
+ """Parse a file into an ElemenTree using the BeautifulSoup parser.
+
+ You can pass a different BeautifulSoup parser through the
+ `beautifulsoup` keyword, and a diffent Element factory function
+ through the `makeelement` keyword. By default, the standard
+ ``BeautifulSoup`` class and the default factory of `lxml.html` are
+ used.
+ """
+ if not hasattr(file, 'read'):
+ file = open(file)
+ root = _parse(file, beautifulsoup, makeelement, **bsargs)
+ return etree.ElementTree(root)
+
+
+def convert_tree(beautiful_soup_tree, makeelement=None):
+ """Convert a BeautifulSoup tree to a list of Element trees.
+
+ Returns a list instead of a single root Element to support
+ HTML-like soup with more than one root element.
+
+ You can pass a different Element factory through the `makeelement`
+ keyword.
+ """
+ root = _convert_tree(beautiful_soup_tree, makeelement)
+ children = root.getchildren()
+ for child in children:
+ root.remove(child)
+ return children
+
+
+# helpers
+
+def _parse(source, beautifulsoup, makeelement, **bsargs):
+ if beautifulsoup is None:
+ beautifulsoup = BeautifulSoup
+ if hasattr(beautifulsoup, "HTML_ENTITIES"): # bs3
+ if 'convertEntities' not in bsargs:
+ bsargs['convertEntities'] = 'html'
+ if hasattr(beautifulsoup, "DEFAULT_BUILDER_FEATURES"): # bs4
+ if 'features' not in bsargs:
+ bsargs['features'] = 'html.parser' # use Python html parser
+ tree = beautifulsoup(source, **bsargs)
+ root = _convert_tree(tree, makeelement)
+ # from ET: wrap the document in a html root element, if necessary
+ if len(root) == 1 and root[0].tag == "html":
+ return root[0]
+ root.tag = "html"
+ return root
+
+
+_parse_doctype_declaration = re.compile(
+ r'(?:\s|[ element. However, the document
+ # may be a soup like 'HelloHi
+ # all<\p>'. In this example roots is a list containing meta, head
+ # and body elements.
+ if first_element_idx is None:
+ pre_root = post_root = []
+ roots = beautiful_soup_tree.contents
+ else:
+ pre_root = beautiful_soup_tree.contents[:first_element_idx]
+ roots = beautiful_soup_tree.contents[first_element_idx:last_element_idx+1]
+ post_root = beautiful_soup_tree.contents[last_element_idx+1:]
+
+ # Reorganize so that there is one root...
+ if html_root is not None:
+ # ... use existing one if possible, ...
+ i = roots.index(html_root)
+ html_root.contents = roots[:i] + html_root.contents + roots[i+1:]
+ else:
+ # ... otherwise create a new one.
+ html_root = _PseudoTag(roots)
+
+ convert_node = _init_node_converters(makeelement)
+
+ # Process pre_root
+ res_root = convert_node(html_root)
+ prev = res_root
+ for e in reversed(pre_root):
+ converted = convert_node(e)
+ if converted is not None:
+ prev.addprevious(converted)
+ prev = converted
+
+ # ditto for post_root
+ prev = res_root
+ for e in post_root:
+ converted = convert_node(e)
+ if converted is not None:
+ prev.addnext(converted)
+ prev = converted
+
+ if declaration is not None:
+ try:
+ # bs4 provides full Doctype string
+ doctype_string = declaration.output_ready()
+ except AttributeError:
+ doctype_string = declaration.string
+
+ match = _parse_doctype_declaration(doctype_string)
+ if not match:
+ # Something is wrong if we end up in here. Since soupparser should
+ # tolerate errors, do not raise Exception, just let it pass.
+ pass
+ else:
+ external_id, sys_uri = match.groups()
+ docinfo = res_root.getroottree().docinfo
+ # strip quotes and update DOCTYPE values (any of None, '', '...')
+ docinfo.public_id = external_id and external_id[1:-1]
+ docinfo.system_url = sys_uri and sys_uri[1:-1]
+
+ return res_root
+
+
+def _init_node_converters(makeelement):
+ converters = {}
+ ordered_node_types = []
+
+ def converter(*types):
+ def add(handler):
+ for t in types:
+ converters[t] = handler
+ ordered_node_types.append(t)
+ return handler
+ return add
+
+ def find_best_converter(node):
+ for t in ordered_node_types:
+ if isinstance(node, t):
+ return converters[t]
+ return None
+
+ def convert_node(bs_node, parent=None):
+ # duplicated in convert_tag() below
+ try:
+ handler = converters[type(bs_node)]
+ except KeyError:
+ handler = converters[type(bs_node)] = find_best_converter(bs_node)
+ if handler is None:
+ return None
+ return handler(bs_node, parent)
+
+ def map_attrs(bs_attrs):
+ if isinstance(bs_attrs, dict): # bs4
+ attribs = {}
+ for k, v in bs_attrs.items():
+ if isinstance(v, list):
+ v = " ".join(v)
+ attribs[k] = unescape(v)
+ else:
+ attribs = {k: unescape(v) for k, v in bs_attrs}
+ return attribs
+
+ def append_text(parent, text):
+ if len(parent) == 0:
+ parent.text = (parent.text or '') + text
+ else:
+ parent[-1].tail = (parent[-1].tail or '') + text
+
+ # converters are tried in order of their definition
+
+ @converter(Tag, _PseudoTag)
+ def convert_tag(bs_node, parent):
+ attrs = bs_node.attrs
+ if parent is not None:
+ attribs = map_attrs(attrs) if attrs else None
+ res = etree.SubElement(parent, bs_node.name, attrib=attribs)
+ else:
+ attribs = map_attrs(attrs) if attrs else {}
+ res = makeelement(bs_node.name, attrib=attribs)
+
+ for child in bs_node:
+ # avoid double recursion by inlining convert_node(), see above
+ try:
+ handler = converters[type(child)]
+ except KeyError:
+ pass
+ else:
+ if handler is not None:
+ handler(child, res)
+ continue
+ convert_node(child, res)
+ return res
+
+ @converter(Comment)
+ def convert_comment(bs_node, parent):
+ res = html.HtmlComment(bs_node)
+ if parent is not None:
+ parent.append(res)
+ return res
+
+ @converter(ProcessingInstruction)
+ def convert_pi(bs_node, parent):
+ if bs_node.endswith('?'):
+ # The PI is of XML style () but BeautifulSoup
+ # interpreted it as being SGML style (). Fix.
+ bs_node = bs_node[:-1]
+ res = etree.ProcessingInstruction(*bs_node.split(' ', 1))
+ if parent is not None:
+ parent.append(res)
+ return res
+
+ @converter(NavigableString)
+ def convert_text(bs_node, parent):
+ if parent is not None:
+ append_text(parent, unescape(bs_node))
+ return None
+
+ return convert_node
+
+
+# copied from ET's ElementSoup
+
+try:
+ from html.entities import name2codepoint # Python 3
+except ImportError:
+ from htmlentitydefs import name2codepoint
+
+
+handle_entities = re.compile(r"&(\w+);").sub
+
+
+try:
+ unichr
+except NameError:
+ # Python 3
+ unichr = chr
+
+
+def unescape(string):
+ if not string:
+ return ''
+ # work around oddities in BeautifulSoup's entity handling
+ def unescape_entity(m):
+ try:
+ return unichr(name2codepoint[m.group(1)])
+ except KeyError:
+ return m.group(0) # use as is
+ return handle_entities(unescape_entity, string)
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/__init__.py b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..a157a8224e7941828a9fbf8c9994bc5325ee7b05
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/__init__.py
@@ -0,0 +1,348 @@
+"""The ``lxml.isoschematron`` package implements ISO Schematron support on top
+of the pure-xslt 'skeleton' implementation.
+"""
+
+import sys
+import os.path
+from lxml import etree as _etree # due to validator __init__ signature
+
+
+# some compat stuff, borrowed from lxml.html
+try:
+ unicode
+except NameError:
+ # Python 3
+ unicode = str
+try:
+ basestring
+except NameError:
+ # Python 3
+ basestring = str
+
+
+__all__ = ['extract_xsd', 'extract_rng', 'iso_dsdl_include',
+ 'iso_abstract_expand', 'iso_svrl_for_xslt1',
+ 'svrl_validation_errors', 'schematron_schema_valid',
+ 'stylesheet_params', 'Schematron']
+
+
+# some namespaces
+#FIXME: Maybe lxml should provide a dedicated place for common namespace
+#FIXME: definitions?
+XML_SCHEMA_NS = "http://www.w3.org/2001/XMLSchema"
+RELAXNG_NS = "http://relaxng.org/ns/structure/1.0"
+SCHEMATRON_NS = "http://purl.oclc.org/dsdl/schematron"
+SVRL_NS = "http://purl.oclc.org/dsdl/svrl"
+
+
+# some helpers
+_schematron_root = '{%s}schema' % SCHEMATRON_NS
+_xml_schema_root = '{%s}schema' % XML_SCHEMA_NS
+_resources_dir = os.path.join(os.path.dirname(__file__), 'resources')
+
+
+# the iso-schematron skeleton implementation steps aka xsl transformations
+extract_xsd = _etree.XSLT(_etree.parse(
+ os.path.join(_resources_dir, 'xsl', 'XSD2Schtrn.xsl')))
+extract_rng = _etree.XSLT(_etree.parse(
+ os.path.join(_resources_dir, 'xsl', 'RNG2Schtrn.xsl')))
+iso_dsdl_include = _etree.XSLT(_etree.parse(
+ os.path.join(_resources_dir, 'xsl', 'iso-schematron-xslt1',
+ 'iso_dsdl_include.xsl')))
+iso_abstract_expand = _etree.XSLT(_etree.parse(
+ os.path.join(_resources_dir, 'xsl', 'iso-schematron-xslt1',
+ 'iso_abstract_expand.xsl')))
+iso_svrl_for_xslt1 = _etree.XSLT(_etree.parse(
+ os.path.join(_resources_dir,
+ 'xsl', 'iso-schematron-xslt1', 'iso_svrl_for_xslt1.xsl')))
+
+
+# svrl result accessors
+svrl_validation_errors = _etree.XPath(
+ '//svrl:failed-assert', namespaces={'svrl': SVRL_NS})
+
+# RelaxNG validator for schematron schemas
+schematron_schema_valid_supported = False
+try:
+ schematron_schema_valid = _etree.RelaxNG(
+ file=os.path.join(_resources_dir, 'rng', 'iso-schematron.rng'))
+ schematron_schema_valid_supported = True
+except _etree.RelaxNGParseError:
+ # Some distributions delete the file due to licensing issues.
+ def schematron_schema_valid(arg):
+ raise NotImplementedError("Validating the ISO schematron requires iso-schematron.rng")
+
+
+def stylesheet_params(**kwargs):
+ """Convert keyword args to a dictionary of stylesheet parameters.
+ XSL stylesheet parameters must be XPath expressions, i.e.:
+
+ * string expressions, like "'5'"
+ * simple (number) expressions, like "5"
+ * valid XPath expressions, like "/a/b/text()"
+
+ This function converts native Python keyword arguments to stylesheet
+ parameters following these rules:
+ If an arg is a string wrap it with XSLT.strparam().
+ If an arg is an XPath object use its path string.
+ If arg is None raise TypeError.
+ Else convert arg to string.
+ """
+ result = {}
+ for key, val in kwargs.items():
+ if isinstance(val, basestring):
+ val = _etree.XSLT.strparam(val)
+ elif val is None:
+ raise TypeError('None not allowed as a stylesheet parameter')
+ elif not isinstance(val, _etree.XPath):
+ val = unicode(val)
+ result[key] = val
+ return result
+
+
+# helper function for use in Schematron __init__
+def _stylesheet_param_dict(paramsDict, kwargsDict):
+ """Return a copy of paramsDict, updated with kwargsDict entries, wrapped as
+ stylesheet arguments.
+ kwargsDict entries with a value of None are ignored.
+ """
+ # beware of changing mutable default arg
+ paramsDict = dict(paramsDict)
+ for k, v in kwargsDict.items():
+ if v is not None: # None values do not override
+ paramsDict[k] = v
+ paramsDict = stylesheet_params(**paramsDict)
+ return paramsDict
+
+
+class Schematron(_etree._Validator):
+ """An ISO Schematron validator.
+
+ Pass a root Element or an ElementTree to turn it into a validator.
+ Alternatively, pass a filename as keyword argument 'file' to parse from
+ the file system.
+
+ Schematron is a less well known, but very powerful schema language.
+ The main idea is to use the capabilities of XPath to put restrictions on
+ the structure and the content of XML documents.
+
+ The standard behaviour is to fail on ``failed-assert`` findings only
+ (``ASSERTS_ONLY``). To change this, you can either pass a report filter
+ function to the ``error_finder`` parameter (e.g. ``ASSERTS_AND_REPORTS``
+ or a custom ``XPath`` object), or subclass isoschematron.Schematron for
+ complete control of the validation process.
+
+ Built on the Schematron language 'reference' skeleton pure-xslt
+ implementation, the validator is created as an XSLT 1.0 stylesheet using
+ these steps:
+
+ 0) (Extract from XML Schema or RelaxNG schema)
+ 1) Process inclusions
+ 2) Process abstract patterns
+ 3) Compile the schematron schema to XSLT
+
+ The ``include`` and ``expand`` keyword arguments can be used to switch off
+ steps 1) and 2).
+ To set parameters for steps 1), 2) and 3) hand parameter dictionaries to the
+ keyword arguments ``include_params``, ``expand_params`` or
+ ``compile_params``.
+ For convenience, the compile-step parameter ``phase`` is also exposed as a
+ keyword argument ``phase``. This takes precedence if the parameter is also
+ given in the parameter dictionary.
+
+ If ``store_schematron`` is set to True, the (included-and-expanded)
+ schematron document tree is stored and available through the ``schematron``
+ property.
+ If ``store_xslt`` is set to True, the validation XSLT document tree will be
+ stored and can be retrieved through the ``validator_xslt`` property.
+ With ``store_report`` set to True (default: False), the resulting validation
+ report document gets stored and can be accessed as the ``validation_report``
+ property.
+
+ If ``validate_schema`` is set to False, the validation of the schema file
+ itself is disabled. Validation happens by default after building the full
+ schema, unless the schema validation file cannot be found at import time,
+ in which case the validation gets disabled. Some lxml distributions exclude
+ this file due to licensing issues. ISO-Schematron validation can then still
+ be used normally, but the schemas themselves cannot be validated.
+
+ Here is a usage example::
+
+ >>> from lxml import etree
+ >>> from lxml.isoschematron import Schematron
+
+ >>> schematron = Schematron(etree.XML('''
+ ...
+ ...
+ ... id is the only permitted attribute name
+ ...
+ ... Attribute
+ ... is forbidden
+ ...
+ ...
+ ...
+ ... '''),
+ ... error_finder=Schematron.ASSERTS_AND_REPORTS)
+
+ >>> xml = etree.XML('''
+ ...
+ ...
+ ...
+ ...
+ ... ''')
+
+ >>> schematron.validate(xml)
+ False
+
+ >>> xml = etree.XML('''
+ ...
+ ...
+ ...
+ ...
+ ... ''')
+
+ >>> schematron.validate(xml)
+ True
+ """
+
+ # libxml2 error categorization for validation errors
+ _domain = _etree.ErrorDomains.SCHEMATRONV
+ _level = _etree.ErrorLevels.ERROR
+ _error_type = _etree.ErrorTypes.SCHEMATRONV_ASSERT
+
+ # convenience definitions for common behaviours
+ ASSERTS_ONLY = svrl_validation_errors # Default
+ ASSERTS_AND_REPORTS = _etree.XPath(
+ '//svrl:failed-assert | //svrl:successful-report',
+ namespaces={'svrl': SVRL_NS})
+
+ def _extract(self, element):
+ """Extract embedded schematron schema from non-schematron host schema.
+ This method will only be called by __init__ if the given schema document
+ is not a schematron schema by itself.
+ Must return a schematron schema document tree or None.
+ """
+ schematron = None
+ if element.tag == _xml_schema_root:
+ schematron = self._extract_xsd(element)
+ elif element.nsmap[element.prefix] == RELAXNG_NS:
+ # RelaxNG does not have a single unique root element
+ schematron = self._extract_rng(element)
+ return schematron
+
+ # customization points
+ # etree.XSLT objects that provide the extract, include, expand, compile
+ # steps
+ _extract_xsd = extract_xsd
+ _extract_rng = extract_rng
+ _include = iso_dsdl_include
+ _expand = iso_abstract_expand
+ _compile = iso_svrl_for_xslt1
+
+ # etree.xpath object that determines input document validity when applied to
+ # the svrl result report; must return a list of result elements (empty if
+ # valid)
+ _validation_errors = ASSERTS_ONLY
+
+ def __init__(self, etree=None, file=None, include=True, expand=True,
+ include_params={}, expand_params={}, compile_params={},
+ store_schematron=False, store_xslt=False, store_report=False,
+ phase=None, error_finder=ASSERTS_ONLY,
+ validate_schema=schematron_schema_valid_supported):
+ super().__init__()
+
+ self._store_report = store_report
+ self._schematron = None
+ self._validator_xslt = None
+ self._validation_report = None
+ if error_finder is not self.ASSERTS_ONLY:
+ self._validation_errors = error_finder
+
+ # parse schema document, may be a schematron schema or an XML Schema or
+ # a RelaxNG schema with embedded schematron rules
+ root = None
+ try:
+ if etree is not None:
+ if _etree.iselement(etree):
+ root = etree
+ else:
+ root = etree.getroot()
+ elif file is not None:
+ root = _etree.parse(file).getroot()
+ except Exception:
+ raise _etree.SchematronParseError(
+ "No tree or file given: %s" % sys.exc_info()[1])
+ if root is None:
+ raise ValueError("Empty tree")
+ if root.tag == _schematron_root:
+ schematron = root
+ else:
+ schematron = self._extract(root)
+ if schematron is None:
+ raise _etree.SchematronParseError(
+ "Document is not a schematron schema or schematron-extractable")
+ # perform the iso-schematron skeleton implementation steps to get a
+ # validating xslt
+ if include:
+ schematron = self._include(schematron, **include_params)
+ if expand:
+ schematron = self._expand(schematron, **expand_params)
+ if validate_schema and not schematron_schema_valid(schematron):
+ raise _etree.SchematronParseError(
+ "invalid schematron schema: %s" %
+ schematron_schema_valid.error_log)
+ if store_schematron:
+ self._schematron = schematron
+ # add new compile keyword args here if exposing them
+ compile_kwargs = {'phase': phase}
+ compile_params = _stylesheet_param_dict(compile_params, compile_kwargs)
+ validator_xslt = self._compile(schematron, **compile_params)
+ if store_xslt:
+ self._validator_xslt = validator_xslt
+ self._validator = _etree.XSLT(validator_xslt)
+
+ def __call__(self, etree):
+ """Validate doc using Schematron.
+
+ Returns true if document is valid, false if not.
+ """
+ self._clear_error_log()
+ result = self._validator(etree)
+ if self._store_report:
+ self._validation_report = result
+ errors = self._validation_errors(result)
+ if errors:
+ if _etree.iselement(etree):
+ fname = etree.getroottree().docinfo.URL or ''
+ else:
+ fname = etree.docinfo.URL or ''
+ for error in errors:
+ # Does svrl report the line number, anywhere? Don't think so.
+ self._append_log_message(
+ domain=self._domain, type=self._error_type,
+ level=self._level, line=0,
+ message=_etree.tostring(error, encoding='unicode'),
+ filename=fname)
+ return False
+ return True
+
+ @property
+ def schematron(self):
+ """ISO-schematron schema document (None if object has been initialized
+ with store_schematron=False).
+ """
+ return self._schematron
+
+ @property
+ def validator_xslt(self):
+ """ISO-schematron skeleton implementation XSLT validator document (None
+ if object has been initialized with store_xslt=False).
+ """
+ return self._validator_xslt
+
+ @property
+ def validation_report(self):
+ """ISO-schematron validation result report (None if result-storing has
+ been turned off).
+ """
+ return self._validation_report
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/__pycache__/__init__.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/__pycache__/__init__.cpython-310.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..90e634b62341320e5da758b181b5a89b782bf35f
Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/__pycache__/__init__.cpython-310.pyc differ
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/rng/iso-schematron.rng b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/rng/iso-schematron.rng
new file mode 100644
index 0000000000000000000000000000000000000000..a4f504af1f7d6f01f7523d447b9304f417c01800
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/rng/iso-schematron.rng
@@ -0,0 +1,709 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ltr
+ rtl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ preserve
+ default
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..21a5d2a069cab9fa327d9a3cd4e4d56c21bb10db
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..de0c9ea700d20c78111660e5fe8bf4ddc5a88137
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..5018395234799dd65d53a339daaddf445a09dbea
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl
@@ -0,0 +1,313 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Suppressed abstract pattern was here
+
+
+
+
+
+
+ Start pattern based on abstract
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..44e5573b73077e015d404935479bdc9344c5ea4d
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl
@@ -0,0 +1,1160 @@
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in RELAX NG extRef
+ include
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in Schematron include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+ Schema error: Use include to
+ include fragments, not a whole
+ schema
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+ Schema error: Use include to include
+ fragments, not a whole schema
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in Schematron include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in Schematron include
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+ Schema error: Use include to include
+ fragments, not a whole schema
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+ Schema error: Use include to include
+ fragments, not a whole schema
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in DTLL include
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in CRDL include
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Fatal error: Xinclude href contains fragment
+ identifier #
+
+
+
+
+
+
+ Fatal error: Sorry, this software only
+ supports simple ids in XInclude xpointers
+
+
+
+
+
+
+ Fatal Error: Impossible URL in XInclude
+ include
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file and fallback
+ file:
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in XLink embedding
+ link
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unable to open referenced included file:
+
+
+
+
+
+
+ Unable to locate id attribute:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..d59b8f38fe0bf28bc089b033c2acdd314839b8cc
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ (
+ /
+ )
+
+
+
\ No newline at end of file
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..b0e7175cfff34fb05d631622c9429f0adcda8d5d
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl
@@ -0,0 +1,1796 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ #ALL
+
+
+
+false
+
+true
+
+
+
+
+ true
+ false
+
+
+
+
+
+
+ true
+ false
+
+
+
+
+
+
+
+
+ @*|
+
+ *
+ node()
+ *|comment()|processing-instruction()
+
+
+
+
+
+
+
+
+
+
+
+
+default
+
+false
+
+
+
+1
+
+
+
+
+ Schema error: Schematron elements in old and new namespaces found
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Schema error: in the queryBinding attribute, use 'xslt'
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+ This XSLT was automatically generated from a Schematron schema.
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+ Fail: This implementation of ISO Schematron does not work with
+ schemas using the "" query language.
+
+
+
+
+ Implementers: please note that overriding process-prolog or process-root is
+ the preferred method for meta-stylesheets to use where possible.
+
+
+
+
+
+
+
+
+
+ PHASES
+
+ PROLOG
+
+ KEYS
+
+ DEFAULT RULES
+
+ SCHEMA METADATA
+
+ SCHEMATRON PATTERNS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Phase Error: no phase with name has been defined.
+
+
+
+
+
+
+ MODE: SCHEMATRON-SELECT-FULL-PATH
+ This mode can be used to generate an ugly though full XPath for locators
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MODE: SCHEMATRON-FULL-PATH
+ This mode can be used to generate an ugly though full XPath for locators
+
+
+
+
+
+ /
+
+
+
+
+
+ []
+
+
+
+ *[local-name()='
+ ' and namespace-uri()='
+
+ ']
+
+
+ []
+
+
+
+
+
+
+
+
+
+ /
+
+ @
+
+ @*[local-name()='
+
+ ' and namespace-uri()='
+
+ ']
+
+
+
+
+
+
+
+
+ MODE: SCHEMATRON-FULL-PATH-2
+
+ This mode can be used to generate prefixed XPath for humans
+
+
+
+
+
+ /
+
+
+ [
+
+ ]
+
+
+
+
+ /@
+
+
+
+
+ MODE: GENERATE-ID-FROM-PATH
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .
+
+
+
+
+
+
+ MODE: SCHEMATRON-FULL-PATH-3
+
+
+ This mode can be used to generate prefixed XPath for humans
+ (Top-level element has index)
+
+
+
+
+
+ /
+
+
+ [
+
+ ]
+
+
+
+
+ /@
+
+
+
+
+ MODE: GENERATE-ID-2
+
+
+ U
+
+
+ U
+
+
+
+
+ U.
+
+ n
+
+
+
+
+ U.
+
+ _
+
+ _
+
+
+
+
+ Strip characters
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no pattern attribute in <active>
+
+
+
+ Reference Error: the pattern "" has been activated but is not declared
+
+
+
+
+
+
+
+ Markup Error: no test attribute in <assert
+
+
+ ASSERT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no test attribute in <report>
+
+
+
+ REPORT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no id attribute in <diagnostic>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no rule attribute in <extends>
+
+
+ Reference Error: the abstract rule "" has been referenced but is not declared
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no name attribute in <key>
+
+
+ Markup Error: no path or use attribute in <key>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no path or use attribute in <key>
+
+
+
+
+
+
+
+
+
+
+
+ Schema error: The key element is not in the ISO Schematron namespace. Use the XSLT namespace.
+
+
+
+
+
+
+
+ Schema error: Empty href= attribute for include directive.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in Schematron include
+
+
+
+
+
+
+ Schema error: Use include to include fragments, not a whole schema
+
+
+
+
+
+
+
+
+
+ Schema error: Use include to include fragments, not a whole schema
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: Impossible URL in Schematron include
+
+
+
+
+
+
+ Schema error: Use include to include fragments, not a whole schema
+
+
+
+
+
+
+
+
+
+
+ Schema error: Use include to include fragments, not a whole schema
+
+
+
+
+
+
+
+
+
+ Warning: Variables should not be used with the "xpath" query language binding.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no uri attribute in <ns>
+
+
+ Markup Error: no prefix attribute in <ns>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ //(
+
+ (
+
+ )
+ |
+
+ )
+ [not(self::text())]
+
+
+
+
+
+
+
+
+
+
+
+
+ Schema implementation error: This schema has abstract patterns, yet they are supposed to be preprocessed out already
+
+
+
+
+
+
+
+
+
+ PATTERN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no id attribute in <phase>
+
+
+
+
+
+
+
+ Markup Error: no context attribute in <rule>
+
+
+ RULE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no id attribute on abstract <rule>
+
+
+ Markup Error: (2) context attribute on abstract <rule>
+
+
+
+
+
+ Markup Error: context attribute on abstract <rule>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Markup Error: no select attribute in <value-of>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Warning:
+
+ must not contain any child elements
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Reference error: A diagnostic "" has been referenced but is not declared
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Using the XSLT namespace with a prefix other than "xsl" in
+ Schematron rules is not supported
+ in this processor:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Error: unrecognized element in ISO Schematron namespace: check spelling
+ and capitalization
+
+
+
+
+
+
+
+
+
+
+
+
+ Warning: unrecognized element
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Warning: unrecognized element
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ title
+
+
+
+
+
+
+ schema-title
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl
new file mode 100644
index 0000000000000000000000000000000000000000..dae74ff6a2bd56a4f21147905c3a1661baf0b3ab
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl
@@ -0,0 +1,588 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+true
+
+
+
+
+
+
+
+
+
+
+ #ALL
+
+
+false
+true
+true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xslt1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt
new file mode 100644
index 0000000000000000000000000000000000000000..e5d6dfcd9e9c2787c32d98b0063a1fa1ec3236ad
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt
@@ -0,0 +1,84 @@
+ISO SCHEMATRON 2010
+
+XSLT implementation by Rick Jelliffe with assistance from members of Schematron-love-in maillist.
+
+2010-04-21
+
+Two distributions are available. One is for XSLT1 engines.
+The other is for XSLT2 engines, such as SAXON 9.
+
+
+This version of Schematron splits the process into a pipeline of several different XSLT stages.
+
+1) First, preprocess your Schematron schema with iso_dsdl_include.xsl.
+This is a macro processor to assemble the schema from various parts.
+If your schema is not in separate parts, you can skip this stage.
+This stage also generates error messages for some common XPath syntax problems.
+
+2) Second, preprocess the output from stage 1 with iso_abstract_expand.xsl.
+This is a macro processor to convert abstract patterns to real patterns.
+If your schema does not use abstract patterns, you can skip this
+stage.
+
+3) Third, compile the Schematron schema into an XSLT script.
+This will typically use iso_svrl_for_xslt1.xsl or iso_svrl_for_xslt2.xsl
+(which in turn invoke iso_schematron_skeleton_for_xslt1.xsl or iso_schematron_skeleton_for_saxon.xsl)
+However, other "meta-stylesheets" are also in common use; the principle of operation is the same.
+If your schema uses Schematron phases, supply these as command line/invocation parameters
+to this process.
+
+4) Fourth, run the script generated by stage 3 against the document being validated.
+If you are using the SVRL script, then the output of validation will be an XML document.
+If your schema uses Schematron parameters, supply these as command line/invocation parameters
+to this process.
+
+
+The XSLT2 distribution also features several next generation features,
+such as validating multiple documents. See the source code for details.
+
+Schematron assertions can be written in any language, of course; the file
+sch-messages-en.xhtml contains the diagnostics messages from the XSLT2 skeleton
+in English, and this can be used as template to localize the skeleton's
+error messages. Note that typically programming errors in Schematron are XPath
+errors, which requires localized messages from the XSLT engine.
+
+ANT
+---
+To give an example of how to process a document, here is a sample ANT task.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/iterparse.pxi b/llmeval-env/lib/python3.10/site-packages/lxml/iterparse.pxi
new file mode 100644
index 0000000000000000000000000000000000000000..f569b865ee980c16c7c8a679ae0f5475745817cc
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/iterparse.pxi
@@ -0,0 +1,438 @@
+# iterparse -- event-driven parsing
+
+DEF __ITERPARSE_CHUNK_SIZE = 32768
+
+cdef class iterparse:
+ """iterparse(self, source, events=("end",), tag=None, \
+ attribute_defaults=False, dtd_validation=False, \
+ load_dtd=False, no_network=True, remove_blank_text=False, \
+ remove_comments=False, remove_pis=False, encoding=None, \
+ html=False, recover=None, huge_tree=False, schema=None)
+
+ Incremental parser.
+
+ Parses XML into a tree and generates tuples (event, element) in a
+ SAX-like fashion. ``event`` is any of 'start', 'end', 'start-ns',
+ 'end-ns'.
+
+ For 'start' and 'end', ``element`` is the Element that the parser just
+ found opening or closing. For 'start-ns', it is a tuple (prefix, URI) of
+ a new namespace declaration. For 'end-ns', it is simply None. Note that
+ all start and end events are guaranteed to be properly nested.
+
+ The keyword argument ``events`` specifies a sequence of event type names
+ that should be generated. By default, only 'end' events will be
+ generated.
+
+ The additional ``tag`` argument restricts the 'start' and 'end' events to
+ those elements that match the given tag. The ``tag`` argument can also be
+ a sequence of tags to allow matching more than one tag. By default,
+ events are generated for all elements. Note that the 'start-ns' and
+ 'end-ns' events are not impacted by this restriction.
+
+ The other keyword arguments in the constructor are mainly based on the
+ libxml2 parser configuration. A DTD will also be loaded if validation or
+ attribute default values are requested.
+
+ Available boolean keyword arguments:
+ - attribute_defaults: read default attributes from DTD
+ - dtd_validation: validate (if DTD is available)
+ - load_dtd: use DTD for parsing
+ - no_network: prevent network access for related files
+ - remove_blank_text: discard blank text nodes
+ - remove_comments: discard comments
+ - remove_pis: discard processing instructions
+ - strip_cdata: replace CDATA sections by normal text content (default: True)
+ - compact: safe memory for short text content (default: True)
+ - resolve_entities: replace entities by their text value (default: True)
+ - huge_tree: disable security restrictions and support very deep trees
+ and very long text content (only affects libxml2 2.7+)
+ - html: parse input as HTML (default: XML)
+ - recover: try hard to parse through broken input (default: True for HTML,
+ False otherwise)
+
+ Other keyword arguments:
+ - encoding: override the document encoding
+ - schema: an XMLSchema to validate against
+ """
+ cdef _FeedParser _parser
+ cdef object _tag
+ cdef object _events
+ cdef readonly object root
+ cdef object _source
+ cdef object _filename
+ cdef object _error
+ cdef bint _close_source_after_read
+
+ def __init__(self, source, events=("end",), *, tag=None,
+ attribute_defaults=False, dtd_validation=False,
+ load_dtd=False, no_network=True, remove_blank_text=False,
+ compact=True, resolve_entities=True, remove_comments=False,
+ remove_pis=False, strip_cdata=True, encoding=None,
+ html=False, recover=None, huge_tree=False, collect_ids=True,
+ XMLSchema schema=None):
+ if not hasattr(source, 'read'):
+ source = _getFSPathOrObject(source)
+ self._filename = source
+ self._source = open(source, 'rb')
+ self._close_source_after_read = True
+ else:
+ self._filename = _getFilenameForFile(source)
+ self._source = source
+ self._close_source_after_read = False
+
+ if recover is None:
+ recover = html
+
+ if html:
+ # make sure we're not looking for namespaces
+ events = [event for event in events
+ if event not in ('start-ns', 'end-ns')]
+ parser = HTMLPullParser(
+ events,
+ tag=tag,
+ recover=recover,
+ base_url=self._filename,
+ encoding=encoding,
+ remove_blank_text=remove_blank_text,
+ remove_comments=remove_comments,
+ remove_pis=remove_pis,
+ strip_cdata=strip_cdata,
+ no_network=no_network,
+ target=None, # TODO
+ schema=schema,
+ compact=compact)
+ else:
+ parser = XMLPullParser(
+ events,
+ tag=tag,
+ recover=recover,
+ base_url=self._filename,
+ encoding=encoding,
+ attribute_defaults=attribute_defaults,
+ dtd_validation=dtd_validation,
+ load_dtd=load_dtd,
+ no_network=no_network,
+ schema=schema,
+ huge_tree=huge_tree,
+ remove_blank_text=remove_blank_text,
+ resolve_entities=resolve_entities,
+ remove_comments=remove_comments,
+ remove_pis=remove_pis,
+ strip_cdata=strip_cdata,
+ collect_ids=True,
+ target=None, # TODO
+ compact=compact)
+
+ self._events = parser.read_events()
+ self._parser = parser
+
+ @property
+ def error_log(self):
+ """The error log of the last (or current) parser run.
+ """
+ return self._parser.feed_error_log
+
+ @property
+ def resolvers(self):
+ """The custom resolver registry of the last (or current) parser run.
+ """
+ return self._parser.resolvers
+
+ @property
+ def version(self):
+ """The version of the underlying XML parser."""
+ return self._parser.version
+
+ def set_element_class_lookup(self, ElementClassLookup lookup = None):
+ """set_element_class_lookup(self, lookup = None)
+
+ Set a lookup scheme for element classes generated from this parser.
+
+ Reset it by passing None or nothing.
+ """
+ self._parser.set_element_class_lookup(lookup)
+
+ def makeelement(self, _tag, attrib=None, nsmap=None, **_extra):
+ """makeelement(self, _tag, attrib=None, nsmap=None, **_extra)
+
+ Creates a new element associated with this parser.
+ """
+ self._parser.makeelement(
+ _tag, attrib=None, nsmap=None, **_extra)
+
+ @cython.final
+ cdef _close_source(self):
+ if self._source is None:
+ return
+ if not self._close_source_after_read:
+ self._source = None
+ return
+ try:
+ close = self._source.close
+ except AttributeError:
+ close = None
+ finally:
+ self._source = None
+ if close is not None:
+ close()
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ try:
+ return next(self._events)
+ except StopIteration:
+ pass
+ context = <_SaxParserContext>self._parser._getPushParserContext()
+ if self._source is not None:
+ done = False
+ while not done:
+ try:
+ done = self._read_more_events(context)
+ return next(self._events)
+ except StopIteration:
+ pass # no events yet
+ except Exception as e:
+ self._error = e
+ self._close_source()
+ try:
+ return next(self._events)
+ except StopIteration:
+ break
+ # nothing left to read or return
+ if self._error is not None:
+ error = self._error
+ self._error = None
+ raise error
+ if (context._validator is not None
+ and not context._validator.isvalid()):
+ _raiseParseError(context._c_ctxt, self._filename,
+ context._error_log)
+ # no errors => all done
+ raise StopIteration
+
+ @cython.final
+ cdef bint _read_more_events(self, _SaxParserContext context) except -123:
+ data = self._source.read(__ITERPARSE_CHUNK_SIZE)
+ if not isinstance(data, bytes):
+ self._close_source()
+ raise TypeError("reading file objects must return bytes objects")
+ if not data:
+ try:
+ self.root = self._parser.close()
+ finally:
+ self._close_source()
+ return True
+ self._parser.feed(data)
+ return False
+
+
+cdef enum _IterwalkSkipStates:
+ IWSKIP_NEXT_IS_START
+ IWSKIP_SKIP_NEXT
+ IWSKIP_CAN_SKIP
+ IWSKIP_CANNOT_SKIP
+
+
+cdef class iterwalk:
+ """iterwalk(self, element_or_tree, events=("end",), tag=None)
+
+ A tree walker that generates events from an existing tree as if it
+ was parsing XML data with ``iterparse()``.
+
+ Just as for ``iterparse()``, the ``tag`` argument can be a single tag or a
+ sequence of tags.
+
+ After receiving a 'start' or 'start-ns' event, the children and
+ descendants of the current element can be excluded from iteration
+ by calling the ``skip_subtree()`` method.
+ """
+ cdef _MultiTagMatcher _matcher
+ cdef list _node_stack
+ cdef list _events
+ cdef object _pop_event
+ cdef object _include_siblings
+ cdef int _index
+ cdef int _event_filter
+ cdef _IterwalkSkipStates _skip_state
+
+ def __init__(self, element_or_tree, events=("end",), tag=None):
+ cdef _Element root
+ cdef int ns_count
+ root = _rootNodeOrRaise(element_or_tree)
+ self._event_filter = _buildParseEventFilter(events)
+ if tag is None or tag == '*':
+ self._matcher = None
+ else:
+ self._matcher = _MultiTagMatcher.__new__(_MultiTagMatcher, tag)
+ self._node_stack = []
+ self._events = []
+ self._pop_event = self._events.pop
+ self._skip_state = IWSKIP_CANNOT_SKIP # ignore all skip requests by default
+
+ if self._event_filter:
+ self._index = 0
+ if self._matcher is not None and self._event_filter & PARSE_EVENT_FILTER_START:
+ self._matcher.cacheTags(root._doc)
+
+ # When processing an ElementTree, add events for the preceding comments/PIs.
+ if self._event_filter & (PARSE_EVENT_FILTER_COMMENT | PARSE_EVENT_FILTER_PI):
+ if isinstance(element_or_tree, _ElementTree):
+ self._include_siblings = root
+ for elem in list(root.itersiblings(preceding=True))[::-1]:
+ if self._event_filter & PARSE_EVENT_FILTER_COMMENT and elem.tag is Comment:
+ self._events.append(('comment', elem))
+ elif self._event_filter & PARSE_EVENT_FILTER_PI and elem.tag is PI:
+ self._events.append(('pi', elem))
+
+ ns_count = self._start_node(root)
+ self._node_stack.append( (root, ns_count) )
+ else:
+ self._index = -1
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ cdef xmlNode* c_child
+ cdef _Element node
+ cdef _Element next_node
+ cdef int ns_count = 0
+ if self._events:
+ return self._next_event()
+ if self._matcher is not None and self._index >= 0:
+ node = self._node_stack[self._index][0]
+ self._matcher.cacheTags(node._doc)
+
+ # find next node
+ while self._index >= 0:
+ node = self._node_stack[self._index][0]
+
+ if self._skip_state == IWSKIP_SKIP_NEXT:
+ c_child = NULL
+ else:
+ c_child = self._process_non_elements(
+ node._doc, _findChildForwards(node._c_node, 0))
+ self._skip_state = IWSKIP_CANNOT_SKIP
+
+ while c_child is NULL:
+ # back off through parents
+ self._index -= 1
+ node = self._end_node()
+ if self._index < 0:
+ break
+ c_child = self._process_non_elements(
+ node._doc, _nextElement(node._c_node))
+
+ if c_child is not NULL:
+ next_node = _elementFactory(node._doc, c_child)
+ if self._event_filter & (PARSE_EVENT_FILTER_START |
+ PARSE_EVENT_FILTER_START_NS):
+ ns_count = self._start_node(next_node)
+ elif self._event_filter & PARSE_EVENT_FILTER_END_NS:
+ ns_count = _countNsDefs(next_node._c_node)
+ self._node_stack.append( (next_node, ns_count) )
+ self._index += 1
+ if self._events:
+ return self._next_event()
+
+ if self._include_siblings is not None:
+ node, self._include_siblings = self._include_siblings, None
+ self._process_non_elements(node._doc, _nextElement(node._c_node))
+ if self._events:
+ return self._next_event()
+
+ raise StopIteration
+
+ @cython.final
+ cdef xmlNode* _process_non_elements(self, _Document doc, xmlNode* c_node):
+ while c_node is not NULL and c_node.type != tree.XML_ELEMENT_NODE:
+ if c_node.type == tree.XML_COMMENT_NODE:
+ if self._event_filter & PARSE_EVENT_FILTER_COMMENT:
+ self._events.append(
+ ("comment", _elementFactory(doc, c_node)))
+ c_node = _nextElement(c_node)
+ elif c_node.type == tree.XML_PI_NODE:
+ if self._event_filter & PARSE_EVENT_FILTER_PI:
+ self._events.append(
+ ("pi", _elementFactory(doc, c_node)))
+ c_node = _nextElement(c_node)
+ else:
+ break
+ return c_node
+
+ @cython.final
+ cdef _next_event(self):
+ if self._skip_state == IWSKIP_NEXT_IS_START:
+ if self._events[0][0] in ('start', 'start-ns'):
+ self._skip_state = IWSKIP_CAN_SKIP
+ return self._pop_event(0)
+
+ def skip_subtree(self):
+ """Prevent descending into the current subtree.
+ Instead, the next returned event will be the 'end' event of the current element
+ (if included), ignoring any children or descendants.
+
+ This has no effect right after an 'end' or 'end-ns' event.
+ """
+ if self._skip_state == IWSKIP_CAN_SKIP:
+ self._skip_state = IWSKIP_SKIP_NEXT
+
+ @cython.final
+ cdef int _start_node(self, _Element node) except -1:
+ cdef int ns_count
+ if self._event_filter & PARSE_EVENT_FILTER_START_NS:
+ ns_count = _appendStartNsEvents(node._c_node, self._events)
+ if self._events:
+ self._skip_state = IWSKIP_NEXT_IS_START
+ elif self._event_filter & PARSE_EVENT_FILTER_END_NS:
+ ns_count = _countNsDefs(node._c_node)
+ else:
+ ns_count = 0
+ if self._event_filter & PARSE_EVENT_FILTER_START:
+ if self._matcher is None or self._matcher.matches(node._c_node):
+ self._events.append( ("start", node) )
+ self._skip_state = IWSKIP_NEXT_IS_START
+ return ns_count
+
+ @cython.final
+ cdef _Element _end_node(self):
+ cdef _Element node
+ cdef int i, ns_count
+ node, ns_count = self._node_stack.pop()
+ if self._event_filter & PARSE_EVENT_FILTER_END:
+ if self._matcher is None or self._matcher.matches(node._c_node):
+ self._events.append( ("end", node) )
+ if self._event_filter & PARSE_EVENT_FILTER_END_NS and ns_count:
+ event = ("end-ns", None)
+ for i in range(ns_count):
+ self._events.append(event)
+ return node
+
+
+cdef int _countNsDefs(xmlNode* c_node) noexcept:
+ cdef xmlNs* c_ns
+ cdef int count
+ count = 0
+ c_ns = c_node.nsDef
+ while c_ns is not NULL:
+ count += (c_ns.href is not NULL)
+ c_ns = c_ns.next
+ return count
+
+
+cdef int _appendStartNsEvents(xmlNode* c_node, list event_list) except -1:
+ cdef xmlNs* c_ns
+ cdef int count
+ count = 0
+ c_ns = c_node.nsDef
+ while c_ns is not NULL:
+ if c_ns.href:
+ ns_tuple = (funicodeOrEmpty(c_ns.prefix),
+ funicode(c_ns.href))
+ event_list.append( ("start-ns", ns_tuple) )
+ count += 1
+ c_ns = c_ns.next
+ return count
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/lxml.etree_api.h b/llmeval-env/lib/python3.10/site-packages/lxml/lxml.etree_api.h
new file mode 100644
index 0000000000000000000000000000000000000000..5efcb431f45d1cb937ce5a9fbf047b6e339fd72d
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/lxml.etree_api.h
@@ -0,0 +1,195 @@
+/* Generated by Cython 3.0.10 */
+
+#ifndef __PYX_HAVE_API__lxml__etree
+#define __PYX_HAVE_API__lxml__etree
+#ifdef __MINGW64__
+#define MS_WIN64
+#endif
+#include "Python.h"
+#include "lxml.etree.h"
+
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument)(struct LxmlDocument *, xmlNode *) = 0;
+#define deepcopyNodeToDocument __pyx_api_f_4lxml_5etree_deepcopyNodeToDocument
+static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_elementTreeFactory)(struct LxmlElement *) = 0;
+#define elementTreeFactory __pyx_api_f_4lxml_5etree_elementTreeFactory
+static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_newElementTree)(struct LxmlElement *, PyObject *) = 0;
+#define newElementTree __pyx_api_f_4lxml_5etree_newElementTree
+static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_adoptExternalDocument)(xmlDoc *, PyObject *, int) = 0;
+#define adoptExternalDocument __pyx_api_f_4lxml_5etree_adoptExternalDocument
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_elementFactory)(struct LxmlDocument *, xmlNode *) = 0;
+#define elementFactory __pyx_api_f_4lxml_5etree_elementFactory
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_makeElement)(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *) = 0;
+#define makeElement __pyx_api_f_4lxml_5etree_makeElement
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_makeSubElement)(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *) = 0;
+#define makeSubElement __pyx_api_f_4lxml_5etree_makeSubElement
+static void (*__pyx_api_f_4lxml_5etree_setElementClassLookupFunction)(_element_class_lookup_function, PyObject *) = 0;
+#define setElementClassLookupFunction __pyx_api_f_4lxml_5etree_setElementClassLookupFunction
+static PyObject *(*__pyx_api_f_4lxml_5etree_lookupDefaultElementClass)(PyObject *, PyObject *, xmlNode *) = 0;
+#define lookupDefaultElementClass __pyx_api_f_4lxml_5etree_lookupDefaultElementClass
+static PyObject *(*__pyx_api_f_4lxml_5etree_lookupNamespaceElementClass)(PyObject *, PyObject *, xmlNode *) = 0;
+#define lookupNamespaceElementClass __pyx_api_f_4lxml_5etree_lookupNamespaceElementClass
+static PyObject *(*__pyx_api_f_4lxml_5etree_callLookupFallback)(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *) = 0;
+#define callLookupFallback __pyx_api_f_4lxml_5etree_callLookupFallback
+static int (*__pyx_api_f_4lxml_5etree_tagMatches)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
+#define tagMatches __pyx_api_f_4lxml_5etree_tagMatches
+static struct LxmlDocument *(*__pyx_api_f_4lxml_5etree_documentOrRaise)(PyObject *) = 0;
+#define documentOrRaise __pyx_api_f_4lxml_5etree_documentOrRaise
+static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_rootNodeOrRaise)(PyObject *) = 0;
+#define rootNodeOrRaise __pyx_api_f_4lxml_5etree_rootNodeOrRaise
+static int (*__pyx_api_f_4lxml_5etree_hasText)(xmlNode *) = 0;
+#define hasText __pyx_api_f_4lxml_5etree_hasText
+static int (*__pyx_api_f_4lxml_5etree_hasTail)(xmlNode *) = 0;
+#define hasTail __pyx_api_f_4lxml_5etree_hasTail
+static PyObject *(*__pyx_api_f_4lxml_5etree_textOf)(xmlNode *) = 0;
+#define textOf __pyx_api_f_4lxml_5etree_textOf
+static PyObject *(*__pyx_api_f_4lxml_5etree_tailOf)(xmlNode *) = 0;
+#define tailOf __pyx_api_f_4lxml_5etree_tailOf
+static int (*__pyx_api_f_4lxml_5etree_setNodeText)(xmlNode *, PyObject *) = 0;
+#define setNodeText __pyx_api_f_4lxml_5etree_setNodeText
+static int (*__pyx_api_f_4lxml_5etree_setTailText)(xmlNode *, PyObject *) = 0;
+#define setTailText __pyx_api_f_4lxml_5etree_setTailText
+static PyObject *(*__pyx_api_f_4lxml_5etree_attributeValue)(xmlNode *, xmlAttr *) = 0;
+#define attributeValue __pyx_api_f_4lxml_5etree_attributeValue
+static PyObject *(*__pyx_api_f_4lxml_5etree_attributeValueFromNsName)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
+#define attributeValueFromNsName __pyx_api_f_4lxml_5etree_attributeValueFromNsName
+static PyObject *(*__pyx_api_f_4lxml_5etree_getAttributeValue)(struct LxmlElement *, PyObject *, PyObject *) = 0;
+#define getAttributeValue __pyx_api_f_4lxml_5etree_getAttributeValue
+static PyObject *(*__pyx_api_f_4lxml_5etree_iterattributes)(struct LxmlElement *, int) = 0;
+#define iterattributes __pyx_api_f_4lxml_5etree_iterattributes
+static PyObject *(*__pyx_api_f_4lxml_5etree_collectAttributes)(xmlNode *, int) = 0;
+#define collectAttributes __pyx_api_f_4lxml_5etree_collectAttributes
+static int (*__pyx_api_f_4lxml_5etree_setAttributeValue)(struct LxmlElement *, PyObject *, PyObject *) = 0;
+#define setAttributeValue __pyx_api_f_4lxml_5etree_setAttributeValue
+static int (*__pyx_api_f_4lxml_5etree_delAttribute)(struct LxmlElement *, PyObject *) = 0;
+#define delAttribute __pyx_api_f_4lxml_5etree_delAttribute
+static int (*__pyx_api_f_4lxml_5etree_delAttributeFromNsName)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
+#define delAttributeFromNsName __pyx_api_f_4lxml_5etree_delAttributeFromNsName
+static int (*__pyx_api_f_4lxml_5etree_hasChild)(xmlNode *) = 0;
+#define hasChild __pyx_api_f_4lxml_5etree_hasChild
+static xmlNode *(*__pyx_api_f_4lxml_5etree_findChild)(xmlNode *, Py_ssize_t) = 0;
+#define findChild __pyx_api_f_4lxml_5etree_findChild
+static xmlNode *(*__pyx_api_f_4lxml_5etree_findChildForwards)(xmlNode *, Py_ssize_t) = 0;
+#define findChildForwards __pyx_api_f_4lxml_5etree_findChildForwards
+static xmlNode *(*__pyx_api_f_4lxml_5etree_findChildBackwards)(xmlNode *, Py_ssize_t) = 0;
+#define findChildBackwards __pyx_api_f_4lxml_5etree_findChildBackwards
+static xmlNode *(*__pyx_api_f_4lxml_5etree_nextElement)(xmlNode *) = 0;
+#define nextElement __pyx_api_f_4lxml_5etree_nextElement
+static xmlNode *(*__pyx_api_f_4lxml_5etree_previousElement)(xmlNode *) = 0;
+#define previousElement __pyx_api_f_4lxml_5etree_previousElement
+static void (*__pyx_api_f_4lxml_5etree_appendChild)(struct LxmlElement *, struct LxmlElement *) = 0;
+#define appendChild __pyx_api_f_4lxml_5etree_appendChild
+static int (*__pyx_api_f_4lxml_5etree_appendChildToElement)(struct LxmlElement *, struct LxmlElement *) = 0;
+#define appendChildToElement __pyx_api_f_4lxml_5etree_appendChildToElement
+static PyObject *(*__pyx_api_f_4lxml_5etree_pyunicode)(const xmlChar *) = 0;
+#define pyunicode __pyx_api_f_4lxml_5etree_pyunicode
+static PyObject *(*__pyx_api_f_4lxml_5etree_utf8)(PyObject *) = 0;
+#define utf8 __pyx_api_f_4lxml_5etree_utf8
+static PyObject *(*__pyx_api_f_4lxml_5etree_getNsTag)(PyObject *) = 0;
+#define getNsTag __pyx_api_f_4lxml_5etree_getNsTag
+static PyObject *(*__pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs)(PyObject *) = 0;
+#define getNsTagWithEmptyNs __pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs
+static PyObject *(*__pyx_api_f_4lxml_5etree_namespacedName)(xmlNode *) = 0;
+#define namespacedName __pyx_api_f_4lxml_5etree_namespacedName
+static PyObject *(*__pyx_api_f_4lxml_5etree_namespacedNameFromNsName)(const xmlChar *, const xmlChar *) = 0;
+#define namespacedNameFromNsName __pyx_api_f_4lxml_5etree_namespacedNameFromNsName
+static void (*__pyx_api_f_4lxml_5etree_iteratorStoreNext)(struct LxmlElementIterator *, struct LxmlElement *) = 0;
+#define iteratorStoreNext __pyx_api_f_4lxml_5etree_iteratorStoreNext
+static void (*__pyx_api_f_4lxml_5etree_initTagMatch)(struct LxmlElementTagMatcher *, PyObject *) = 0;
+#define initTagMatch __pyx_api_f_4lxml_5etree_initTagMatch
+static xmlNs *(*__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix)(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *) = 0;
+#define findOrBuildNodeNsPrefix __pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix
+#ifndef __PYX_HAVE_RT_ImportFunction_3_0_10
+#define __PYX_HAVE_RT_ImportFunction_3_0_10
+static int __Pyx_ImportFunction_3_0_10(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
+ PyObject *d = 0;
+ PyObject *cobj = 0;
+ union {
+ void (*fp)(void);
+ void *p;
+ } tmp;
+ d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
+ if (!d)
+ goto bad;
+ cobj = PyDict_GetItemString(d, funcname);
+ if (!cobj) {
+ PyErr_Format(PyExc_ImportError,
+ "%.200s does not export expected C function %.200s",
+ PyModule_GetName(module), funcname);
+ goto bad;
+ }
+ if (!PyCapsule_IsValid(cobj, sig)) {
+ PyErr_Format(PyExc_TypeError,
+ "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
+ PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
+ goto bad;
+ }
+ tmp.p = PyCapsule_GetPointer(cobj, sig);
+ *f = tmp.fp;
+ if (!(*f))
+ goto bad;
+ Py_DECREF(d);
+ return 0;
+bad:
+ Py_XDECREF(d);
+ return -1;
+}
+#endif
+
+
+static int import_lxml__etree(void) {
+ PyObject *module = 0;
+ module = PyImport_ImportModule("lxml.etree");
+ if (!module) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "deepcopyNodeToDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "elementTreeFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementTreeFactory, "struct LxmlElementTree *(struct LxmlElement *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "newElementTree", (void (**)(void))&__pyx_api_f_4lxml_5etree_newElementTree, "struct LxmlElementTree *(struct LxmlElement *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "adoptExternalDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_adoptExternalDocument, "struct LxmlElementTree *(xmlDoc *, PyObject *, int)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "elementFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementFactory, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "makeElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_makeElement, "struct LxmlElement *(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "makeSubElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_makeSubElement, "struct LxmlElement *(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "setElementClassLookupFunction", (void (**)(void))&__pyx_api_f_4lxml_5etree_setElementClassLookupFunction, "void (_element_class_lookup_function, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "lookupDefaultElementClass", (void (**)(void))&__pyx_api_f_4lxml_5etree_lookupDefaultElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "lookupNamespaceElementClass", (void (**)(void))&__pyx_api_f_4lxml_5etree_lookupNamespaceElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "callLookupFallback", (void (**)(void))&__pyx_api_f_4lxml_5etree_callLookupFallback, "PyObject *(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "tagMatches", (void (**)(void))&__pyx_api_f_4lxml_5etree_tagMatches, "int (xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "documentOrRaise", (void (**)(void))&__pyx_api_f_4lxml_5etree_documentOrRaise, "struct LxmlDocument *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "rootNodeOrRaise", (void (**)(void))&__pyx_api_f_4lxml_5etree_rootNodeOrRaise, "struct LxmlElement *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "hasText", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasText, "int (xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "hasTail", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasTail, "int (xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "textOf", (void (**)(void))&__pyx_api_f_4lxml_5etree_textOf, "PyObject *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "tailOf", (void (**)(void))&__pyx_api_f_4lxml_5etree_tailOf, "PyObject *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "setNodeText", (void (**)(void))&__pyx_api_f_4lxml_5etree_setNodeText, "int (xmlNode *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "setTailText", (void (**)(void))&__pyx_api_f_4lxml_5etree_setTailText, "int (xmlNode *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "attributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_attributeValue, "PyObject *(xmlNode *, xmlAttr *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "attributeValueFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_attributeValueFromNsName, "PyObject *(xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "getAttributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_getAttributeValue, "PyObject *(struct LxmlElement *, PyObject *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "iterattributes", (void (**)(void))&__pyx_api_f_4lxml_5etree_iterattributes, "PyObject *(struct LxmlElement *, int)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "collectAttributes", (void (**)(void))&__pyx_api_f_4lxml_5etree_collectAttributes, "PyObject *(xmlNode *, int)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "setAttributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_setAttributeValue, "int (struct LxmlElement *, PyObject *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "delAttribute", (void (**)(void))&__pyx_api_f_4lxml_5etree_delAttribute, "int (struct LxmlElement *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "delAttributeFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_delAttributeFromNsName, "int (xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "hasChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasChild, "int (xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "findChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChild, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "findChildForwards", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChildForwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "findChildBackwards", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChildBackwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "nextElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_nextElement, "xmlNode *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "previousElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_previousElement, "xmlNode *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "appendChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_appendChild, "void (struct LxmlElement *, struct LxmlElement *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "appendChildToElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_appendChildToElement, "int (struct LxmlElement *, struct LxmlElement *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "pyunicode", (void (**)(void))&__pyx_api_f_4lxml_5etree_pyunicode, "PyObject *(const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "utf8", (void (**)(void))&__pyx_api_f_4lxml_5etree_utf8, "PyObject *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "getNsTag", (void (**)(void))&__pyx_api_f_4lxml_5etree_getNsTag, "PyObject *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "getNsTagWithEmptyNs", (void (**)(void))&__pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs, "PyObject *(PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "namespacedName", (void (**)(void))&__pyx_api_f_4lxml_5etree_namespacedName, "PyObject *(xmlNode *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "namespacedNameFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_namespacedNameFromNsName, "PyObject *(const xmlChar *, const xmlChar *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "iteratorStoreNext", (void (**)(void))&__pyx_api_f_4lxml_5etree_iteratorStoreNext, "void (struct LxmlElementIterator *, struct LxmlElement *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "initTagMatch", (void (**)(void))&__pyx_api_f_4lxml_5etree_initTagMatch, "void (struct LxmlElementTagMatcher *, PyObject *)") < 0) goto bad;
+ if (__Pyx_ImportFunction_3_0_10(module, "findOrBuildNodeNsPrefix", (void (**)(void))&__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix, "xmlNs *(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
+ Py_DECREF(module); module = 0;
+ return 0;
+ bad:
+ Py_XDECREF(module);
+ return -1;
+}
+
+#endif /* !__PYX_HAVE_API__lxml__etree */
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/objectify.pyx b/llmeval-env/lib/python3.10/site-packages/lxml/objectify.pyx
new file mode 100644
index 0000000000000000000000000000000000000000..0ff922262ed55ef2d04bdea0f196bd724b736550
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/objectify.pyx
@@ -0,0 +1,2145 @@
+# cython: binding=True
+# cython: auto_pickle=False
+# cython: language_level=3
+
+"""
+The ``lxml.objectify`` module implements a Python object API for XML.
+It is based on `lxml.etree`.
+"""
+
+cimport cython
+
+from lxml.includes.etreepublic cimport _Document, _Element, ElementBase, ElementClassLookup
+from lxml.includes.etreepublic cimport elementFactory, import_lxml__etree, textOf, pyunicode
+from lxml.includes.tree cimport const_xmlChar, _xcstr
+from lxml cimport python
+from lxml.includes cimport tree
+
+cimport lxml.includes.etreepublic as cetree
+cimport libc.string as cstring_h # not to be confused with stdlib 'string'
+from libc.string cimport const_char
+
+__all__ = ['BoolElement', 'DataElement', 'E', 'Element', 'ElementMaker',
+ 'FloatElement', 'IntElement', 'NoneElement',
+ 'NumberElement', 'ObjectPath', 'ObjectifiedDataElement',
+ 'ObjectifiedElement', 'ObjectifyElementClassLookup',
+ 'PYTYPE_ATTRIBUTE', 'PyType', 'StringElement', 'SubElement',
+ 'XML', 'annotate', 'deannotate', 'dump', 'enable_recursive_str',
+ 'fromstring', 'getRegisteredTypes', 'makeparser', 'parse',
+ 'pyannotate', 'pytypename', 'set_default_parser',
+ 'set_pytype_attribute_tag', 'xsiannotate']
+
+cdef object etree
+from lxml import etree
+# initialize C-API of lxml.etree
+import_lxml__etree()
+
+__version__ = etree.__version__
+
+cdef object _float_is_inf, _float_is_nan
+from math import isinf as _float_is_inf, isnan as _float_is_nan
+
+cdef object re
+import re
+
+cdef tuple IGNORABLE_ERRORS = (ValueError, TypeError)
+cdef object is_special_method = re.compile('__.*__$').match
+
+
+cdef object _typename(object t):
+ cdef const_char* c_name
+ c_name = python._fqtypename(t)
+ s = cstring_h.strrchr(c_name, c'.')
+ if s is not NULL:
+ c_name = s + 1
+ return pyunicode(c_name)
+
+
+# namespace/name for "pytype" hint attribute
+cdef object PYTYPE_NAMESPACE
+cdef bytes PYTYPE_NAMESPACE_UTF8
+cdef const_xmlChar* _PYTYPE_NAMESPACE
+
+cdef object PYTYPE_ATTRIBUTE_NAME
+cdef bytes PYTYPE_ATTRIBUTE_NAME_UTF8
+cdef const_xmlChar* _PYTYPE_ATTRIBUTE_NAME
+
+PYTYPE_ATTRIBUTE = None
+
+cdef unicode TREE_PYTYPE_NAME = "TREE"
+
+cdef tuple _unicodeAndUtf8(s):
+ return s, python.PyUnicode_AsUTF8String(s)
+
+def set_pytype_attribute_tag(attribute_tag=None):
+ """set_pytype_attribute_tag(attribute_tag=None)
+ Change name and namespace of the XML attribute that holds Python type
+ information.
+
+ Do not use this unless you know what you are doing.
+
+ Reset by calling without argument.
+
+ Default: "{http://codespeak.net/lxml/objectify/pytype}pytype"
+ """
+ global PYTYPE_ATTRIBUTE, _PYTYPE_NAMESPACE, _PYTYPE_ATTRIBUTE_NAME
+ global PYTYPE_NAMESPACE, PYTYPE_NAMESPACE_UTF8
+ global PYTYPE_ATTRIBUTE_NAME, PYTYPE_ATTRIBUTE_NAME_UTF8
+ if attribute_tag is None:
+ PYTYPE_NAMESPACE, PYTYPE_NAMESPACE_UTF8 = \
+ _unicodeAndUtf8("http://codespeak.net/lxml/objectify/pytype")
+ PYTYPE_ATTRIBUTE_NAME, PYTYPE_ATTRIBUTE_NAME_UTF8 = \
+ _unicodeAndUtf8("pytype")
+ else:
+ PYTYPE_NAMESPACE_UTF8, PYTYPE_ATTRIBUTE_NAME_UTF8 = \
+ cetree.getNsTag(attribute_tag)
+ PYTYPE_NAMESPACE = PYTYPE_NAMESPACE_UTF8.decode('utf8')
+ PYTYPE_ATTRIBUTE_NAME = PYTYPE_ATTRIBUTE_NAME_UTF8.decode('utf8')
+
+ _PYTYPE_NAMESPACE = PYTYPE_NAMESPACE_UTF8
+ _PYTYPE_ATTRIBUTE_NAME = PYTYPE_ATTRIBUTE_NAME_UTF8
+ PYTYPE_ATTRIBUTE = cetree.namespacedNameFromNsName(
+ _PYTYPE_NAMESPACE, _PYTYPE_ATTRIBUTE_NAME)
+
+set_pytype_attribute_tag()
+
+
+# namespaces for XML Schema
+cdef object XML_SCHEMA_NS, XML_SCHEMA_NS_UTF8
+XML_SCHEMA_NS, XML_SCHEMA_NS_UTF8 = \
+ _unicodeAndUtf8("http://www.w3.org/2001/XMLSchema")
+cdef const_xmlChar* _XML_SCHEMA_NS = _xcstr(XML_SCHEMA_NS_UTF8)
+
+cdef object XML_SCHEMA_INSTANCE_NS, XML_SCHEMA_INSTANCE_NS_UTF8
+XML_SCHEMA_INSTANCE_NS, XML_SCHEMA_INSTANCE_NS_UTF8 = \
+ _unicodeAndUtf8("http://www.w3.org/2001/XMLSchema-instance")
+cdef const_xmlChar* _XML_SCHEMA_INSTANCE_NS = _xcstr(XML_SCHEMA_INSTANCE_NS_UTF8)
+
+cdef object XML_SCHEMA_INSTANCE_NIL_ATTR = "{%s}nil" % XML_SCHEMA_INSTANCE_NS
+cdef object XML_SCHEMA_INSTANCE_TYPE_ATTR = "{%s}type" % XML_SCHEMA_INSTANCE_NS
+
+
+################################################################################
+# Element class for the main API
+
+cdef class ObjectifiedElement(ElementBase):
+ """Main XML Element class.
+
+ Element children are accessed as object attributes. Multiple children
+ with the same name are available through a list index. Example::
+
+ >>> root = XML("01")
+ >>> second_c2 = root.c1.c2[1]
+ >>> print(second_c2.text)
+ 1
+
+ Note that you cannot (and must not) instantiate this class or its
+ subclasses.
+ """
+ def __iter__(self):
+ """Iterate over self and all siblings with the same tag.
+ """
+ parent = self.getparent()
+ if parent is None:
+ return iter([self])
+ return etree.ElementChildIterator(parent, tag=self.tag)
+
+ def __str__(self):
+ if __RECURSIVE_STR:
+ return _dump(self, 0)
+ else:
+ return textOf(self._c_node) or ''
+
+ # pickle support for objectified Element
+ def __reduce__(self):
+ return fromstring, (etree.tostring(self),)
+
+ @property
+ def text(self):
+ return textOf(self._c_node)
+
+ @property
+ def __dict__(self):
+ """A fake implementation for __dict__ to support dir() etc.
+
+ Note that this only considers the first child with a given name.
+ """
+ cdef _Element child
+ cdef dict children
+ c_ns = tree._getNs(self._c_node)
+ tag = "{%s}*" % pyunicode(c_ns) if c_ns is not NULL else None
+ children = {}
+ for child in etree.ElementChildIterator(self, tag=tag):
+ if c_ns is NULL and tree._getNs(child._c_node) is not NULL:
+ continue
+ name = pyunicode(child._c_node.name)
+ if name not in children:
+ children[name] = child
+ return children
+
+ def __len__(self):
+ """Count self and siblings with the same tag.
+ """
+ return _countSiblings(self._c_node)
+
+ def countchildren(self):
+ """countchildren(self)
+
+ Return the number of children of this element, regardless of their
+ name.
+ """
+ # copied from etree
+ cdef Py_ssize_t c
+ cdef tree.xmlNode* c_node
+ c = 0
+ c_node = self._c_node.children
+ while c_node is not NULL:
+ if tree._isElement(c_node):
+ c += 1
+ c_node = c_node.next
+ return c
+
+ def getchildren(self):
+ """getchildren(self)
+
+ Returns a sequence of all direct children. The elements are
+ returned in document order.
+ """
+ cdef tree.xmlNode* c_node
+ result = []
+ c_node = self._c_node.children
+ while c_node is not NULL:
+ if tree._isElement(c_node):
+ result.append(cetree.elementFactory(self._doc, c_node))
+ c_node = c_node.next
+ return result
+
+ def __getattr__(self, tag):
+ """Return the (first) child with the given tag name. If no namespace
+ is provided, the child will be looked up in the same one as self.
+ """
+ return _lookupChildOrRaise(self, tag)
+
+ def __setattr__(self, tag, value):
+ """Set the value of the (first) child with the given tag name. If no
+ namespace is provided, the child will be looked up in the same one as
+ self.
+ """
+ cdef _Element element
+ # properties are looked up /after/ __setattr__, so we must emulate them
+ if tag == 'text' or tag == 'pyval':
+ # read-only !
+ raise TypeError, f"attribute '{tag}' of '{_typename(self)}' objects is not writable"
+ elif tag == 'tail':
+ cetree.setTailText(self._c_node, value)
+ return
+ elif tag == 'tag':
+ ElementBase.tag.__set__(self, value)
+ return
+ elif tag == 'base':
+ ElementBase.base.__set__(self, value)
+ return
+ tag = _buildChildTag(self, tag)
+ element = _lookupChild(self, tag)
+ if element is None:
+ _appendValue(self, tag, value)
+ else:
+ _replaceElement(element, value)
+
+ def __delattr__(self, tag):
+ child = _lookupChildOrRaise(self, tag)
+ self.remove(child)
+
+ def addattr(self, tag, value):
+ """addattr(self, tag, value)
+
+ Add a child value to the element.
+
+ As opposed to append(), it sets a data value, not an element.
+ """
+ _appendValue(self, _buildChildTag(self, tag), value)
+
+ def __getitem__(self, key):
+ """Return a sibling, counting from the first child of the parent. The
+ method behaves like both a dict and a sequence.
+
+ * If argument is an integer, returns the sibling at that position.
+
+ * If argument is a string, does the same as getattr(). This can be
+ used to provide namespaces for element lookup, or to look up
+ children with special names (``text`` etc.).
+
+ * If argument is a slice object, returns the matching slice.
+ """
+ cdef tree.xmlNode* c_self_node
+ cdef tree.xmlNode* c_parent
+ cdef tree.xmlNode* c_node
+ cdef Py_ssize_t c_index
+ if python._isString(key):
+ return _lookupChildOrRaise(self, key)
+ elif isinstance(key, slice):
+ return list(self)[key]
+ # normal item access
+ c_index = key # raises TypeError if necessary
+ c_self_node = self._c_node
+ c_parent = c_self_node.parent
+ if c_parent is NULL:
+ if c_index == 0 or c_index == -1:
+ return self
+ raise IndexError, unicode(key)
+ if c_index < 0:
+ c_node = c_parent.last
+ else:
+ c_node = c_parent.children
+ c_node = _findFollowingSibling(
+ c_node, tree._getNs(c_self_node), c_self_node.name, c_index)
+ if c_node is NULL:
+ raise IndexError, unicode(key)
+ return elementFactory(self._doc, c_node)
+
+ def __setitem__(self, key, value):
+ """Set the value of a sibling, counting from the first child of the
+ parent. Implements key assignment, item assignment and slice
+ assignment.
+
+ * If argument is an integer, sets the sibling at that position.
+
+ * If argument is a string, does the same as setattr(). This is used
+ to provide namespaces for element lookup.
+
+ * If argument is a sequence (list, tuple, etc.), assign the contained
+ items to the siblings.
+ """
+ cdef _Element element
+ cdef tree.xmlNode* c_node
+ if python._isString(key):
+ key = _buildChildTag(self, key)
+ element = _lookupChild(self, key)
+ if element is None:
+ _appendValue(self, key, value)
+ else:
+ _replaceElement(element, value)
+ return
+
+ if self._c_node.parent is NULL:
+ # the 'root[i] = ...' case
+ raise TypeError, "assignment to root element is invalid"
+
+ if isinstance(key, slice):
+ # slice assignment
+ _setSlice(key, self, value)
+ else:
+ # normal index assignment
+ if key < 0:
+ c_node = self._c_node.parent.last
+ else:
+ c_node = self._c_node.parent.children
+ c_node = _findFollowingSibling(
+ c_node, tree._getNs(self._c_node), self._c_node.name, key)
+ if c_node is NULL:
+ raise IndexError, unicode(key)
+ element = elementFactory(self._doc, c_node)
+ _replaceElement(element, value)
+
+ def __delitem__(self, key):
+ parent = self.getparent()
+ if parent is None:
+ raise TypeError, "deleting items not supported by root element"
+ if isinstance(key, slice):
+ # slice deletion
+ del_items = list(self)[key]
+ remove = parent.remove
+ for el in del_items:
+ remove(el)
+ else:
+ # normal index deletion
+ sibling = self.__getitem__(key)
+ parent.remove(sibling)
+
+ def descendantpaths(self, prefix=None):
+ """descendantpaths(self, prefix=None)
+
+ Returns a list of object path expressions for all descendants.
+ """
+ if prefix is not None and not python._isString(prefix):
+ prefix = '.'.join(prefix)
+ return _build_descendant_paths(self._c_node, prefix)
+
+
+cdef inline bint _tagMatches(tree.xmlNode* c_node, const_xmlChar* c_href, const_xmlChar* c_name):
+ if c_node.name != c_name:
+ return 0
+ if c_href == NULL:
+ return 1
+ c_node_href = tree._getNs(c_node)
+ if c_node_href == NULL:
+ return c_href[0] == c'\0'
+ return tree.xmlStrcmp(c_node_href, c_href) == 0
+
+
+cdef Py_ssize_t _countSiblings(tree.xmlNode* c_start_node):
+ cdef tree.xmlNode* c_node
+ cdef Py_ssize_t count
+ c_tag = c_start_node.name
+ c_href = tree._getNs(c_start_node)
+ count = 1
+ c_node = c_start_node.next
+ while c_node is not NULL:
+ if c_node.type == tree.XML_ELEMENT_NODE and \
+ _tagMatches(c_node, c_href, c_tag):
+ count += 1
+ c_node = c_node.next
+ c_node = c_start_node.prev
+ while c_node is not NULL:
+ if c_node.type == tree.XML_ELEMENT_NODE and \
+ _tagMatches(c_node, c_href, c_tag):
+ count += 1
+ c_node = c_node.prev
+ return count
+
+cdef tree.xmlNode* _findFollowingSibling(tree.xmlNode* c_node,
+ const_xmlChar* href, const_xmlChar* name,
+ Py_ssize_t index):
+ cdef tree.xmlNode* (*next)(tree.xmlNode*)
+ if index >= 0:
+ next = cetree.nextElement
+ else:
+ index = -1 - index
+ next = cetree.previousElement
+ while c_node is not NULL:
+ if c_node.type == tree.XML_ELEMENT_NODE and \
+ _tagMatches(c_node, href, name):
+ index = index - 1
+ if index < 0:
+ return c_node
+ c_node = next(c_node)
+ return NULL
+
+cdef object _lookupChild(_Element parent, tag):
+ cdef tree.xmlNode* c_result
+ cdef tree.xmlNode* c_node
+ c_node = parent._c_node
+ ns, tag = cetree.getNsTagWithEmptyNs(tag)
+ c_tag = tree.xmlDictExists(
+ c_node.doc.dict, _xcstr(tag), python.PyBytes_GET_SIZE(tag))
+ if c_tag is NULL:
+ return None # not in the hash map => not in the tree
+ if ns is None:
+ # either inherit ns from parent or use empty (i.e. no) namespace
+ c_href = tree._getNs(c_node) or ''
+ else:
+ c_href = _xcstr(ns)
+ c_result = _findFollowingSibling(c_node.children, c_href, c_tag, 0)
+ if c_result is NULL:
+ return None
+ return elementFactory(parent._doc, c_result)
+
+cdef object _lookupChildOrRaise(_Element parent, tag):
+ element = _lookupChild(parent, tag)
+ if element is None:
+ raise AttributeError, "no such child: " + _buildChildTag(parent, tag)
+ return element
+
+cdef object _buildChildTag(_Element parent, tag):
+ ns, tag = cetree.getNsTag(tag)
+ c_tag = _xcstr(tag)
+ c_href = tree._getNs(parent._c_node) if ns is None else _xcstr(ns)
+ return cetree.namespacedNameFromNsName(c_href, c_tag)
+
+cdef _replaceElement(_Element element, value):
+ cdef _Element new_element
+ if isinstance(value, _Element):
+ # deep copy the new element
+ new_element = cetree.deepcopyNodeToDocument(
+ element._doc, (<_Element>value)._c_node)
+ new_element.tag = element.tag
+ elif isinstance(value, (list, tuple)):
+ element[:] = value
+ return
+ else:
+ new_element = element.makeelement(element.tag)
+ _setElementValue(new_element, value)
+ element.getparent().replace(element, new_element)
+
+cdef _appendValue(_Element parent, tag, value):
+ cdef _Element new_element
+ if isinstance(value, _Element):
+ # deep copy the new element
+ new_element = cetree.deepcopyNodeToDocument(
+ parent._doc, (<_Element>value)._c_node)
+ new_element.tag = tag
+ cetree.appendChildToElement(parent, new_element)
+ elif isinstance(value, (list, tuple)):
+ for item in value:
+ _appendValue(parent, tag, item)
+ else:
+ new_element = cetree.makeElement(
+ tag, parent._doc, None, None, None, None, None)
+ _setElementValue(new_element, value)
+ cetree.appendChildToElement(parent, new_element)
+
+cdef _setElementValue(_Element element, value):
+ if value is None:
+ cetree.setAttributeValue(
+ element, XML_SCHEMA_INSTANCE_NIL_ATTR, "true")
+ elif isinstance(value, _Element):
+ _replaceElement(element, value)
+ return
+ else:
+ cetree.delAttributeFromNsName(
+ element._c_node, _XML_SCHEMA_INSTANCE_NS, "nil")
+ if python._isString(value):
+ pytype_name = "str"
+ py_type = _PYTYPE_DICT.get(pytype_name)
+ else:
+ pytype_name = _typename(value)
+ py_type = _PYTYPE_DICT.get(pytype_name)
+ if py_type is not None:
+ value = py_type.stringify(value)
+ else:
+ value = unicode(value)
+ if py_type is not None:
+ cetree.setAttributeValue(element, PYTYPE_ATTRIBUTE, pytype_name)
+ else:
+ cetree.delAttributeFromNsName(
+ element._c_node, _PYTYPE_NAMESPACE, _PYTYPE_ATTRIBUTE_NAME)
+ cetree.setNodeText(element._c_node, value)
+
+cdef _setSlice(sliceobject, _Element target, items):
+ cdef _Element parent
+ cdef tree.xmlNode* c_node
+ cdef Py_ssize_t c_step, c_start, pos
+ # collect existing slice
+ if (sliceobject).step is None:
+ c_step = 1
+ else:
+ c_step = (sliceobject).step
+ if c_step == 0:
+ raise ValueError, "Invalid slice"
+ cdef list del_items = target[sliceobject]
+
+ # collect new values
+ new_items = []
+ tag = target.tag
+ for item in items:
+ if isinstance(item, _Element):
+ # deep copy the new element
+ new_element = cetree.deepcopyNodeToDocument(
+ target._doc, (<_Element>item)._c_node)
+ new_element.tag = tag
+ else:
+ new_element = cetree.makeElement(
+ tag, target._doc, None, None, None, None, None)
+ _setElementValue(new_element, item)
+ new_items.append(new_element)
+
+ # sanity check - raise what a list would raise
+ if c_step != 1 and len(del_items) != len(new_items):
+ raise ValueError, \
+ f"attempt to assign sequence of size {len(new_items)} to extended slice of size {len(del_items)}"
+
+ # replace existing items
+ pos = 0
+ parent = target.getparent()
+ replace = parent.replace
+ while pos < len(new_items) and pos < len(del_items):
+ replace(del_items[pos], new_items[pos])
+ pos += 1
+ # remove leftover items
+ if pos < len(del_items):
+ remove = parent.remove
+ while pos < len(del_items):
+ remove(del_items[pos])
+ pos += 1
+ # append remaining new items
+ if pos < len(new_items):
+ # the sanity check above guarantees (step == 1)
+ if pos > 0:
+ item = new_items[pos-1]
+ else:
+ if (sliceobject).start > 0:
+ c_node = parent._c_node.children
+ else:
+ c_node = parent._c_node.last
+ c_node = _findFollowingSibling(
+ c_node, tree._getNs(target._c_node), target._c_node.name,
+ (sliceobject).start - 1)
+ if c_node is NULL:
+ while pos < len(new_items):
+ cetree.appendChildToElement(parent, new_items[pos])
+ pos += 1
+ return
+ item = cetree.elementFactory(parent._doc, c_node)
+ while pos < len(new_items):
+ add = item.addnext
+ item = new_items[pos]
+ add(item)
+ pos += 1
+
+################################################################################
+# Data type support in subclasses
+
+cdef class ObjectifiedDataElement(ObjectifiedElement):
+ """This is the base class for all data type Elements. Subclasses should
+ override the 'pyval' property and possibly the __str__ method.
+ """
+ @property
+ def pyval(self):
+ return textOf(self._c_node)
+
+ def __str__(self):
+ return textOf(self._c_node) or ''
+
+ def __repr__(self):
+ return textOf(self._c_node) or ''
+
+ def _setText(self, s):
+ """For use in subclasses only. Don't use unless you know what you are
+ doing.
+ """
+ cetree.setNodeText(self._c_node, s)
+
+
+cdef class NumberElement(ObjectifiedDataElement):
+ cdef object _parse_value
+
+ def _setValueParser(self, function):
+ """Set the function that parses the Python value from a string.
+
+ Do not use this unless you know what you are doing.
+ """
+ self._parse_value = function
+
+ @property
+ def pyval(self):
+ return _parseNumber(self)
+
+ def __int__(self):
+ return int(_parseNumber(self))
+
+ def __float__(self):
+ return float(_parseNumber(self))
+
+ def __complex__(self):
+ return complex(_parseNumber(self))
+
+ def __str__(self):
+ return unicode(_parseNumber(self))
+
+ def __repr__(self):
+ return repr(_parseNumber(self))
+
+ def __oct__(self):
+ return oct(_parseNumber(self))
+
+ def __hex__(self):
+ return hex(_parseNumber(self))
+
+ def __richcmp__(self, other, int op):
+ return _richcmpPyvals(self, other, op)
+
+ def __hash__(self):
+ return hash(_parseNumber(self))
+
+ def __add__(self, other):
+ return _numericValueOf(self) + _numericValueOf(other)
+
+ def __radd__(self, other):
+ return _numericValueOf(other) + _numericValueOf(self)
+
+ def __sub__(self, other):
+ return _numericValueOf(self) - _numericValueOf(other)
+
+ def __rsub__(self, other):
+ return _numericValueOf(other) - _numericValueOf(self)
+
+ def __mul__(self, other):
+ return _numericValueOf(self) * _numericValueOf(other)
+
+ def __rmul__(self, other):
+ return _numericValueOf(other) * _numericValueOf(self)
+
+ def __div__(self, other):
+ return _numericValueOf(self) / _numericValueOf(other)
+
+ def __rdiv__(self, other):
+ return _numericValueOf(other) / _numericValueOf(self)
+
+ def __truediv__(self, other):
+ return _numericValueOf(self) / _numericValueOf(other)
+
+ def __rtruediv__(self, other):
+ return _numericValueOf(other) / _numericValueOf(self)
+
+ def __floordiv__(self, other):
+ return _numericValueOf(self) // _numericValueOf(other)
+
+ def __rfloordiv__(self, other):
+ return _numericValueOf(other) // _numericValueOf(self)
+
+ def __mod__(self, other):
+ return _numericValueOf(self) % _numericValueOf(other)
+
+ def __rmod__(self, other):
+ return _numericValueOf(other) % _numericValueOf(self)
+
+ def __divmod__(self, other):
+ return divmod(_numericValueOf(self), _numericValueOf(other))
+
+ def __rdivmod__(self, other):
+ return divmod(_numericValueOf(other), _numericValueOf(self))
+
+ def __pow__(self, other, modulo):
+ if modulo is None:
+ return _numericValueOf(self) ** _numericValueOf(other)
+ else:
+ return pow(_numericValueOf(self), _numericValueOf(other), modulo)
+
+ def __rpow__(self, other, modulo):
+ if modulo is None:
+ return _numericValueOf(other) ** _numericValueOf(self)
+ else:
+ return pow(_numericValueOf(other), _numericValueOf(self), modulo)
+
+ def __neg__(self):
+ return - _numericValueOf(self)
+
+ def __pos__(self):
+ return + _numericValueOf(self)
+
+ def __abs__(self):
+ return abs( _numericValueOf(self) )
+
+ def __bool__(self):
+ return bool(_numericValueOf(self))
+
+ def __invert__(self):
+ return ~ _numericValueOf(self)
+
+ def __lshift__(self, other):
+ return _numericValueOf(self) << _numericValueOf(other)
+
+ def __rlshift__(self, other):
+ return _numericValueOf(other) << _numericValueOf(self)
+
+ def __rshift__(self, other):
+ return _numericValueOf(self) >> _numericValueOf(other)
+
+ def __rrshift__(self, other):
+ return _numericValueOf(other) >> _numericValueOf(self)
+
+ def __and__(self, other):
+ return _numericValueOf(self) & _numericValueOf(other)
+
+ def __rand__(self, other):
+ return _numericValueOf(other) & _numericValueOf(self)
+
+ def __or__(self, other):
+ return _numericValueOf(self) | _numericValueOf(other)
+
+ def __ror__(self, other):
+ return _numericValueOf(other) | _numericValueOf(self)
+
+ def __xor__(self, other):
+ return _numericValueOf(self) ^ _numericValueOf(other)
+
+ def __rxor__(self, other):
+ return _numericValueOf(other) ^ _numericValueOf(self)
+
+
+cdef class IntElement(NumberElement):
+ def _init(self):
+ self._parse_value = int
+
+ def __index__(self):
+ return int(_parseNumber(self))
+
+
+cdef class FloatElement(NumberElement):
+ def _init(self):
+ self._parse_value = float
+
+
+cdef class StringElement(ObjectifiedDataElement):
+ """String data class.
+
+ Note that this class does *not* support the sequence protocol of strings:
+ len(), iter(), str_attr[0], str_attr[0:1], etc. are *not* supported.
+ Instead, use the .text attribute to get a 'real' string.
+ """
+ @property
+ def pyval(self):
+ return textOf(self._c_node) or ''
+
+ def __repr__(self):
+ return repr(textOf(self._c_node) or '')
+
+ def strlen(self):
+ text = textOf(self._c_node)
+ if text is None:
+ return 0
+ else:
+ return len(text)
+
+ def __bool__(self):
+ return bool(textOf(self._c_node))
+
+ def __richcmp__(self, other, int op):
+ return _richcmpPyvals(self, other, op)
+
+ def __hash__(self):
+ return hash(textOf(self._c_node) or '')
+
+ def __add__(self, other):
+ text = _strValueOf(self)
+ other = _strValueOf(other)
+ return text + other
+
+ def __radd__(self, other):
+ text = _strValueOf(self)
+ other = _strValueOf(other)
+ return other + text
+
+ def __mul__(self, other):
+ if isinstance(self, StringElement):
+ return (textOf((self)._c_node) or '') * _numericValueOf(other)
+ elif isinstance(other, StringElement):
+ return _numericValueOf(self) * (textOf((other)._c_node) or '')
+ else:
+ return NotImplemented
+
+ def __rmul__(self, other):
+ return _numericValueOf(other) * (textOf((self)._c_node) or '')
+
+ def __mod__(self, other):
+ return (_strValueOf(self) or '') % other
+
+ def __int__(self):
+ return int(textOf(self._c_node))
+
+ def __float__(self):
+ return float(textOf(self._c_node))
+
+ def __complex__(self):
+ return complex(textOf(self._c_node))
+
+
+cdef class NoneElement(ObjectifiedDataElement):
+ def __str__(self):
+ return "None"
+
+ def __repr__(self):
+ return "None"
+
+ def __bool__(self):
+ return False
+
+ def __richcmp__(self, other, int op):
+ if other is None or self is None:
+ return python.PyObject_RichCompare(None, None, op)
+ if isinstance(self, NoneElement):
+ return python.PyObject_RichCompare(None, other, op)
+ else:
+ return python.PyObject_RichCompare(self, None, op)
+
+ def __hash__(self):
+ return hash(None)
+
+ @property
+ def pyval(self):
+ return None
+
+
+cdef class BoolElement(IntElement):
+ """Boolean type base on string values: 'true' or 'false'.
+
+ Note that this inherits from IntElement to mimic the behaviour of
+ Python's bool type.
+ """
+ def _init(self):
+ self._parse_value = _parseBool # wraps as Python callable
+
+ def __bool__(self):
+ return _parseBool(textOf(self._c_node))
+
+ def __int__(self):
+ return 0 + _parseBool(textOf(self._c_node))
+
+ def __float__(self):
+ return 0.0 + _parseBool(textOf(self._c_node))
+
+ def __richcmp__(self, other, int op):
+ return _richcmpPyvals(self, other, op)
+
+ def __hash__(self):
+ return hash(_parseBool(textOf(self._c_node)))
+
+ def __str__(self):
+ return unicode(_parseBool(textOf(self._c_node)))
+
+ def __repr__(self):
+ return repr(_parseBool(textOf(self._c_node)))
+
+ @property
+ def pyval(self):
+ return _parseBool(textOf(self._c_node))
+
+
+cdef _checkBool(s):
+ cdef int value = -1
+ if s is not None:
+ value = __parseBoolAsInt(s)
+ if value == -1:
+ raise ValueError
+
+
+cdef bint _parseBool(s) except -1:
+ cdef int value
+ if s is None:
+ return False
+ value = __parseBoolAsInt(s)
+ if value == -1:
+ raise ValueError, f"Invalid boolean value: '{s}'"
+ return value
+
+
+cdef inline int __parseBoolAsInt(text) except -2:
+ if text == 'false':
+ return 0
+ elif text == 'true':
+ return 1
+ elif text == '0':
+ return 0
+ elif text == '1':
+ return 1
+ return -1
+
+
+cdef object _parseNumber(NumberElement element):
+ return element._parse_value(textOf(element._c_node))
+
+
+cdef enum NumberParserState:
+ NPS_SPACE_PRE = 0
+ NPS_SIGN = 1
+ NPS_DIGITS = 2
+ NPS_POINT_LEAD = 3
+ NPS_POINT = 4
+ NPS_FRACTION = 5
+ NPS_EXP = 6
+ NPS_EXP_SIGN = 7
+ NPS_DIGITS_EXP = 8
+ NPS_SPACE_TAIL = 9
+ NPS_INF1 = 20
+ NPS_INF2 = 21
+ NPS_INF3 = 22
+ NPS_NAN1 = 23
+ NPS_NAN2 = 24
+ NPS_NAN3 = 25
+ NPS_ERROR = 99
+
+
+ctypedef fused bytes_unicode:
+ bytes
+ unicode
+
+
+cdef _checkNumber(bytes_unicode s, bint allow_float):
+ cdef Py_UCS4 c
+ cdef NumberParserState state = NPS_SPACE_PRE
+
+ for c in s:
+ if c in '0123456789':
+ if state in (NPS_DIGITS, NPS_FRACTION, NPS_DIGITS_EXP):
+ pass
+ elif state in (NPS_SPACE_PRE, NPS_SIGN):
+ state = NPS_DIGITS
+ elif state in (NPS_POINT_LEAD, NPS_POINT):
+ state = NPS_FRACTION
+ elif state in (NPS_EXP, NPS_EXP_SIGN):
+ state = NPS_DIGITS_EXP
+ else:
+ state = NPS_ERROR
+ else:
+ if c == '.':
+ if state in (NPS_SPACE_PRE, NPS_SIGN):
+ state = NPS_POINT_LEAD
+ elif state == NPS_DIGITS:
+ state = NPS_POINT
+ else:
+ state = NPS_ERROR
+ if not allow_float:
+ state = NPS_ERROR
+ elif c in '-+':
+ if state == NPS_SPACE_PRE:
+ state = NPS_SIGN
+ elif state == NPS_EXP:
+ state = NPS_EXP_SIGN
+ else:
+ state = NPS_ERROR
+ elif c == 'E':
+ if state in (NPS_DIGITS, NPS_POINT, NPS_FRACTION):
+ state = NPS_EXP
+ else:
+ state = NPS_ERROR
+ if not allow_float:
+ state = NPS_ERROR
+ # Allow INF and NaN. XMLSchema requires case, we don't, like Python.
+ elif c in 'iI':
+ state = NPS_INF1 if allow_float and state in (NPS_SPACE_PRE, NPS_SIGN) else NPS_ERROR
+ elif c in 'fF':
+ state = NPS_INF3 if state == NPS_INF2 else NPS_ERROR
+ elif c in 'aA':
+ state = NPS_NAN2 if state == NPS_NAN1 else NPS_ERROR
+ elif c in 'nN':
+ # Python also allows [+-]NaN, so let's accept that.
+ if state in (NPS_SPACE_PRE, NPS_SIGN):
+ state = NPS_NAN1 if allow_float else NPS_ERROR
+ elif state == NPS_NAN2:
+ state = NPS_NAN3
+ elif state == NPS_INF1:
+ state = NPS_INF2
+ else:
+ state = NPS_ERROR
+ # Allow spaces around text values.
+ else:
+ if c.isspace() if (bytes_unicode is unicode) else c in b'\x09\x0a\x0b\x0c\x0d\x20':
+ if state in (NPS_SPACE_PRE, NPS_SPACE_TAIL):
+ pass
+ elif state in (NPS_DIGITS, NPS_POINT, NPS_FRACTION, NPS_DIGITS_EXP, NPS_INF3, NPS_NAN3):
+ state = NPS_SPACE_TAIL
+ else:
+ state = NPS_ERROR
+ else:
+ state = NPS_ERROR
+
+ if state == NPS_ERROR:
+ break
+
+ if state not in (NPS_DIGITS, NPS_FRACTION, NPS_POINT, NPS_DIGITS_EXP, NPS_INF3, NPS_NAN3, NPS_SPACE_TAIL):
+ raise ValueError
+
+
+cdef _checkInt(s):
+ return _checkNumber(s, allow_float=False)
+
+
+cdef _checkFloat(s):
+ return _checkNumber(s, allow_float=True)
+
+
+cdef object _strValueOf(obj):
+ if python._isString(obj):
+ return obj
+ if isinstance(obj, _Element):
+ return textOf((<_Element>obj)._c_node) or ''
+ if obj is None:
+ return ''
+ return unicode(obj)
+
+
+cdef object _numericValueOf(obj):
+ if isinstance(obj, NumberElement):
+ return _parseNumber(obj)
+ try:
+ # not always numeric, but Python will raise the right exception
+ return obj.pyval
+ except AttributeError:
+ pass
+ return obj
+
+
+cdef _richcmpPyvals(left, right, int op):
+ left = getattr(left, 'pyval', left)
+ right = getattr(right, 'pyval', right)
+ return python.PyObject_RichCompare(left, right, op)
+
+
+################################################################################
+# Python type registry
+
+cdef class PyType:
+ """PyType(self, name, type_check, type_class, stringify=None)
+ User defined type.
+
+ Named type that contains a type check function, a type class that
+ inherits from ObjectifiedDataElement and an optional "stringification"
+ function. The type check must take a string as argument and raise
+ ValueError or TypeError if it cannot handle the string value. It may be
+ None in which case it is not considered for type guessing. For registered
+ named types, the 'stringify' function (or unicode() if None) is used to
+ convert a Python object with type name 'name' to the string representation
+ stored in the XML tree.
+
+ Example::
+
+ PyType('int', int, MyIntClass).register()
+
+ Note that the order in which types are registered matters. The first
+ matching type will be used.
+ """
+ cdef readonly object name
+ cdef readonly object type_check
+ cdef readonly object stringify
+ cdef object _type
+ cdef list _schema_types
+ def __init__(self, name, type_check, type_class, stringify=None):
+ if isinstance(name, bytes):
+ name = (name).decode('ascii')
+ elif not isinstance(name, unicode):
+ raise TypeError, "Type name must be a string"
+ if type_check is not None and not callable(type_check):
+ raise TypeError, "Type check function must be callable (or None)"
+ if name != TREE_PYTYPE_NAME and \
+ not issubclass(type_class, ObjectifiedDataElement):
+ raise TypeError, \
+ "Data classes must inherit from ObjectifiedDataElement"
+ self.name = name
+ self._type = type_class
+ self.type_check = type_check
+ if stringify is None:
+ stringify = unicode
+ self.stringify = stringify
+ self._schema_types = []
+
+ def __repr__(self):
+ return "PyType(%s, %s)" % (self.name, self._type.__name__)
+
+ def register(self, before=None, after=None):
+ """register(self, before=None, after=None)
+
+ Register the type.
+
+ The additional keyword arguments 'before' and 'after' accept a
+ sequence of type names that must appear before/after the new type in
+ the type list. If any of them is not currently known, it is simply
+ ignored. Raises ValueError if the dependencies cannot be fulfilled.
+ """
+ if self.name == TREE_PYTYPE_NAME:
+ raise ValueError, "Cannot register tree type"
+ if self.type_check is not None:
+ for item in _TYPE_CHECKS:
+ if item[0] is self.type_check:
+ _TYPE_CHECKS.remove(item)
+ break
+ entry = (self.type_check, self)
+ first_pos = 0
+ last_pos = -1
+ if before or after:
+ if before is None:
+ before = ()
+ elif after is None:
+ after = ()
+ for i, (check, pytype) in enumerate(_TYPE_CHECKS):
+ if last_pos == -1 and pytype.name in before:
+ last_pos = i
+ if pytype.name in after:
+ first_pos = i+1
+ if last_pos == -1:
+ _TYPE_CHECKS.append(entry)
+ elif first_pos > last_pos:
+ raise ValueError, "inconsistent before/after dependencies"
+ else:
+ _TYPE_CHECKS.insert(last_pos, entry)
+
+ _PYTYPE_DICT[self.name] = self
+ for xs_type in self._schema_types:
+ _SCHEMA_TYPE_DICT[xs_type] = self
+
+ def unregister(self):
+ "unregister(self)"
+ if _PYTYPE_DICT.get(self.name) is self:
+ del _PYTYPE_DICT[self.name]
+ for xs_type, pytype in list(_SCHEMA_TYPE_DICT.items()):
+ if pytype is self:
+ del _SCHEMA_TYPE_DICT[xs_type]
+ if self.type_check is None:
+ return
+ try:
+ _TYPE_CHECKS.remove( (self.type_check, self) )
+ except ValueError:
+ pass
+
+ property xmlSchemaTypes:
+ """The list of XML Schema datatypes this Python type maps to.
+
+ Note that this must be set before registering the type!
+ """
+ def __get__(self):
+ return self._schema_types
+ def __set__(self, types):
+ self._schema_types = list(map(unicode, types))
+
+
+cdef dict _PYTYPE_DICT = {}
+cdef dict _SCHEMA_TYPE_DICT = {}
+cdef list _TYPE_CHECKS = []
+
+cdef unicode _xml_bool(value):
+ return "true" if value else "false"
+
+cdef unicode _xml_float(value):
+ if _float_is_inf(value):
+ if value > 0:
+ return "INF"
+ return "-INF"
+ if _float_is_nan(value):
+ return "NaN"
+ return unicode(repr(value))
+
+cdef _pytypename(obj):
+ return "str" if python._isString(obj) else _typename(obj)
+
+def pytypename(obj):
+ """pytypename(obj)
+
+ Find the name of the corresponding PyType for a Python object.
+ """
+ return _pytypename(obj)
+
+cdef _registerPyTypes():
+ pytype = PyType('int', _checkInt, IntElement) # wraps functions for Python
+ pytype.xmlSchemaTypes = ("integer", "int", "short", "byte", "unsignedShort",
+ "unsignedByte", "nonPositiveInteger",
+ "negativeInteger", "long", "nonNegativeInteger",
+ "unsignedLong", "unsignedInt", "positiveInteger",)
+ pytype.register()
+
+ # 'long' type just for backwards compatibility
+ pytype = PyType('long', None, IntElement)
+ pytype.register()
+
+ pytype = PyType('float', _checkFloat, FloatElement, _xml_float) # wraps functions for Python
+ pytype.xmlSchemaTypes = ("double", "float")
+ pytype.register()
+
+ pytype = PyType('bool', _checkBool, BoolElement, _xml_bool) # wraps functions for Python
+ pytype.xmlSchemaTypes = ("boolean",)
+ pytype.register()
+
+ pytype = PyType('str', None, StringElement)
+ pytype.xmlSchemaTypes = ("string", "normalizedString", "token", "language",
+ "Name", "NCName", "ID", "IDREF", "ENTITY",
+ "NMTOKEN", )
+ pytype.register()
+
+ # since lxml 2.0
+ pytype = PyType('NoneType', None, NoneElement)
+ pytype.register()
+
+ # backwards compatibility
+ pytype = PyType('none', None, NoneElement)
+ pytype.register()
+
+# non-registered PyType for inner tree elements
+cdef PyType TREE_PYTYPE = PyType(TREE_PYTYPE_NAME, None, ObjectifiedElement)
+
+_registerPyTypes()
+
+def getRegisteredTypes():
+ """getRegisteredTypes()
+
+ Returns a list of the currently registered PyType objects.
+
+ To add a new type, retrieve this list and call unregister() for all
+ entries. Then add the new type at a suitable position (possibly replacing
+ an existing one) and call register() for all entries.
+
+ This is necessary if the new type interferes with the type check functions
+ of existing ones (normally only int/float/bool) and must the tried before
+ other types. To add a type that is not yet parsable by the current type
+ check functions, you can simply register() it, which will append it to the
+ end of the type list.
+ """
+ cdef list types = []
+ cdef set known = set()
+ for check, pytype in _TYPE_CHECKS:
+ name = pytype.name
+ if name not in known:
+ known.add(name)
+ types.append(pytype)
+ for pytype in _PYTYPE_DICT.values():
+ name = pytype.name
+ if name not in known:
+ known.add(name)
+ types.append(pytype)
+ return types
+
+cdef PyType _guessPyType(value, PyType defaulttype):
+ if value is None:
+ return None
+ for type_check, tested_pytype in _TYPE_CHECKS:
+ try:
+ type_check(value)
+ return tested_pytype
+ except IGNORABLE_ERRORS:
+ # could not be parsed as the specified type => ignore
+ pass
+ return defaulttype
+
+cdef object _guessElementClass(tree.xmlNode* c_node):
+ value = textOf(c_node)
+ if value is None:
+ return None
+ if value == '':
+ return StringElement
+
+ for type_check, pytype in _TYPE_CHECKS:
+ try:
+ type_check(value)
+ return (pytype)._type
+ except IGNORABLE_ERRORS:
+ pass
+ return None
+
+################################################################################
+# adapted ElementMaker supports registered PyTypes
+
+@cython.final
+@cython.internal
+cdef class _ObjectifyElementMakerCaller:
+ cdef object _tag
+ cdef object _nsmap
+ cdef object _element_factory
+ cdef bint _annotate
+
+ def __call__(self, *children, **attrib):
+ "__call__(self, *children, **attrib)"
+ cdef _ObjectifyElementMakerCaller elementMaker
+ cdef _Element element
+ cdef _Element childElement
+ cdef bint has_children
+ cdef bint has_string_value
+ if self._element_factory is None:
+ element = _makeElement(self._tag, None, attrib, self._nsmap)
+ else:
+ element = self._element_factory(self._tag, attrib, self._nsmap)
+
+ pytype_name = None
+ has_children = False
+ has_string_value = False
+ for child in children:
+ if child is None:
+ if len(children) == 1:
+ cetree.setAttributeValue(
+ element, XML_SCHEMA_INSTANCE_NIL_ATTR, "true")
+ elif python._isString(child):
+ _add_text(element, child)
+ has_string_value = True
+ elif isinstance(child, _Element):
+ cetree.appendChildToElement(element, <_Element>child)
+ has_children = True
+ elif isinstance(child, _ObjectifyElementMakerCaller):
+ elementMaker = <_ObjectifyElementMakerCaller>child
+ if elementMaker._element_factory is None:
+ cetree.makeSubElement(element, elementMaker._tag,
+ None, None, None, None)
+ else:
+ childElement = elementMaker._element_factory(
+ elementMaker._tag)
+ cetree.appendChildToElement(element, childElement)
+ has_children = True
+ elif isinstance(child, dict):
+ for name, value in child.items():
+ # keyword arguments in attrib take precedence
+ if name in attrib:
+ continue
+ pytype = _PYTYPE_DICT.get(_typename(value))
+ if pytype is not None:
+ value = (pytype).stringify(value)
+ elif not python._isString(value):
+ value = unicode(value)
+ cetree.setAttributeValue(element, name, value)
+ else:
+ if pytype_name is not None:
+ # concatenation always makes the result a string
+ has_string_value = True
+ pytype_name = _typename(child)
+ pytype = _PYTYPE_DICT.get(_typename(child))
+ if pytype is not None:
+ _add_text(element, (pytype).stringify(child))
+ else:
+ has_string_value = True
+ child = unicode(child)
+ _add_text(element, child)
+
+ if self._annotate and not has_children:
+ if has_string_value:
+ cetree.setAttributeValue(element, PYTYPE_ATTRIBUTE, "str")
+ elif pytype_name is not None:
+ cetree.setAttributeValue(element, PYTYPE_ATTRIBUTE, pytype_name)
+
+ return element
+
+cdef _add_text(_Element elem, text):
+ # add text to the tree in construction, either as element text or
+ # tail text, depending on the current tree state
+ cdef tree.xmlNode* c_child
+ c_child = cetree.findChildBackwards(elem._c_node, 0)
+ if c_child is not NULL:
+ old = cetree.tailOf(c_child)
+ if old is not None:
+ text = old + text
+ cetree.setTailText(c_child, text)
+ else:
+ old = cetree.textOf(elem._c_node)
+ if old is not None:
+ text = old + text
+ cetree.setNodeText(elem._c_node, text)
+
+cdef class ElementMaker:
+ """ElementMaker(self, namespace=None, nsmap=None, annotate=True, makeelement=None)
+
+ An ElementMaker that can be used for constructing trees.
+
+ Example::
+
+ >>> M = ElementMaker(annotate=False)
+ >>> attributes = {'class': 'par'}
+ >>> html = M.html( M.body( M.p('hello', attributes, M.br, 'objectify', style="font-weight: bold") ) )
+
+ >>> from lxml.etree import tostring
+ >>> print(tostring(html, method='html').decode('ascii'))
+
hello objectify
+
+ To create tags that are not valid Python identifiers, call the factory
+ directly and pass the tag name as first argument::
+
+ >>> root = M('tricky-tag', 'some text')
+ >>> print(root.tag)
+ tricky-tag
+ >>> print(root.text)
+ some text
+
+ Note that this module has a predefined ElementMaker instance called ``E``.
+ """
+ cdef object _makeelement
+ cdef object _namespace
+ cdef object _nsmap
+ cdef bint _annotate
+ cdef dict _cache
+ def __init__(self, *, namespace=None, nsmap=None, annotate=True,
+ makeelement=None):
+ if nsmap is None:
+ nsmap = _DEFAULT_NSMAP if annotate else {}
+ self._nsmap = nsmap
+ self._namespace = None if namespace is None else "{%s}" % namespace
+ self._annotate = annotate
+ if makeelement is not None:
+ if not callable(makeelement):
+ raise TypeError(
+ f"argument of 'makeelement' parameter must be callable, got {type(makeelement)}")
+ self._makeelement = makeelement
+ else:
+ self._makeelement = None
+ self._cache = {}
+
+ @cython.final
+ cdef _build_element_maker(self, tag, bint caching):
+ cdef _ObjectifyElementMakerCaller element_maker
+ element_maker = _ObjectifyElementMakerCaller.__new__(_ObjectifyElementMakerCaller)
+ if self._namespace is not None and tag[0] != "{":
+ element_maker._tag = self._namespace + tag
+ else:
+ element_maker._tag = tag
+ element_maker._nsmap = self._nsmap
+ element_maker._annotate = self._annotate
+ element_maker._element_factory = self._makeelement
+ if caching:
+ if len(self._cache) > 200:
+ self._cache.clear()
+ self._cache[tag] = element_maker
+ return element_maker
+
+ def __getattr__(self, tag):
+ element_maker = self._cache.get(tag)
+ if element_maker is None:
+ return self._build_element_maker(tag, caching=True)
+ return element_maker
+
+ def __call__(self, tag, *args, **kwargs):
+ element_maker = self._cache.get(tag)
+ if element_maker is None:
+ element_maker = self._build_element_maker(
+ tag, caching=not is_special_method(tag))
+ return element_maker(*args, **kwargs)
+
+################################################################################
+# Recursive element dumping
+
+cdef bint __RECURSIVE_STR = 0 # default: off
+
+def enable_recursive_str(on=True):
+ """enable_recursive_str(on=True)
+
+ Enable a recursively generated tree representation for str(element),
+ based on objectify.dump(element).
+ """
+ global __RECURSIVE_STR
+ __RECURSIVE_STR = on
+
+def dump(_Element element not None):
+ """dump(_Element element not None)
+
+ Return a recursively generated string representation of an element.
+ """
+ return _dump(element, 0)
+
+cdef object _dump(_Element element, int indent):
+ indentstr = " " * indent
+ if isinstance(element, ObjectifiedDataElement):
+ value = repr(element)
+ else:
+ value = textOf(element._c_node)
+ if value is not None:
+ if not value.strip():
+ value = None
+ else:
+ value = repr(value)
+ result = f"{indentstr}{element.tag} = {value} [{_typename(element)}]\n"
+ xsi_ns = "{%s}" % XML_SCHEMA_INSTANCE_NS
+ pytype_ns = "{%s}" % PYTYPE_NAMESPACE
+ for name, value in sorted(cetree.iterattributes(element, 3)):
+ if '{' in name:
+ if name == PYTYPE_ATTRIBUTE:
+ if value == TREE_PYTYPE_NAME:
+ continue
+ else:
+ name = name.replace(pytype_ns, 'py:')
+ name = name.replace(xsi_ns, 'xsi:')
+ result += f"{indentstr} * {name} = {value!r}\n"
+
+ indent += 1
+ for child in element.iterchildren():
+ result += _dump(child, indent)
+ if indent == 1:
+ return result[:-1] # strip last '\n'
+ else:
+ return result
+
+
+################################################################################
+# Pickle support for objectified ElementTree
+
+def __unpickleElementTree(data):
+ return etree.ElementTree(fromstring(data))
+
+cdef _setupPickle(elementTreeReduceFunction):
+ import copyreg
+ copyreg.pickle(etree._ElementTree,
+ elementTreeReduceFunction, __unpickleElementTree)
+
+def pickleReduceElementTree(obj):
+ return __unpickleElementTree, (etree.tostring(obj),)
+
+_setupPickle(pickleReduceElementTree)
+del pickleReduceElementTree
+
+################################################################################
+# Element class lookup
+
+cdef class ObjectifyElementClassLookup(ElementClassLookup):
+ """ObjectifyElementClassLookup(self, tree_class=None, empty_data_class=None)
+ Element class lookup method that uses the objectify classes.
+ """
+ cdef object empty_data_class
+ cdef object tree_class
+ def __init__(self, tree_class=None, empty_data_class=None):
+ """Lookup mechanism for objectify.
+
+ The default Element classes can be replaced by passing subclasses of
+ ObjectifiedElement and ObjectifiedDataElement as keyword arguments.
+ 'tree_class' defines inner tree classes (defaults to
+ ObjectifiedElement), 'empty_data_class' defines the default class for
+ empty data elements (defaults to StringElement).
+ """
+ self._lookup_function = _lookupElementClass
+ if tree_class is None:
+ tree_class = ObjectifiedElement
+ self.tree_class = tree_class
+ if empty_data_class is None:
+ empty_data_class = StringElement
+ self.empty_data_class = empty_data_class
+
+cdef object _lookupElementClass(state, _Document doc, tree.xmlNode* c_node):
+ cdef ObjectifyElementClassLookup lookup
+ lookup = state
+ # if element has children => no data class
+ if cetree.hasChild(c_node):
+ return lookup.tree_class
+
+ # if element is defined as xsi:nil, return NoneElement class
+ if "true" == cetree.attributeValueFromNsName(
+ c_node, _XML_SCHEMA_INSTANCE_NS, "nil"):
+ return NoneElement
+
+ # check for Python type hint
+ value = cetree.attributeValueFromNsName(
+ c_node, _PYTYPE_NAMESPACE, _PYTYPE_ATTRIBUTE_NAME)
+ if value is not None:
+ if value == TREE_PYTYPE_NAME:
+ return lookup.tree_class
+ py_type = _PYTYPE_DICT.get(value)
+ if py_type is not None:
+ return py_type._type
+ # unknown 'pyval' => try to figure it out ourself, just go on
+
+ # check for XML Schema type hint
+ value = cetree.attributeValueFromNsName(
+ c_node, _XML_SCHEMA_INSTANCE_NS, "type")
+
+ if value is not None:
+ schema_type = _SCHEMA_TYPE_DICT.get(value)
+ if schema_type is None and ':' in value:
+ prefix, value = value.split(':', 1)
+ schema_type = _SCHEMA_TYPE_DICT.get(value)
+ if schema_type is not None:
+ return schema_type._type
+
+ # otherwise determine class based on text content type
+ el_class = _guessElementClass(c_node)
+ if el_class is not None:
+ return el_class
+
+ # if element is a root node => default to tree node
+ if c_node.parent is NULL or not tree._isElement(c_node.parent):
+ return lookup.tree_class
+
+ return lookup.empty_data_class
+
+
+################################################################################
+# Type annotations
+
+cdef PyType _check_type(tree.xmlNode* c_node, PyType pytype):
+ if pytype is None:
+ return None
+ value = textOf(c_node)
+ try:
+ pytype.type_check(value)
+ return pytype
+ except IGNORABLE_ERRORS:
+ # could not be parsed as the specified type => ignore
+ pass
+ return None
+
+def pyannotate(element_or_tree, *, ignore_old=False, ignore_xsi=False,
+ empty_pytype=None):
+ """pyannotate(element_or_tree, ignore_old=False, ignore_xsi=False, empty_pytype=None)
+
+ Recursively annotates the elements of an XML tree with 'pytype'
+ attributes.
+
+ If the 'ignore_old' keyword argument is True (the default), current 'pytype'
+ attributes will be ignored and replaced. Otherwise, they will be checked
+ and only replaced if they no longer fit the current text value.
+
+ Setting the keyword argument ``ignore_xsi`` to True makes the function
+ additionally ignore existing ``xsi:type`` annotations. The default is to
+ use them as a type hint.
+
+ The default annotation of empty elements can be set with the
+ ``empty_pytype`` keyword argument. The default is not to annotate empty
+ elements. Pass 'str', for example, to make string values the default.
+ """
+ cdef _Element element
+ element = cetree.rootNodeOrRaise(element_or_tree)
+ _annotate(element, 0, 1, ignore_xsi, ignore_old, None, empty_pytype)
+
+def xsiannotate(element_or_tree, *, ignore_old=False, ignore_pytype=False,
+ empty_type=None):
+ """xsiannotate(element_or_tree, ignore_old=False, ignore_pytype=False, empty_type=None)
+
+ Recursively annotates the elements of an XML tree with 'xsi:type'
+ attributes.
+
+ If the 'ignore_old' keyword argument is True (the default), current
+ 'xsi:type' attributes will be ignored and replaced. Otherwise, they will be
+ checked and only replaced if they no longer fit the current text value.
+
+ Note that the mapping from Python types to XSI types is usually ambiguous.
+ Currently, only the first XSI type name in the corresponding PyType
+ definition will be used for annotation. Thus, you should consider naming
+ the widest type first if you define additional types.
+
+ Setting the keyword argument ``ignore_pytype`` to True makes the function
+ additionally ignore existing ``pytype`` annotations. The default is to
+ use them as a type hint.
+
+ The default annotation of empty elements can be set with the
+ ``empty_type`` keyword argument. The default is not to annotate empty
+ elements. Pass 'string', for example, to make string values the default.
+ """
+ cdef _Element element
+ element = cetree.rootNodeOrRaise(element_or_tree)
+ _annotate(element, 1, 0, ignore_old, ignore_pytype, empty_type, None)
+
+def annotate(element_or_tree, *, ignore_old=True, ignore_xsi=False,
+ empty_pytype=None, empty_type=None, annotate_xsi=0,
+ annotate_pytype=1):
+ """annotate(element_or_tree, ignore_old=True, ignore_xsi=False, empty_pytype=None, empty_type=None, annotate_xsi=0, annotate_pytype=1)
+
+ Recursively annotates the elements of an XML tree with 'xsi:type'
+ and/or 'py:pytype' attributes.
+
+ If the 'ignore_old' keyword argument is True (the default), current
+ 'py:pytype' attributes will be ignored for the type annotation. Set to False
+ if you want reuse existing 'py:pytype' information (iff appropriate for the
+ element text value).
+
+ If the 'ignore_xsi' keyword argument is False (the default), existing
+ 'xsi:type' attributes will be used for the type annotation, if they fit the
+ element text values.
+
+ Note that the mapping from Python types to XSI types is usually ambiguous.
+ Currently, only the first XSI type name in the corresponding PyType
+ definition will be used for annotation. Thus, you should consider naming
+ the widest type first if you define additional types.
+
+ The default 'py:pytype' annotation of empty elements can be set with the
+ ``empty_pytype`` keyword argument. Pass 'str', for example, to make
+ string values the default.
+
+ The default 'xsi:type' annotation of empty elements can be set with the
+ ``empty_type`` keyword argument. The default is not to annotate empty
+ elements. Pass 'string', for example, to make string values the default.
+
+ The keyword arguments 'annotate_xsi' (default: 0) and 'annotate_pytype'
+ (default: 1) control which kind(s) of annotation to use.
+ """
+ cdef _Element element
+ element = cetree.rootNodeOrRaise(element_or_tree)
+ _annotate(element, annotate_xsi, annotate_pytype, ignore_xsi,
+ ignore_old, empty_type, empty_pytype)
+
+
+cdef _annotate(_Element element, bint annotate_xsi, bint annotate_pytype,
+ bint ignore_xsi, bint ignore_pytype,
+ empty_type_name, empty_pytype_name):
+ cdef _Document doc
+ cdef tree.xmlNode* c_node
+ cdef PyType empty_pytype, StrType, NoneType
+
+ if not annotate_xsi and not annotate_pytype:
+ return
+
+ if empty_type_name is not None:
+ if isinstance(empty_type_name, bytes):
+ empty_type_name = (empty_type_name).decode("ascii")
+ empty_pytype = _SCHEMA_TYPE_DICT.get(empty_type_name)
+ elif empty_pytype_name is not None:
+ if isinstance(empty_pytype_name, bytes):
+ empty_pytype_name = (empty_pytype_name).decode("ascii")
+ empty_pytype = _PYTYPE_DICT.get(empty_pytype_name)
+ else:
+ empty_pytype = None
+
+ StrType = _PYTYPE_DICT.get('str')
+ NoneType = _PYTYPE_DICT.get('NoneType')
+
+ doc = element._doc
+ c_node = element._c_node
+ tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_node, c_node, 1)
+ if c_node.type == tree.XML_ELEMENT_NODE:
+ _annotate_element(c_node, doc, annotate_xsi, annotate_pytype,
+ ignore_xsi, ignore_pytype,
+ empty_type_name, empty_pytype, StrType, NoneType)
+ tree.END_FOR_EACH_ELEMENT_FROM(c_node)
+
+cdef int _annotate_element(tree.xmlNode* c_node, _Document doc,
+ bint annotate_xsi, bint annotate_pytype,
+ bint ignore_xsi, bint ignore_pytype,
+ empty_type_name, PyType empty_pytype,
+ PyType StrType, PyType NoneType) except -1:
+ cdef tree.xmlNs* c_ns
+ cdef PyType pytype = None
+ typename = None
+ istree = 0
+
+ # if element is defined as xsi:nil, represent it as None
+ if cetree.attributeValueFromNsName(
+ c_node, _XML_SCHEMA_INSTANCE_NS, "nil") == "true":
+ pytype = NoneType
+
+ if pytype is None and not ignore_xsi:
+ # check that old xsi type value is valid
+ typename = cetree.attributeValueFromNsName(
+ c_node, _XML_SCHEMA_INSTANCE_NS, "type")
+ if typename is not None:
+ pytype = _SCHEMA_TYPE_DICT.get(typename)
+ if pytype is None and ':' in typename:
+ prefix, typename = typename.split(':', 1)
+ pytype = _SCHEMA_TYPE_DICT.get(typename)
+ if pytype is not None and pytype is not StrType:
+ # StrType does not have a typecheck but is the default
+ # anyway, so just accept it if given as type
+ # information
+ pytype = _check_type(c_node, pytype)
+ if pytype is None:
+ typename = None
+
+ if pytype is None and not ignore_pytype:
+ # check that old pytype value is valid
+ old_pytypename = cetree.attributeValueFromNsName(
+ c_node, _PYTYPE_NAMESPACE, _PYTYPE_ATTRIBUTE_NAME)
+ if old_pytypename is not None:
+ if old_pytypename == TREE_PYTYPE_NAME:
+ if not cetree.hasChild(c_node):
+ # only case where we should keep it,
+ # everything else is clear enough
+ pytype = TREE_PYTYPE
+ else:
+ if old_pytypename == 'none':
+ # transition from lxml 1.x
+ old_pytypename = "NoneType"
+ pytype = _PYTYPE_DICT.get(old_pytypename)
+ if pytype is not None and pytype is not StrType:
+ # StrType does not have a typecheck but is the
+ # default anyway, so just accept it if given as
+ # type information
+ pytype = _check_type(c_node, pytype)
+
+ if pytype is None:
+ # try to guess type
+ if not cetree.hasChild(c_node):
+ # element has no children => data class
+ pytype = _guessPyType(textOf(c_node), StrType)
+ else:
+ istree = 1
+
+ if pytype is None:
+ # use default type for empty elements
+ if cetree.hasText(c_node):
+ pytype = StrType
+ else:
+ pytype = empty_pytype
+ if typename is None:
+ typename = empty_type_name
+
+ if pytype is not None:
+ if typename is None:
+ if not istree:
+ if pytype._schema_types:
+ # pytype->xsi:type is a 1:n mapping
+ # simply take the first
+ typename = pytype._schema_types[0]
+ elif typename not in pytype._schema_types:
+ typename = pytype._schema_types[0]
+
+ if annotate_xsi:
+ if typename is None or istree:
+ cetree.delAttributeFromNsName(
+ c_node, _XML_SCHEMA_INSTANCE_NS, "type")
+ else:
+ # update or create attribute
+ typename_utf8 = cetree.utf8(typename)
+ c_ns = cetree.findOrBuildNodeNsPrefix(
+ doc, c_node, _XML_SCHEMA_NS, 'xsd')
+ if c_ns is not NULL:
+ if b':' in typename_utf8:
+ prefix, name = typename_utf8.split(b':', 1)
+ if c_ns.prefix is NULL or c_ns.prefix[0] == c'\0':
+ typename_utf8 = name
+ elif tree.xmlStrcmp(_xcstr(prefix), c_ns.prefix) != 0:
+ typename_utf8 = (c_ns.prefix) + b':' + name
+ elif c_ns.prefix is not NULL and c_ns.prefix[0] != c'\0':
+ typename_utf8 = (c_ns.prefix) + b':' + typename_utf8
+ c_ns = cetree.findOrBuildNodeNsPrefix(
+ doc, c_node, _XML_SCHEMA_INSTANCE_NS, 'xsi')
+ tree.xmlSetNsProp(c_node, c_ns, "type", _xcstr(typename_utf8))
+
+ if annotate_pytype:
+ if pytype is None:
+ # delete attribute if it exists
+ cetree.delAttributeFromNsName(
+ c_node, _PYTYPE_NAMESPACE, _PYTYPE_ATTRIBUTE_NAME)
+ else:
+ # update or create attribute
+ c_ns = cetree.findOrBuildNodeNsPrefix(
+ doc, c_node, _PYTYPE_NAMESPACE, 'py')
+ pytype_name = cetree.utf8(pytype.name)
+ tree.xmlSetNsProp(c_node, c_ns, _PYTYPE_ATTRIBUTE_NAME,
+ _xcstr(pytype_name))
+ if pytype is NoneType:
+ c_ns = cetree.findOrBuildNodeNsPrefix(
+ doc, c_node, _XML_SCHEMA_INSTANCE_NS, 'xsi')
+ tree.xmlSetNsProp(c_node, c_ns, "nil", "true")
+
+ return 0
+
+cdef object _strip_attributes = etree.strip_attributes
+cdef object _cleanup_namespaces = etree.cleanup_namespaces
+
+def deannotate(element_or_tree, *, bint pytype=True, bint xsi=True,
+ bint xsi_nil=False, bint cleanup_namespaces=False):
+ """deannotate(element_or_tree, pytype=True, xsi=True, xsi_nil=False, cleanup_namespaces=False)
+
+ Recursively de-annotate the elements of an XML tree by removing 'py:pytype'
+ and/or 'xsi:type' attributes and/or 'xsi:nil' attributes.
+
+ If the 'pytype' keyword argument is True (the default), 'py:pytype'
+ attributes will be removed. If the 'xsi' keyword argument is True (the
+ default), 'xsi:type' attributes will be removed.
+ If the 'xsi_nil' keyword argument is True (default: False), 'xsi:nil'
+ attributes will be removed.
+
+ Note that this does not touch the namespace declarations by
+ default. If you want to remove unused namespace declarations from
+ the tree, pass the option ``cleanup_namespaces=True``.
+ """
+ cdef list attribute_names = []
+
+ if pytype:
+ attribute_names.append(PYTYPE_ATTRIBUTE)
+ if xsi:
+ attribute_names.append(XML_SCHEMA_INSTANCE_TYPE_ATTR)
+ if xsi_nil:
+ attribute_names.append(XML_SCHEMA_INSTANCE_NIL_ATTR)
+
+ _strip_attributes(element_or_tree, *attribute_names)
+ if cleanup_namespaces:
+ _cleanup_namespaces(element_or_tree)
+
+################################################################################
+# Module level parser setup
+
+cdef object __DEFAULT_PARSER
+__DEFAULT_PARSER = etree.XMLParser(remove_blank_text=True)
+__DEFAULT_PARSER.set_element_class_lookup( ObjectifyElementClassLookup() )
+
+cdef object objectify_parser
+objectify_parser = __DEFAULT_PARSER
+
+def set_default_parser(new_parser = None):
+ """set_default_parser(new_parser = None)
+
+ Replace the default parser used by objectify's Element() and
+ fromstring() functions.
+
+ The new parser must be an etree.XMLParser.
+
+ Call without arguments to reset to the original parser.
+ """
+ global objectify_parser
+ if new_parser is None:
+ objectify_parser = __DEFAULT_PARSER
+ elif isinstance(new_parser, etree.XMLParser):
+ objectify_parser = new_parser
+ else:
+ raise TypeError, "parser must inherit from lxml.etree.XMLParser"
+
+def makeparser(**kw):
+ """makeparser(remove_blank_text=True, **kw)
+
+ Create a new XML parser for objectify trees.
+
+ You can pass all keyword arguments that are supported by
+ ``etree.XMLParser()``. Note that this parser defaults to removing
+ blank text. You can disable this by passing the
+ ``remove_blank_text`` boolean keyword option yourself.
+ """
+ if 'remove_blank_text' not in kw:
+ kw['remove_blank_text'] = True
+ parser = etree.XMLParser(**kw)
+ parser.set_element_class_lookup( ObjectifyElementClassLookup() )
+ return parser
+
+cdef _Element _makeElement(tag, text, attrib, nsmap):
+ return cetree.makeElement(tag, None, objectify_parser, text, None, attrib, nsmap)
+
+################################################################################
+# Module level factory functions
+
+cdef object _fromstring
+_fromstring = etree.fromstring
+
+SubElement = etree.SubElement
+
+def fromstring(xml, parser=None, *, base_url=None):
+ """fromstring(xml, parser=None, base_url=None)
+
+ Objectify specific version of the lxml.etree fromstring() function
+ that uses the objectify parser.
+
+ You can pass a different parser as second argument.
+
+ The ``base_url`` keyword argument allows to set the original base URL of
+ the document to support relative Paths when looking up external entities
+ (DTD, XInclude, ...).
+ """
+ if parser is None:
+ parser = objectify_parser
+ return _fromstring(xml, parser, base_url=base_url)
+
+def XML(xml, parser=None, *, base_url=None):
+ """XML(xml, parser=None, base_url=None)
+
+ Objectify specific version of the lxml.etree XML() literal factory
+ that uses the objectify parser.
+
+ You can pass a different parser as second argument.
+
+ The ``base_url`` keyword argument allows to set the original base URL of
+ the document to support relative Paths when looking up external entities
+ (DTD, XInclude, ...).
+ """
+ if parser is None:
+ parser = objectify_parser
+ return _fromstring(xml, parser, base_url=base_url)
+
+cdef object _parse
+_parse = etree.parse
+
+def parse(f, parser=None, *, base_url=None):
+ """parse(f, parser=None, base_url=None)
+
+ Parse a file or file-like object with the objectify parser.
+
+ You can pass a different parser as second argument.
+
+ The ``base_url`` keyword allows setting a URL for the document
+ when parsing from a file-like object. This is needed when looking
+ up external entities (DTD, XInclude, ...) with relative paths.
+ """
+ if parser is None:
+ parser = objectify_parser
+ return _parse(f, parser, base_url=base_url)
+
+cdef dict _DEFAULT_NSMAP = {
+ "py" : PYTYPE_NAMESPACE,
+ "xsi" : XML_SCHEMA_INSTANCE_NS,
+ "xsd" : XML_SCHEMA_NS
+}
+
+E = ElementMaker()
+
+def Element(_tag, attrib=None, nsmap=None, *, _pytype=None, **_attributes):
+ """Element(_tag, attrib=None, nsmap=None, _pytype=None, **_attributes)
+
+ Objectify specific version of the lxml.etree Element() factory that
+ always creates a structural (tree) element.
+
+ NOTE: requires parser based element class lookup activated in lxml.etree!
+ """
+ if attrib is not None:
+ if _attributes:
+ attrib = dict(attrib)
+ attrib.update(_attributes)
+ _attributes = attrib
+ if _pytype is None:
+ _pytype = TREE_PYTYPE_NAME
+ if nsmap is None:
+ nsmap = _DEFAULT_NSMAP
+ _attributes[PYTYPE_ATTRIBUTE] = _pytype
+ return _makeElement(_tag, None, _attributes, nsmap)
+
+def DataElement(_value, attrib=None, nsmap=None, *, _pytype=None, _xsi=None,
+ **_attributes):
+ """DataElement(_value, attrib=None, nsmap=None, _pytype=None, _xsi=None, **_attributes)
+
+ Create a new element from a Python value and XML attributes taken from
+ keyword arguments or a dictionary passed as second argument.
+
+ Automatically adds a 'pytype' attribute for the Python type of the value,
+ if the type can be identified. If '_pytype' or '_xsi' are among the
+ keyword arguments, they will be used instead.
+
+ If the _value argument is an ObjectifiedDataElement instance, its py:pytype,
+ xsi:type and other attributes and nsmap are reused unless they are redefined
+ in attrib and/or keyword arguments.
+ """
+ if nsmap is None:
+ nsmap = _DEFAULT_NSMAP
+ if attrib is not None and attrib:
+ if _attributes:
+ attrib = dict(attrib)
+ attrib.update(_attributes)
+ _attributes = attrib
+ if isinstance(_value, ObjectifiedElement):
+ if _pytype is None:
+ if _xsi is None and not _attributes and nsmap is _DEFAULT_NSMAP:
+ # special case: no change!
+ return _value.__copy__()
+ if isinstance(_value, ObjectifiedDataElement):
+ # reuse existing nsmap unless redefined in nsmap parameter
+ temp = _value.nsmap
+ if temp is not None and temp:
+ temp = dict(temp)
+ temp.update(nsmap)
+ nsmap = temp
+ # reuse existing attributes unless redefined in attrib/_attributes
+ temp = _value.attrib
+ if temp is not None and temp:
+ temp = dict(temp)
+ temp.update(_attributes)
+ _attributes = temp
+ # reuse existing xsi:type or py:pytype attributes, unless provided as
+ # arguments
+ if _xsi is None and _pytype is None:
+ _xsi = _attributes.get(XML_SCHEMA_INSTANCE_TYPE_ATTR)
+ _pytype = _attributes.get(PYTYPE_ATTRIBUTE)
+
+ if _xsi is not None:
+ if ':' in _xsi:
+ prefix, name = _xsi.split(':', 1)
+ ns = nsmap.get(prefix)
+ if ns != XML_SCHEMA_NS:
+ raise ValueError, "XSD types require the XSD namespace"
+ elif nsmap is _DEFAULT_NSMAP:
+ name = _xsi
+ _xsi = 'xsd:' + _xsi
+ else:
+ name = _xsi
+ for prefix, ns in nsmap.items():
+ if ns == XML_SCHEMA_NS:
+ if prefix is not None and prefix:
+ _xsi = prefix + ':' + _xsi
+ break
+ else:
+ raise ValueError, "XSD types require the XSD namespace"
+ _attributes[XML_SCHEMA_INSTANCE_TYPE_ATTR] = _xsi
+ if _pytype is None:
+ # allow using unregistered or even wrong xsi:type names
+ py_type = _SCHEMA_TYPE_DICT.get(_xsi)
+ if py_type is None:
+ py_type = _SCHEMA_TYPE_DICT.get(name)
+ if py_type is not None:
+ _pytype = py_type.name
+
+ if _pytype is None:
+ _pytype = _pytypename(_value)
+
+ if _value is None and _pytype != "str":
+ _pytype = _pytype or "NoneType"
+ strval = None
+ elif python._isString(_value):
+ strval = _value
+ elif isinstance(_value, bool):
+ if _value:
+ strval = "true"
+ else:
+ strval = "false"
+ else:
+ py_type = _PYTYPE_DICT.get(_pytype)
+ stringify = unicode if py_type is None else py_type.stringify
+ strval = stringify(_value)
+
+ if _pytype is not None:
+ if _pytype == "NoneType" or _pytype == "none":
+ strval = None
+ _attributes[XML_SCHEMA_INSTANCE_NIL_ATTR] = "true"
+ else:
+ # check if type information from arguments is valid
+ py_type = _PYTYPE_DICT.get(_pytype)
+ if py_type is not None:
+ if py_type.type_check is not None:
+ py_type.type_check(strval)
+ _attributes[PYTYPE_ATTRIBUTE] = _pytype
+
+ return _makeElement("value", strval, _attributes, nsmap)
+
+
+################################################################################
+# ObjectPath
+
+include "objectpath.pxi"
diff --git a/llmeval-env/lib/python3.10/site-packages/lxml/parser.pxi b/llmeval-env/lib/python3.10/site-packages/lxml/parser.pxi
new file mode 100644
index 0000000000000000000000000000000000000000..ff07dcdd3ebd341a8e02b7cebb9c01f3255a2edd
--- /dev/null
+++ b/llmeval-env/lib/python3.10/site-packages/lxml/parser.pxi
@@ -0,0 +1,1994 @@
+# Parsers for XML and HTML
+
+from lxml.includes cimport xmlparser
+from lxml.includes cimport htmlparser
+
+
+class ParseError(LxmlSyntaxError):
+ """Syntax error while parsing an XML document.
+
+ For compatibility with ElementTree 1.3 and later.
+ """
+ def __init__(self, message, code, line, column, filename=None):
+ super(_ParseError, self).__init__(message)
+ self.lineno, self.offset = (line, column - 1)
+ self.code = code
+ self.filename = filename
+
+ @property
+ def position(self):
+ return self.lineno, self.offset + 1
+
+ @position.setter
+ def position(self, new_pos):
+ self.lineno, column = new_pos
+ self.offset = column - 1
+
+cdef object _ParseError = ParseError
+
+
+class XMLSyntaxError(ParseError):
+ """Syntax error while parsing an XML document.
+ """
+
+cdef class ParserError(LxmlError):
+ """Internal lxml parser error.
+ """
+
+
+@cython.final
+@cython.internal
+cdef class _ParserDictionaryContext:
+ # Global parser context to share the string dictionary.
+ #
+ # This class is a delegate singleton!
+ #
+ # It creates _ParserDictionaryContext objects for each thread to keep thread state,
+ # but those must never be used directly. Always stick to using the static
+ # __GLOBAL_PARSER_CONTEXT as defined below the class.
+ #
+
+ cdef tree.xmlDict* _c_dict
+ cdef _BaseParser _default_parser
+ cdef list _implied_parser_contexts
+
+ def __cinit__(self):
+ self._c_dict = NULL
+ self._implied_parser_contexts = []
+
+ def __dealloc__(self):
+ if self._c_dict is not NULL:
+ xmlparser.xmlDictFree(self._c_dict)
+
+ cdef int initMainParserContext(self) except -1:
+ """Put the global context into the thread dictionary of the main
+ thread. To be called once and only in the main thread."""
+ thread_dict = python.PyThreadState_GetDict()
+ if thread_dict is not NULL:
+ (thread_dict)["_ParserDictionaryContext"] = self
+
+ cdef _ParserDictionaryContext _findThreadParserContext(self):
+ "Find (or create) the _ParserDictionaryContext object for the current thread"
+ cdef _ParserDictionaryContext context
+ thread_dict = python.PyThreadState_GetDict()
+ if thread_dict is NULL:
+ return self
+ d = thread_dict
+ result = python.PyDict_GetItem(d, "_ParserDictionaryContext")
+ if result is not NULL:
+ return