asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T ElementTree.py000064400000221237151027357230007343 0ustar00"""Lightweight XML support for Python. XML is an inherently hierarchical data format, and the most natural way to represent it is with a tree. This module has two classes for this purpose: 1. ElementTree represents the whole XML document as a tree and 2. Element represents a single node in this tree. Interactions with the whole document (reading and writing to/from files) are usually done on the ElementTree level. Interactions with a single XML element and its sub-elements are done on the Element level. Element is a flexible container object designed to store hierarchical data structures in memory. It can be described as a cross between a list and a dictionary. Each Element has a number of properties associated with it: 'tag' - a string containing the element's name. 'attributes' - a Python dictionary storing the element's attributes. 'text' - a string containing the element's text content. 'tail' - an optional string containing text after the element's end tag. And a number of child elements stored in a Python sequence. To create an element instance, use the Element constructor, or the SubElement factory function. You can also use the ElementTree class to wrap an element structure and convert it to and from XML. """ #--------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See https://www.python.org/psf/license for licensing details. # # ElementTree # Copyright (c) 1999-2008 by Fredrik Lundh. All rights reserved. # # fredrik@pythonware.com # http://www.pythonware.com # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2008 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. # -------------------------------------------------------------------- __all__ = [ # public symbols "Comment", "dump", "Element", "ElementTree", "fromstring", "fromstringlist", "indent", "iselement", "iterparse", "parse", "ParseError", "PI", "ProcessingInstruction", "QName", "SubElement", "tostring", "tostringlist", "TreeBuilder", "VERSION", "XML", "XMLID", "XMLParser", "XMLPullParser", "register_namespace", "canonicalize", "C14NWriterTarget", ] VERSION = "1.3.0" import sys import re import warnings import io import collections import collections.abc import contextlib import weakref from . import ElementPath class ParseError(SyntaxError): """An error when parsing an XML document. In addition to its exception value, a ParseError contains two extra attributes: 'code' - the specific exception code 'position' - the line and column of the error """ pass # -------------------------------------------------------------------- def iselement(element): """Return True if *element* appears to be an Element.""" return hasattr(element, 'tag') class Element: """An XML element. This class is the reference implementation of the Element interface. An element's length is its number of subelements. That means if you want to check if an element is truly empty, you should check BOTH its length AND its text attribute. The element tag, attribute names, and attribute values can be either bytes or strings. *tag* is the element name. *attrib* is an optional dictionary containing element attributes. *extra* are additional element attributes given as keyword arguments. Example form: text...tail """ tag = None """The element's name.""" attrib = None """Dictionary of the element's attributes.""" text = None """ Text before first subelement. This is either a string or the value None. Note that if there is no text, this attribute may be either None or the empty string, depending on the parser. """ tail = None """ Text after this element's end tag, but before the next sibling element's start tag. This is either a string or the value None. Note that if there was no text, this attribute may be either None or an empty string, depending on the parser. """ def __init__(self, tag, attrib={}, **extra): if not isinstance(attrib, dict): raise TypeError("attrib must be dict, not %s" % ( attrib.__class__.__name__,)) self.tag = tag self.attrib = {**attrib, **extra} self._children = [] def __repr__(self): return "<%s %r at %#x>" % (self.__class__.__name__, self.tag, id(self)) def makeelement(self, tag, attrib): """Create a new element with the same type. *tag* is a string containing the element name. *attrib* is a dictionary containing the element attributes. Do not call this method, use the SubElement factory function instead. """ return self.__class__(tag, attrib) def copy(self): """Return copy of current element. This creates a shallow copy. Subelements will be shared with the original tree. """ warnings.warn( "elem.copy() is deprecated. Use copy.copy(elem) instead.", DeprecationWarning ) return self.__copy__() def __copy__(self): elem = self.makeelement(self.tag, self.attrib) elem.text = self.text elem.tail = self.tail elem[:] = self return elem def __len__(self): return len(self._children) def __bool__(self): warnings.warn( "The behavior of this method will change in future versions. " "Use specific 'len(elem)' or 'elem is not None' test instead.", FutureWarning, stacklevel=2 ) return len(self._children) != 0 # emulate old behaviour, for now def __getitem__(self, index): return self._children[index] def __setitem__(self, index, element): if isinstance(index, slice): for elt in element: self._assert_is_element(elt) else: self._assert_is_element(element) self._children[index] = element def __delitem__(self, index): del self._children[index] def append(self, subelement): """Add *subelement* to the end of this element. The new element will appear in document order after the last existing subelement (or directly after the text, if it's the first subelement), but before the end tag for this element. """ self._assert_is_element(subelement) self._children.append(subelement) def extend(self, elements): """Append subelements from a sequence. *elements* is a sequence with zero or more elements. """ for element in elements: self._assert_is_element(element) self._children.append(element) def insert(self, index, subelement): """Insert *subelement* at position *index*.""" self._assert_is_element(subelement) self._children.insert(index, subelement) def _assert_is_element(self, e): # Need to refer to the actual Python implementation, not the # shadowing C implementation. if not isinstance(e, _Element_Py): raise TypeError('expected an Element, not %s' % type(e).__name__) def remove(self, subelement): """Remove matching subelement. Unlike the find methods, this method compares elements based on identity, NOT ON tag value or contents. To remove subelements by other means, the easiest way is to use a list comprehension to select what elements to keep, and then use slice assignment to update the parent element. ValueError is raised if a matching element could not be found. """ # assert iselement(element) self._children.remove(subelement) def find(self, path, namespaces=None): """Find first matching element by tag name or path. *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return the first matching element, or None if no element was found. """ return ElementPath.find(self, path, namespaces) def findtext(self, path, default=None, namespaces=None): """Find text for first matching element by tag name or path. *path* is a string having either an element tag or an XPath, *default* is the value to return if the element was not found, *namespaces* is an optional mapping from namespace prefix to full name. Return text content of first matching element, or default value if none was found. Note that if an element is found having no text content, the empty string is returned. """ return ElementPath.findtext(self, path, default, namespaces) def findall(self, path, namespaces=None): """Find all matching subelements by tag name or path. *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Returns list containing all matching elements in document order. """ return ElementPath.findall(self, path, namespaces) def iterfind(self, path, namespaces=None): """Find all matching subelements by tag name or path. *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return an iterable yielding all matching elements in document order. """ return ElementPath.iterfind(self, path, namespaces) def clear(self): """Reset element. This function removes all subelements, clears all attributes, and sets the text and tail attributes to None. """ self.attrib.clear() self._children = [] self.text = self.tail = None def get(self, key, default=None): """Get element attribute. Equivalent to attrib.get, but some implementations may handle this a bit more efficiently. *key* is what attribute to look for, and *default* is what to return if the attribute was not found. Returns a string containing the attribute value, or the default if attribute was not found. """ return self.attrib.get(key, default) def set(self, key, value): """Set element attribute. Equivalent to attrib[key] = value, but some implementations may handle this a bit more efficiently. *key* is what attribute to set, and *value* is the attribute value to set it to. """ self.attrib[key] = value def keys(self): """Get list of attribute names. Names are returned in an arbitrary order, just like an ordinary Python dict. Equivalent to attrib.keys() """ return self.attrib.keys() def items(self): """Get element attributes as a sequence. The attributes are returned in arbitrary order. Equivalent to attrib.items(). Return a list of (name, value) tuples. """ return self.attrib.items() def iter(self, tag=None): """Create tree iterator. The iterator loops over the element and all subelements in document order, returning all elements with a matching tag. If the tree structure is modified during iteration, new or removed elements may or may not be included. To get a stable set, use the list() function on the iterator, and loop over the resulting list. *tag* is what tags to look for (default is to return all elements) Return an iterator containing all the matching elements. """ if tag == "*": tag = None if tag is None or self.tag == tag: yield self for e in self._children: yield from e.iter(tag) def itertext(self): """Create text iterator. The iterator loops over the element and all subelements in document order, returning all inner text. """ tag = self.tag if not isinstance(tag, str) and tag is not None: return t = self.text if t: yield t for e in self: yield from e.itertext() t = e.tail if t: yield t def SubElement(parent, tag, attrib={}, **extra): """Subelement factory which creates an element instance, and appends it to an existing parent. The element tag, attribute names, and attribute values can be either bytes or Unicode strings. *parent* is the parent element, *tag* is the subelements name, *attrib* is an optional directory containing element attributes, *extra* are additional attributes given as keyword arguments. """ attrib = {**attrib, **extra} element = parent.makeelement(tag, attrib) parent.append(element) return element def Comment(text=None): """Comment element factory. This function creates a special element which the standard serializer serializes as an XML comment. *text* is a string containing the comment string. """ element = Element(Comment) element.text = text return element def ProcessingInstruction(target, text=None): """Processing Instruction element factory. This function creates a special element which the standard serializer serializes as an XML comment. *target* is a string containing the processing instruction, *text* is a string containing the processing instruction contents, if any. """ element = Element(ProcessingInstruction) element.text = target if text: element.text = element.text + " " + text return element PI = ProcessingInstruction class QName: """Qualified name wrapper. This class can be used to wrap a QName attribute value in order to get proper namespace handing on output. *text_or_uri* is a string containing the QName value either in the form {uri}local, or if the tag argument is given, the URI part of a QName. *tag* is an optional argument which if given, will make the first argument (text_or_uri) be interpreted as a URI, and this argument (tag) be interpreted as a local name. """ def __init__(self, text_or_uri, tag=None): if tag: text_or_uri = "{%s}%s" % (text_or_uri, tag) self.text = text_or_uri def __str__(self): return self.text def __repr__(self): return '<%s %r>' % (self.__class__.__name__, self.text) def __hash__(self): return hash(self.text) def __le__(self, other): if isinstance(other, QName): return self.text <= other.text return self.text <= other def __lt__(self, other): if isinstance(other, QName): return self.text < other.text return self.text < other def __ge__(self, other): if isinstance(other, QName): return self.text >= other.text return self.text >= other def __gt__(self, other): if isinstance(other, QName): return self.text > other.text return self.text > other def __eq__(self, other): if isinstance(other, QName): return self.text == other.text return self.text == other # -------------------------------------------------------------------- class ElementTree: """An XML element hierarchy. This class also provides support for serialization to and from standard XML. *element* is an optional root element node, *file* is an optional file handle or file name of an XML file whose contents will be used to initialize the tree with. """ def __init__(self, element=None, file=None): # assert element is None or iselement(element) self._root = element # first node if file: self.parse(file) def getroot(self): """Return root element of this tree.""" return self._root def _setroot(self, element): """Replace root element of this tree. This will discard the current contents of the tree and replace it with the given element. Use with care! """ # assert iselement(element) self._root = element def parse(self, source, parser=None): """Load external XML document into element tree. *source* is a file name or file object, *parser* is an optional parser instance that defaults to XMLParser. ParseError is raised if the parser fails to parse the document. Returns the root element of the given source document. """ close_source = False if not hasattr(source, "read"): source = open(source, "rb") close_source = True try: if parser is None: # If no parser was specified, create a default XMLParser parser = XMLParser() if hasattr(parser, '_parse_whole'): # The default XMLParser, when it comes from an accelerator, # can define an internal _parse_whole API for efficiency. # It can be used to parse the whole source without feeding # it with chunks. self._root = parser._parse_whole(source) return self._root while True: data = source.read(65536) if not data: break parser.feed(data) self._root = parser.close() return self._root finally: if close_source: source.close() def iter(self, tag=None): """Create and return tree iterator for the root element. The iterator loops over all elements in this tree, in document order. *tag* is a string with the tag name to iterate over (default is to return all elements). """ # assert self._root is not None return self._root.iter(tag) def find(self, path, namespaces=None): """Find first matching element by tag name or path. Same as getroot().find(path), which is Element.find() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return the first matching element, or None if no element was found. """ # assert self._root is not None if path[:1] == "/": path = "." + path warnings.warn( "This search is broken in 1.3 and earlier, and will be " "fixed in a future version. If you rely on the current " "behaviour, change it to %r" % path, FutureWarning, stacklevel=2 ) return self._root.find(path, namespaces) def findtext(self, path, default=None, namespaces=None): """Find first matching element by tag name or path. Same as getroot().findtext(path), which is Element.findtext() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return the first matching element, or None if no element was found. """ # assert self._root is not None if path[:1] == "/": path = "." + path warnings.warn( "This search is broken in 1.3 and earlier, and will be " "fixed in a future version. If you rely on the current " "behaviour, change it to %r" % path, FutureWarning, stacklevel=2 ) return self._root.findtext(path, default, namespaces) def findall(self, path, namespaces=None): """Find all matching subelements by tag name or path. Same as getroot().findall(path), which is Element.findall(). *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return list containing all matching elements in document order. """ # assert self._root is not None if path[:1] == "/": path = "." + path warnings.warn( "This search is broken in 1.3 and earlier, and will be " "fixed in a future version. If you rely on the current " "behaviour, change it to %r" % path, FutureWarning, stacklevel=2 ) return self._root.findall(path, namespaces) def iterfind(self, path, namespaces=None): """Find all matching subelements by tag name or path. Same as getroot().iterfind(path), which is element.iterfind() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return an iterable yielding all matching elements in document order. """ # assert self._root is not None if path[:1] == "/": path = "." + path warnings.warn( "This search is broken in 1.3 and earlier, and will be " "fixed in a future version. If you rely on the current " "behaviour, change it to %r" % path, FutureWarning, stacklevel=2 ) return self._root.iterfind(path, namespaces) def write(self, file_or_filename, encoding=None, xml_declaration=None, default_namespace=None, method=None, *, short_empty_elements=True): """Write element tree to a file as XML. Arguments: *file_or_filename* -- file name or a file object opened for writing *encoding* -- the output encoding (default: US-ASCII) *xml_declaration* -- bool indicating if an XML declaration should be added to the output. If None, an XML declaration is added if encoding IS NOT either of: US-ASCII, UTF-8, or Unicode *default_namespace* -- sets the default XML namespace (for "xmlns") *method* -- either "xml" (default), "html, "text", or "c14n" *short_empty_elements* -- controls the formatting of elements that contain no content. If True (default) they are emitted as a single self-closed tag, otherwise they are emitted as a pair of start/end tags """ if not method: method = "xml" elif method not in _serialize: raise ValueError("unknown method %r" % method) if not encoding: if method == "c14n": encoding = "utf-8" else: encoding = "us-ascii" with _get_writer(file_or_filename, encoding) as (write, declared_encoding): if method == "xml" and (xml_declaration or (xml_declaration is None and encoding.lower() != "unicode" and declared_encoding.lower() not in ("utf-8", "us-ascii"))): write("\n" % ( declared_encoding,)) if method == "text": _serialize_text(write, self._root) else: qnames, namespaces = _namespaces(self._root, default_namespace) serialize = _serialize[method] serialize(write, self._root, qnames, namespaces, short_empty_elements=short_empty_elements) def write_c14n(self, file): # lxml.etree compatibility. use output method instead return self.write(file, method="c14n") # -------------------------------------------------------------------- # serialization support @contextlib.contextmanager def _get_writer(file_or_filename, encoding): # returns text write method and release all resources after using try: write = file_or_filename.write except AttributeError: # file_or_filename is a file name if encoding.lower() == "unicode": encoding="utf-8" with open(file_or_filename, "w", encoding=encoding, errors="xmlcharrefreplace") as file: yield file.write, encoding else: # file_or_filename is a file-like object # encoding determines if it is a text or binary writer if encoding.lower() == "unicode": # use a text writer as is yield write, getattr(file_or_filename, "encoding", None) or "utf-8" else: # wrap a binary writer with TextIOWrapper with contextlib.ExitStack() as stack: if isinstance(file_or_filename, io.BufferedIOBase): file = file_or_filename elif isinstance(file_or_filename, io.RawIOBase): file = io.BufferedWriter(file_or_filename) # Keep the original file open when the BufferedWriter is # destroyed stack.callback(file.detach) else: # This is to handle passed objects that aren't in the # IOBase hierarchy, but just have a write method file = io.BufferedIOBase() file.writable = lambda: True file.write = write try: # TextIOWrapper uses this methods to determine # if BOM (for UTF-16, etc) should be added file.seekable = file_or_filename.seekable file.tell = file_or_filename.tell except AttributeError: pass file = io.TextIOWrapper(file, encoding=encoding, errors="xmlcharrefreplace", newline="\n") # Keep the original file open when the TextIOWrapper is # destroyed stack.callback(file.detach) yield file.write, encoding def _namespaces(elem, default_namespace=None): # identify namespaces used in this tree # maps qnames to *encoded* prefix:local names qnames = {None: None} # maps uri:s to prefixes namespaces = {} if default_namespace: namespaces[default_namespace] = "" def add_qname(qname): # calculate serialized qname representation try: if qname[:1] == "{": uri, tag = qname[1:].rsplit("}", 1) prefix = namespaces.get(uri) if prefix is None: prefix = _namespace_map.get(uri) if prefix is None: prefix = "ns%d" % len(namespaces) if prefix != "xml": namespaces[uri] = prefix if prefix: qnames[qname] = "%s:%s" % (prefix, tag) else: qnames[qname] = tag # default element else: if default_namespace: # FIXME: can this be handled in XML 1.0? raise ValueError( "cannot use non-qualified names with " "default_namespace option" ) qnames[qname] = qname except TypeError: _raise_serialization_error(qname) # populate qname and namespaces table for elem in elem.iter(): tag = elem.tag if isinstance(tag, QName): if tag.text not in qnames: add_qname(tag.text) elif isinstance(tag, str): if tag not in qnames: add_qname(tag) elif tag is not None and tag is not Comment and tag is not PI: _raise_serialization_error(tag) for key, value in elem.items(): if isinstance(key, QName): key = key.text if key not in qnames: add_qname(key) if isinstance(value, QName) and value.text not in qnames: add_qname(value.text) text = elem.text if isinstance(text, QName) and text.text not in qnames: add_qname(text.text) return qnames, namespaces def _serialize_xml(write, elem, qnames, namespaces, short_empty_elements, **kwargs): tag = elem.tag text = elem.text if tag is Comment: write("" % text) elif tag is ProcessingInstruction: write("" % text) else: tag = qnames[tag] if tag is None: if text: write(_escape_cdata(text)) for e in elem: _serialize_xml(write, e, qnames, None, short_empty_elements=short_empty_elements) else: write("<" + tag) items = list(elem.items()) if items or namespaces: if namespaces: for v, k in sorted(namespaces.items(), key=lambda x: x[1]): # sort on prefix if k: k = ":" + k write(" xmlns%s=\"%s\"" % ( k, _escape_attrib(v) )) for k, v in items: if isinstance(k, QName): k = k.text if isinstance(v, QName): v = qnames[v.text] else: v = _escape_attrib(v) write(" %s=\"%s\"" % (qnames[k], v)) if text or len(elem) or not short_empty_elements: write(">") if text: write(_escape_cdata(text)) for e in elem: _serialize_xml(write, e, qnames, None, short_empty_elements=short_empty_elements) write("") else: write(" />") if elem.tail: write(_escape_cdata(elem.tail)) HTML_EMPTY = {"area", "base", "basefont", "br", "col", "embed", "frame", "hr", "img", "input", "isindex", "link", "meta", "param", "source", "track", "wbr"} def _serialize_html(write, elem, qnames, namespaces, **kwargs): tag = elem.tag text = elem.text if tag is Comment: write("" % _escape_cdata(text)) elif tag is ProcessingInstruction: write("" % _escape_cdata(text)) else: tag = qnames[tag] if tag is None: if text: write(_escape_cdata(text)) for e in elem: _serialize_html(write, e, qnames, None) else: write("<" + tag) items = list(elem.items()) if items or namespaces: if namespaces: for v, k in sorted(namespaces.items(), key=lambda x: x[1]): # sort on prefix if k: k = ":" + k write(" xmlns%s=\"%s\"" % ( k, _escape_attrib(v) )) for k, v in items: if isinstance(k, QName): k = k.text if isinstance(v, QName): v = qnames[v.text] else: v = _escape_attrib_html(v) # FIXME: handle boolean attributes write(" %s=\"%s\"" % (qnames[k], v)) write(">") ltag = tag.lower() if text: if ltag == "script" or ltag == "style": write(text) else: write(_escape_cdata(text)) for e in elem: _serialize_html(write, e, qnames, None) if ltag not in HTML_EMPTY: write("") if elem.tail: write(_escape_cdata(elem.tail)) def _serialize_text(write, elem): for part in elem.itertext(): write(part) if elem.tail: write(elem.tail) _serialize = { "xml": _serialize_xml, "html": _serialize_html, "text": _serialize_text, # this optional method is imported at the end of the module # "c14n": _serialize_c14n, } def register_namespace(prefix, uri): """Register a namespace prefix. The registry is global, and any existing mapping for either the given prefix or the namespace URI will be removed. *prefix* is the namespace prefix, *uri* is a namespace uri. Tags and attributes in this namespace will be serialized with prefix if possible. ValueError is raised if prefix is reserved or is invalid. """ if re.match(r"ns\d+$", prefix): raise ValueError("Prefix format reserved for internal use") for k, v in list(_namespace_map.items()): if k == uri or v == prefix: del _namespace_map[k] _namespace_map[uri] = prefix _namespace_map = { # "well-known" namespace prefixes "http://www.w3.org/XML/1998/namespace": "xml", "http://www.w3.org/1999/xhtml": "html", "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf", "http://schemas.xmlsoap.org/wsdl/": "wsdl", # xml schema "http://www.w3.org/2001/XMLSchema": "xs", "http://www.w3.org/2001/XMLSchema-instance": "xsi", # dublin core "http://purl.org/dc/elements/1.1/": "dc", } # For tests and troubleshooting register_namespace._namespace_map = _namespace_map def _raise_serialization_error(text): raise TypeError( "cannot serialize %r (type %s)" % (text, type(text).__name__) ) def _escape_cdata(text): # escape character data try: # it's worth avoiding do-nothing calls for strings that are # shorter than 500 characters, or so. assume that's, by far, # the most common case in most applications. if "&" in text: text = text.replace("&", "&") if "<" in text: text = text.replace("<", "<") if ">" in text: text = text.replace(">", ">") return text except (TypeError, AttributeError): _raise_serialization_error(text) def _escape_attrib(text): # escape attribute value try: if "&" in text: text = text.replace("&", "&") if "<" in text: text = text.replace("<", "<") if ">" in text: text = text.replace(">", ">") if "\"" in text: text = text.replace("\"", """) # Although section 2.11 of the XML specification states that CR or # CR LN should be replaced with just LN, it applies only to EOLNs # which take part of organizing file into lines. Within attributes, # we are replacing these with entity numbers, so they do not count. # http://www.w3.org/TR/REC-xml/#sec-line-ends # The current solution, contained in following six lines, was # discussed in issue 17582 and 39011. if "\r" in text: text = text.replace("\r", " ") if "\n" in text: text = text.replace("\n", " ") if "\t" in text: text = text.replace("\t", " ") return text except (TypeError, AttributeError): _raise_serialization_error(text) def _escape_attrib_html(text): # escape attribute value try: if "&" in text: text = text.replace("&", "&") if ">" in text: text = text.replace(">", ">") if "\"" in text: text = text.replace("\"", """) return text except (TypeError, AttributeError): _raise_serialization_error(text) # -------------------------------------------------------------------- def tostring(element, encoding=None, method=None, *, xml_declaration=None, default_namespace=None, short_empty_elements=True): """Generate string representation of XML element. All subelements are included. If encoding is "unicode", a string is returned. Otherwise a bytestring is returned. *element* is an Element instance, *encoding* is an optional output encoding defaulting to US-ASCII, *method* is an optional output which can be one of "xml" (default), "html", "text" or "c14n", *default_namespace* sets the default XML namespace (for "xmlns"). Returns an (optionally) encoded string containing the XML data. """ stream = io.StringIO() if encoding == 'unicode' else io.BytesIO() ElementTree(element).write(stream, encoding, xml_declaration=xml_declaration, default_namespace=default_namespace, method=method, short_empty_elements=short_empty_elements) return stream.getvalue() class _ListDataStream(io.BufferedIOBase): """An auxiliary stream accumulating into a list reference.""" def __init__(self, lst): self.lst = lst def writable(self): return True def seekable(self): return True def write(self, b): self.lst.append(b) def tell(self): return len(self.lst) def tostringlist(element, encoding=None, method=None, *, xml_declaration=None, default_namespace=None, short_empty_elements=True): lst = [] stream = _ListDataStream(lst) ElementTree(element).write(stream, encoding, xml_declaration=xml_declaration, default_namespace=default_namespace, method=method, short_empty_elements=short_empty_elements) return lst def dump(elem): """Write element tree or element structure to sys.stdout. This function should be used for debugging only. *elem* is either an ElementTree, or a single Element. The exact output format is implementation dependent. In this version, it's written as an ordinary XML file. """ # debugging if not isinstance(elem, ElementTree): elem = ElementTree(elem) elem.write(sys.stdout, encoding="unicode") tail = elem.getroot().tail if not tail or tail[-1] != "\n": sys.stdout.write("\n") def indent(tree, space=" ", level=0): """Indent an XML document by inserting newlines and indentation space after elements. *tree* is the ElementTree or Element to modify. The (root) element itself will not be changed, but the tail text of all elements in its subtree will be adapted. *space* is the whitespace to insert for each indentation level, two space characters by default. *level* is the initial indentation level. Setting this to a higher value than 0 can be used for indenting subtrees that are more deeply nested inside of a document. """ if isinstance(tree, ElementTree): tree = tree.getroot() if level < 0: raise ValueError(f"Initial indentation level must be >= 0, got {level}") if not len(tree): return # Reduce the memory consumption by reusing indentation strings. indentations = ["\n" + level * space] def _indent_children(elem, level): # Start a new indentation level for the first child. child_level = level + 1 try: child_indentation = indentations[child_level] except IndexError: child_indentation = indentations[level] + space indentations.append(child_indentation) if not elem.text or not elem.text.strip(): elem.text = child_indentation for child in elem: if len(child): _indent_children(child, child_level) if not child.tail or not child.tail.strip(): child.tail = child_indentation # Dedent after the last child by overwriting the previous indentation. if not child.tail.strip(): child.tail = indentations[level] _indent_children(tree, 0) # -------------------------------------------------------------------- # parsing def parse(source, parser=None): """Parse XML document into element tree. *source* is a filename or file object containing XML data, *parser* is an optional parser instance defaulting to XMLParser. Return an ElementTree instance. """ tree = ElementTree() tree.parse(source, parser) return tree def iterparse(source, events=None, parser=None): """Incrementally parse XML document into ElementTree. This class also reports what's going on to the user based on the *events* it is initialized with. The supported events are the strings "start", "end", "start-ns" and "end-ns" (the "ns" events are used to get detailed namespace information). If *events* is omitted, only "end" events are reported. *source* is a filename or file object containing XML data, *events* is a list of events to report back, *parser* is an optional parser instance. Returns an iterator providing (event, elem) pairs. """ # Use the internal, undocumented _parser argument for now; When the # parser argument of iterparse is removed, this can be killed. pullparser = XMLPullParser(events=events, _parser=parser) if not hasattr(source, "read"): source = open(source, "rb") close_source = True else: close_source = False def iterator(source): try: while True: yield from pullparser.read_events() # load event buffer data = source.read(16 * 1024) if not data: break pullparser.feed(data) root = pullparser._close_and_return_root() yield from pullparser.read_events() it = wr() if it is not None: it.root = root finally: if close_source: source.close() class IterParseIterator(collections.abc.Iterator): __next__ = iterator(source).__next__ def __del__(self): if close_source: source.close() it = IterParseIterator() it.root = None wr = weakref.ref(it) return it class XMLPullParser: def __init__(self, events=None, *, _parser=None): # The _parser argument is for internal use only and must not be relied # upon in user code. It will be removed in a future release. # See https://bugs.python.org/issue17741 for more details. self._events_queue = collections.deque() self._parser = _parser or XMLParser(target=TreeBuilder()) # wire up the parser for event reporting if events is None: events = ("end",) self._parser._setevents(self._events_queue, events) def feed(self, data): """Feed encoded data to parser.""" if self._parser is None: raise ValueError("feed() called after end of stream") if data: try: self._parser.feed(data) except SyntaxError as exc: self._events_queue.append(exc) def _close_and_return_root(self): # iterparse needs this to set its root attribute properly :( root = self._parser.close() self._parser = None return root def close(self): """Finish feeding data to parser. Unlike XMLParser, does not return the root element. Use read_events() to consume elements from XMLPullParser. """ self._close_and_return_root() def read_events(self): """Return an iterator over currently available (event, elem) pairs. Events are consumed from the internal event queue as they are retrieved from the iterator. """ events = self._events_queue while events: event = events.popleft() if isinstance(event, Exception): raise event else: yield event def flush(self): if self._parser is None: raise ValueError("flush() called after end of stream") self._parser.flush() def XML(text, parser=None): """Parse XML document from string constant. This function can be used to embed "XML Literals" in Python code. *text* is a string containing XML data, *parser* is an optional parser instance, defaulting to the standard XMLParser. Returns an Element instance. """ if not parser: parser = XMLParser(target=TreeBuilder()) parser.feed(text) return parser.close() def XMLID(text, parser=None): """Parse XML document from string constant for its IDs. *text* is a string containing XML data, *parser* is an optional parser instance, defaulting to the standard XMLParser. Returns an (Element, dict) tuple, in which the dict maps element id:s to elements. """ if not parser: parser = XMLParser(target=TreeBuilder()) parser.feed(text) tree = parser.close() ids = {} for elem in tree.iter(): id = elem.get("id") if id: ids[id] = elem return tree, ids # Parse XML document from string constant. Alias for XML(). fromstring = XML def fromstringlist(sequence, parser=None): """Parse XML document from sequence of string fragments. *sequence* is a list of other sequence, *parser* is an optional parser instance, defaulting to the standard XMLParser. Returns an Element instance. """ if not parser: parser = XMLParser(target=TreeBuilder()) for text in sequence: parser.feed(text) return parser.close() # -------------------------------------------------------------------- class TreeBuilder: """Generic element structure builder. This builder converts a sequence of start, data, and end method calls to a well-formed element structure. You can use this class to build an element structure using a custom XML parser, or a parser for some other XML-like format. *element_factory* is an optional element factory which is called to create new Element instances, as necessary. *comment_factory* is a factory to create comments to be used instead of the standard factory. If *insert_comments* is false (the default), comments will not be inserted into the tree. *pi_factory* is a factory to create processing instructions to be used instead of the standard factory. If *insert_pis* is false (the default), processing instructions will not be inserted into the tree. """ def __init__(self, element_factory=None, *, comment_factory=None, pi_factory=None, insert_comments=False, insert_pis=False): self._data = [] # data collector self._elem = [] # element stack self._last = None # last element self._root = None # root element self._tail = None # true if we're after an end tag if comment_factory is None: comment_factory = Comment self._comment_factory = comment_factory self.insert_comments = insert_comments if pi_factory is None: pi_factory = ProcessingInstruction self._pi_factory = pi_factory self.insert_pis = insert_pis if element_factory is None: element_factory = Element self._factory = element_factory def close(self): """Flush builder buffers and return toplevel document Element.""" assert len(self._elem) == 0, "missing end tags" assert self._root is not None, "missing toplevel element" return self._root def _flush(self): if self._data: if self._last is not None: text = "".join(self._data) if self._tail: assert self._last.tail is None, "internal error (tail)" self._last.tail = text else: assert self._last.text is None, "internal error (text)" self._last.text = text self._data = [] def data(self, data): """Add text to current element.""" self._data.append(data) def start(self, tag, attrs): """Open new element and return it. *tag* is the element name, *attrs* is a dict containing element attributes. """ self._flush() self._last = elem = self._factory(tag, attrs) if self._elem: self._elem[-1].append(elem) elif self._root is None: self._root = elem self._elem.append(elem) self._tail = 0 return elem def end(self, tag): """Close and return current Element. *tag* is the element name. """ self._flush() self._last = self._elem.pop() assert self._last.tag == tag,\ "end tag mismatch (expected %s, got %s)" % ( self._last.tag, tag) self._tail = 1 return self._last def comment(self, text): """Create a comment using the comment_factory. *text* is the text of the comment. """ return self._handle_single( self._comment_factory, self.insert_comments, text) def pi(self, target, text=None): """Create a processing instruction using the pi_factory. *target* is the target name of the processing instruction. *text* is the data of the processing instruction, or ''. """ return self._handle_single( self._pi_factory, self.insert_pis, target, text) def _handle_single(self, factory, insert, *args): elem = factory(*args) if insert: self._flush() self._last = elem if self._elem: self._elem[-1].append(elem) self._tail = 1 return elem # also see ElementTree and TreeBuilder class XMLParser: """Element structure builder for XML source data based on the expat parser. *target* is an optional target object which defaults to an instance of the standard TreeBuilder class, *encoding* is an optional encoding string which if given, overrides the encoding specified in the XML file: http://www.iana.org/assignments/character-sets """ def __init__(self, *, target=None, encoding=None): try: from xml.parsers import expat except ImportError: try: import pyexpat as expat except ImportError: raise ImportError( "No module named expat; use SimpleXMLTreeBuilder instead" ) parser = expat.ParserCreate(encoding, "}") if target is None: target = TreeBuilder() # underscored names are provided for compatibility only self.parser = self._parser = parser self.target = self._target = target self._error = expat.error self._names = {} # name memo cache # main callbacks parser.DefaultHandlerExpand = self._default if hasattr(target, 'start'): parser.StartElementHandler = self._start if hasattr(target, 'end'): parser.EndElementHandler = self._end if hasattr(target, 'start_ns'): parser.StartNamespaceDeclHandler = self._start_ns if hasattr(target, 'end_ns'): parser.EndNamespaceDeclHandler = self._end_ns if hasattr(target, 'data'): parser.CharacterDataHandler = target.data # miscellaneous callbacks if hasattr(target, 'comment'): parser.CommentHandler = target.comment if hasattr(target, 'pi'): parser.ProcessingInstructionHandler = target.pi # Configure pyexpat: buffering, new-style attribute handling. parser.buffer_text = 1 parser.ordered_attributes = 1 self._doctype = None self.entity = {} try: self.version = "Expat %d.%d.%d" % expat.version_info except AttributeError: pass # unknown def _setevents(self, events_queue, events_to_report): # Internal API for XMLPullParser # events_to_report: a list of events to report during parsing (same as # the *events* of XMLPullParser's constructor. # events_queue: a list of actual parsing events that will be populated # by the underlying parser. # parser = self._parser append = events_queue.append for event_name in events_to_report: if event_name == "start": parser.ordered_attributes = 1 def handler(tag, attrib_in, event=event_name, append=append, start=self._start): append((event, start(tag, attrib_in))) parser.StartElementHandler = handler elif event_name == "end": def handler(tag, event=event_name, append=append, end=self._end): append((event, end(tag))) parser.EndElementHandler = handler elif event_name == "start-ns": # TreeBuilder does not implement .start_ns() if hasattr(self.target, "start_ns"): def handler(prefix, uri, event=event_name, append=append, start_ns=self._start_ns): append((event, start_ns(prefix, uri))) else: def handler(prefix, uri, event=event_name, append=append): append((event, (prefix or '', uri or ''))) parser.StartNamespaceDeclHandler = handler elif event_name == "end-ns": # TreeBuilder does not implement .end_ns() if hasattr(self.target, "end_ns"): def handler(prefix, event=event_name, append=append, end_ns=self._end_ns): append((event, end_ns(prefix))) else: def handler(prefix, event=event_name, append=append): append((event, None)) parser.EndNamespaceDeclHandler = handler elif event_name == 'comment': def handler(text, event=event_name, append=append, self=self): append((event, self.target.comment(text))) parser.CommentHandler = handler elif event_name == 'pi': def handler(pi_target, data, event=event_name, append=append, self=self): append((event, self.target.pi(pi_target, data))) parser.ProcessingInstructionHandler = handler else: raise ValueError("unknown event %r" % event_name) def _raiseerror(self, value): err = ParseError(value) err.code = value.code err.position = value.lineno, value.offset raise err def _fixname(self, key): # expand qname, and convert name string to ascii, if possible try: name = self._names[key] except KeyError: name = key if "}" in name: name = "{" + name self._names[key] = name return name def _start_ns(self, prefix, uri): return self.target.start_ns(prefix or '', uri or '') def _end_ns(self, prefix): return self.target.end_ns(prefix or '') def _start(self, tag, attr_list): # Handler for expat's StartElementHandler. Since ordered_attributes # is set, the attributes are reported as a list of alternating # attribute name,value. fixname = self._fixname tag = fixname(tag) attrib = {} if attr_list: for i in range(0, len(attr_list), 2): attrib[fixname(attr_list[i])] = attr_list[i+1] return self.target.start(tag, attrib) def _end(self, tag): return self.target.end(self._fixname(tag)) def _default(self, text): prefix = text[:1] if prefix == "&": # deal with undefined entities try: data_handler = self.target.data except AttributeError: return try: data_handler(self.entity[text[1:-1]]) except KeyError: from xml.parsers import expat err = expat.error( "undefined entity %s: line %d, column %d" % (text, self.parser.ErrorLineNumber, self.parser.ErrorColumnNumber) ) err.code = 11 # XML_ERROR_UNDEFINED_ENTITY err.lineno = self.parser.ErrorLineNumber err.offset = self.parser.ErrorColumnNumber raise err elif prefix == "<" and text[:9] == "": self._doctype = None return text = text.strip() if not text: return self._doctype.append(text) n = len(self._doctype) if n > 2: type = self._doctype[1] if type == "PUBLIC" and n == 4: name, type, pubid, system = self._doctype if pubid: pubid = pubid[1:-1] elif type == "SYSTEM" and n == 3: name, type, system = self._doctype pubid = None else: return if hasattr(self.target, "doctype"): self.target.doctype(name, pubid, system[1:-1]) elif hasattr(self, "doctype"): warnings.warn( "The doctype() method of XMLParser is ignored. " "Define doctype() method on the TreeBuilder target.", RuntimeWarning) self._doctype = None def feed(self, data): """Feed encoded data to parser.""" try: self.parser.Parse(data, False) except self._error as v: self._raiseerror(v) def close(self): """Finish feeding data to parser and return element structure.""" try: self.parser.Parse(b"", True) # end of data except self._error as v: self._raiseerror(v) try: close_handler = self.target.close except AttributeError: pass else: return close_handler() finally: # get rid of circular references del self.parser, self._parser del self.target, self._target def flush(self): was_enabled = self.parser.GetReparseDeferralEnabled() try: self.parser.SetReparseDeferralEnabled(False) self.parser.Parse(b"", False) except self._error as v: self._raiseerror(v) finally: self.parser.SetReparseDeferralEnabled(was_enabled) # -------------------------------------------------------------------- # C14N 2.0 def canonicalize(xml_data=None, *, out=None, from_file=None, **options): """Convert XML to its C14N 2.0 serialised form. If *out* is provided, it must be a file or file-like object that receives the serialised canonical XML output (text, not bytes) through its ``.write()`` method. To write to a file, open it in text mode with encoding "utf-8". If *out* is not provided, this function returns the output as text string. Either *xml_data* (an XML string) or *from_file* (a file path or file-like object) must be provided as input. The configuration options are the same as for the ``C14NWriterTarget``. """ if xml_data is None and from_file is None: raise ValueError("Either 'xml_data' or 'from_file' must be provided as input") sio = None if out is None: sio = out = io.StringIO() parser = XMLParser(target=C14NWriterTarget(out.write, **options)) if xml_data is not None: parser.feed(xml_data) parser.close() elif from_file is not None: parse(from_file, parser=parser) return sio.getvalue() if sio is not None else None _looks_like_prefix_name = re.compile(r'^\w+:\w+$', re.UNICODE).match class C14NWriterTarget: """ Canonicalization writer target for the XMLParser. Serialises parse events to XML C14N 2.0. The *write* function is used for writing out the resulting data stream as text (not bytes). To write to a file, open it in text mode with encoding "utf-8" and pass its ``.write`` method. Configuration options: - *with_comments*: set to true to include comments - *strip_text*: set to true to strip whitespace before and after text content - *rewrite_prefixes*: set to true to replace namespace prefixes by "n{number}" - *qname_aware_tags*: a set of qname aware tag names in which prefixes should be replaced in text content - *qname_aware_attrs*: a set of qname aware attribute names in which prefixes should be replaced in text content - *exclude_attrs*: a set of attribute names that should not be serialised - *exclude_tags*: a set of tag names that should not be serialised """ def __init__(self, write, *, with_comments=False, strip_text=False, rewrite_prefixes=False, qname_aware_tags=None, qname_aware_attrs=None, exclude_attrs=None, exclude_tags=None): self._write = write self._data = [] self._with_comments = with_comments self._strip_text = strip_text self._exclude_attrs = set(exclude_attrs) if exclude_attrs else None self._exclude_tags = set(exclude_tags) if exclude_tags else None self._rewrite_prefixes = rewrite_prefixes if qname_aware_tags: self._qname_aware_tags = set(qname_aware_tags) else: self._qname_aware_tags = None if qname_aware_attrs: self._find_qname_aware_attrs = set(qname_aware_attrs).intersection else: self._find_qname_aware_attrs = None # Stack with globally and newly declared namespaces as (uri, prefix) pairs. self._declared_ns_stack = [[ ("http://www.w3.org/XML/1998/namespace", "xml"), ]] # Stack with user declared namespace prefixes as (uri, prefix) pairs. self._ns_stack = [] if not rewrite_prefixes: self._ns_stack.append(list(_namespace_map.items())) self._ns_stack.append([]) self._prefix_map = {} self._preserve_space = [False] self._pending_start = None self._root_seen = False self._root_done = False self._ignored_depth = 0 def _iter_namespaces(self, ns_stack, _reversed=reversed): for namespaces in _reversed(ns_stack): if namespaces: # almost no element declares new namespaces yield from namespaces def _resolve_prefix_name(self, prefixed_name): prefix, name = prefixed_name.split(':', 1) for uri, p in self._iter_namespaces(self._ns_stack): if p == prefix: return f'{{{uri}}}{name}' raise ValueError(f'Prefix {prefix} of QName "{prefixed_name}" is not declared in scope') def _qname(self, qname, uri=None): if uri is None: uri, tag = qname[1:].rsplit('}', 1) if qname[:1] == '{' else ('', qname) else: tag = qname prefixes_seen = set() for u, prefix in self._iter_namespaces(self._declared_ns_stack): if u == uri and prefix not in prefixes_seen: return f'{prefix}:{tag}' if prefix else tag, tag, uri prefixes_seen.add(prefix) # Not declared yet => add new declaration. if self._rewrite_prefixes: if uri in self._prefix_map: prefix = self._prefix_map[uri] else: prefix = self._prefix_map[uri] = f'n{len(self._prefix_map)}' self._declared_ns_stack[-1].append((uri, prefix)) return f'{prefix}:{tag}', tag, uri if not uri and '' not in prefixes_seen: # No default namespace declared => no prefix needed. return tag, tag, uri for u, prefix in self._iter_namespaces(self._ns_stack): if u == uri: self._declared_ns_stack[-1].append((uri, prefix)) return f'{prefix}:{tag}' if prefix else tag, tag, uri if not uri: # As soon as a default namespace is defined, # anything that has no namespace (and thus, no prefix) goes there. return tag, tag, uri raise ValueError(f'Namespace "{uri}" is not declared in scope') def data(self, data): if not self._ignored_depth: self._data.append(data) def _flush(self, _join_text=''.join): data = _join_text(self._data) del self._data[:] if self._strip_text and not self._preserve_space[-1]: data = data.strip() if self._pending_start is not None: args, self._pending_start = self._pending_start, None qname_text = data if data and _looks_like_prefix_name(data) else None self._start(*args, qname_text) if qname_text is not None: return if data and self._root_seen: self._write(_escape_cdata_c14n(data)) def start_ns(self, prefix, uri): if self._ignored_depth: return # we may have to resolve qnames in text content if self._data: self._flush() self._ns_stack[-1].append((uri, prefix)) def start(self, tag, attrs): if self._exclude_tags is not None and ( self._ignored_depth or tag in self._exclude_tags): self._ignored_depth += 1 return if self._data: self._flush() new_namespaces = [] self._declared_ns_stack.append(new_namespaces) if self._qname_aware_tags is not None and tag in self._qname_aware_tags: # Need to parse text first to see if it requires a prefix declaration. self._pending_start = (tag, attrs, new_namespaces) return self._start(tag, attrs, new_namespaces) def _start(self, tag, attrs, new_namespaces, qname_text=None): if self._exclude_attrs is not None and attrs: attrs = {k: v for k, v in attrs.items() if k not in self._exclude_attrs} qnames = {tag, *attrs} resolved_names = {} # Resolve prefixes in attribute and tag text. if qname_text is not None: qname = resolved_names[qname_text] = self._resolve_prefix_name(qname_text) qnames.add(qname) if self._find_qname_aware_attrs is not None and attrs: qattrs = self._find_qname_aware_attrs(attrs) if qattrs: for attr_name in qattrs: value = attrs[attr_name] if _looks_like_prefix_name(value): qname = resolved_names[value] = self._resolve_prefix_name(value) qnames.add(qname) else: qattrs = None else: qattrs = None # Assign prefixes in lexicographical order of used URIs. parse_qname = self._qname parsed_qnames = {n: parse_qname(n) for n in sorted( qnames, key=lambda n: n.split('}', 1))} # Write namespace declarations in prefix order ... if new_namespaces: attr_list = [ ('xmlns:' + prefix if prefix else 'xmlns', uri) for uri, prefix in new_namespaces ] attr_list.sort() else: # almost always empty attr_list = [] # ... followed by attributes in URI+name order if attrs: for k, v in sorted(attrs.items()): if qattrs is not None and k in qattrs and v in resolved_names: v = parsed_qnames[resolved_names[v]][0] attr_qname, attr_name, uri = parsed_qnames[k] # No prefix for attributes in default ('') namespace. attr_list.append((attr_qname if uri else attr_name, v)) # Honour xml:space attributes. space_behaviour = attrs.get('{http://www.w3.org/XML/1998/namespace}space') self._preserve_space.append( space_behaviour == 'preserve' if space_behaviour else self._preserve_space[-1]) # Write the tag. write = self._write write('<' + parsed_qnames[tag][0]) if attr_list: write(''.join([f' {k}="{_escape_attrib_c14n(v)}"' for k, v in attr_list])) write('>') # Write the resolved qname text content. if qname_text is not None: write(_escape_cdata_c14n(parsed_qnames[resolved_names[qname_text]][0])) self._root_seen = True self._ns_stack.append([]) def end(self, tag): if self._ignored_depth: self._ignored_depth -= 1 return if self._data: self._flush() self._write(f'') self._preserve_space.pop() self._root_done = len(self._preserve_space) == 1 self._declared_ns_stack.pop() self._ns_stack.pop() def comment(self, text): if not self._with_comments: return if self._ignored_depth: return if self._root_done: self._write('\n') elif self._root_seen and self._data: self._flush() self._write(f'') if not self._root_seen: self._write('\n') def pi(self, target, data): if self._ignored_depth: return if self._root_done: self._write('\n') elif self._root_seen and self._data: self._flush() self._write( f'' if data else f'') if not self._root_seen: self._write('\n') def _escape_cdata_c14n(text): # escape character data try: # it's worth avoiding do-nothing calls for strings that are # shorter than 500 character, or so. assume that's, by far, # the most common case in most applications. if '&' in text: text = text.replace('&', '&') if '<' in text: text = text.replace('<', '<') if '>' in text: text = text.replace('>', '>') if '\r' in text: text = text.replace('\r', ' ') return text except (TypeError, AttributeError): _raise_serialization_error(text) def _escape_attrib_c14n(text): # escape attribute value try: if '&' in text: text = text.replace('&', '&') if '<' in text: text = text.replace('<', '<') if '"' in text: text = text.replace('"', '"') if '\t' in text: text = text.replace('\t', ' ') if '\n' in text: text = text.replace('\n', ' ') if '\r' in text: text = text.replace('\r', ' ') return text except (TypeError, AttributeError): _raise_serialization_error(text) # -------------------------------------------------------------------- # Import the C accelerators try: # Element is going to be shadowed by the C implementation. We need to keep # the Python version of it accessible for some "creative" by external code # (see tests) _Element_Py = Element # Element, SubElement, ParseError, TreeBuilder, XMLParser, _set_factories from _elementtree import * from _elementtree import _set_factories except ImportError: pass else: _set_factories(Comment, ProcessingInstruction) ElementInclude.py000064400000015342151027357230010025 0ustar00# # ElementTree # $Id: ElementInclude.py 3375 2008-02-13 08:05:08Z 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-2008 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. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See https://www.python.org/psf/license for licensing details. ## # Limited XInclude support for the ElementTree package. ## import copy from . import ElementTree from urllib.parse import urljoin XINCLUDE = "{http://www.w3.org/2001/XInclude}" XINCLUDE_INCLUDE = XINCLUDE + "include" XINCLUDE_FALLBACK = XINCLUDE + "fallback" # 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(SyntaxError): pass class LimitedRecursiveIncludeError(FatalIncludeError): pass ## # 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 (UTF-8 by default for "text"). # @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 OSError exception. # @throws OSError If the loader fails to load the resource. def default_loader(href, parse, encoding=None): if parse == "xml": with open(href, 'rb') as file: data = ElementTree.parse(file).getroot() else: if not encoding: encoding = 'UTF-8' with open(href, 'r', encoding=encoding) as file: data = file.read() return data ## # 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 a negative value 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 hasattr(elem, 'getroot'): elem = elem.getroot() if loader is None: loader = default_loader _include(elem, loader, base_url, max_depth, set()) def _include(elem, loader, base_url, max_depth, _parent_hrefs): # look for xinclude elements i = 0 while i < len(elem): e = elem[i] if e.tag == XINCLUDE_INCLUDE: # process xinclude directive href = e.get("href") if base_url: href = urljoin(base_url, href) parse = e.get("parse", "xml") if parse == "xml": if href in _parent_hrefs: raise FatalIncludeError("recursive include of %s" % href) if max_depth == 0: raise LimitedRecursiveIncludeError( "maximum xinclude depth reached when including file %s" % href) _parent_hrefs.add(href) node = loader(href, parse) if node is None: raise FatalIncludeError( "cannot load %r as %r" % (href, parse) ) node = copy.copy(node) # FIXME: this makes little sense with recursive includes _include(node, loader, href, max_depth - 1, _parent_hrefs) _parent_hrefs.remove(href) if e.tail: node.tail = (node.tail or "") + e.tail elem[i] = node elif parse == "text": text = loader(href, parse, e.get("encoding")) if text is None: raise FatalIncludeError( "cannot load %r as %r" % (href, parse) ) if e.tail: text += e.tail if i: node = elem[i-1] node.tail = (node.tail or "") + text else: elem.text = (elem.text or "") + text del elem[i] continue else: raise FatalIncludeError( "unknown parse type in xi:include tag (%r)" % parse ) elif e.tag == XINCLUDE_FALLBACK: raise FatalIncludeError( "xi:fallback tag must be child of xi:include (%r)" % e.tag ) else: _include(e, loader, base_url, max_depth, _parent_hrefs) i += 1 ElementPath.py000064400000033255151027357230007341 0ustar00# # ElementTree # $Id: ElementPath.py 3375 2008-02-13 08:05:08Z fredrik $ # # limited xpath support for element trees # # history: # 2003-05-23 fl created # 2003-05-28 fl added support for // etc # 2003-08-27 fl fixed parsing of periods in element names # 2007-09-10 fl new selection engine # 2007-09-12 fl fixed parent selector # 2007-09-13 fl added iterfind; changed findall to return a list # 2007-11-30 fl added namespaces support # 2009-10-30 fl added child element value filter # # Copyright (c) 2003-2009 by Fredrik Lundh. All rights reserved. # # fredrik@pythonware.com # http://www.pythonware.com # # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2009 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. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See https://www.python.org/psf/license for licensing details. ## # Implementation module for XPath support. There's usually no reason # to import this module directly; the ElementTree does this for # you, if needed. ## import re xpath_tokenizer_re = re.compile( r"(" r"'[^']*'|\"[^\"]*\"|" r"::|" r"//?|" r"\.\.|" r"\(\)|" r"!=|" r"[/.*:\[\]\(\)@=])|" r"((?:\{[^}]+\})?[^/\[\]\(\)@!=\s]+)|" r"\s+" ) def xpath_tokenizer(pattern, namespaces=None): default_namespace = namespaces.get('') if namespaces else None parsing_attribute = False for token in xpath_tokenizer_re.findall(pattern): ttype, tag = token if tag and tag[0] != "{": if ":" in tag: prefix, uri = tag.split(":", 1) try: if not namespaces: raise KeyError yield ttype, "{%s}%s" % (namespaces[prefix], uri) except KeyError: raise SyntaxError("prefix %r not found in prefix map" % prefix) from None elif default_namespace and not parsing_attribute: yield ttype, "{%s}%s" % (default_namespace, tag) else: yield token parsing_attribute = False else: yield token parsing_attribute = ttype == '@' def get_parent_map(context): parent_map = context.parent_map if parent_map is None: context.parent_map = parent_map = {} for p in context.root.iter(): for e in p: parent_map[e] = p return parent_map def _is_wildcard_tag(tag): return tag[:3] == '{*}' or tag[-2:] == '}*' def _prepare_tag(tag): _isinstance, _str = isinstance, str if tag == '{*}*': # Same as '*', but no comments or processing instructions. # It can be a surprise that '*' includes those, but there is no # justification for '{*}*' doing the same. def select(context, result): for elem in result: if _isinstance(elem.tag, _str): yield elem elif tag == '{}*': # Any tag that is not in a namespace. def select(context, result): for elem in result: el_tag = elem.tag if _isinstance(el_tag, _str) and el_tag[0] != '{': yield elem elif tag[:3] == '{*}': # The tag in any (or no) namespace. suffix = tag[2:] # '}name' no_ns = slice(-len(suffix), None) tag = tag[3:] def select(context, result): for elem in result: el_tag = elem.tag if el_tag == tag or _isinstance(el_tag, _str) and el_tag[no_ns] == suffix: yield elem elif tag[-2:] == '}*': # Any tag in the given namespace. ns = tag[:-1] ns_only = slice(None, len(ns)) def select(context, result): for elem in result: el_tag = elem.tag if _isinstance(el_tag, _str) and el_tag[ns_only] == ns: yield elem else: raise RuntimeError(f"internal parser error, got {tag}") return select def prepare_child(next, token): tag = token[1] if _is_wildcard_tag(tag): select_tag = _prepare_tag(tag) def select(context, result): def select_child(result): for elem in result: yield from elem return select_tag(context, select_child(result)) else: if tag[:2] == '{}': tag = tag[2:] # '{}tag' == 'tag' def select(context, result): for elem in result: for e in elem: if e.tag == tag: yield e return select def prepare_star(next, token): def select(context, result): for elem in result: yield from elem return select def prepare_self(next, token): def select(context, result): yield from result return select def prepare_descendant(next, token): try: token = next() except StopIteration: return if token[0] == "*": tag = "*" elif not token[0]: tag = token[1] else: raise SyntaxError("invalid descendant") if _is_wildcard_tag(tag): select_tag = _prepare_tag(tag) def select(context, result): def select_child(result): for elem in result: for e in elem.iter(): if e is not elem: yield e return select_tag(context, select_child(result)) else: if tag[:2] == '{}': tag = tag[2:] # '{}tag' == 'tag' def select(context, result): for elem in result: for e in elem.iter(tag): if e is not elem: yield e return select def prepare_parent(next, token): def select(context, result): # FIXME: raise error if .. is applied at toplevel? parent_map = get_parent_map(context) result_map = {} for elem in result: if elem in parent_map: parent = parent_map[elem] if parent not in result_map: result_map[parent] = None yield parent return select def prepare_predicate(next, token): # FIXME: replace with real parser!!! refs: # http://javascript.crockford.com/tdop/tdop.html signature = [] predicate = [] while 1: try: token = next() except StopIteration: return if token[0] == "]": break if token == ('', ''): # ignore whitespace continue if token[0] and token[0][:1] in "'\"": token = "'", token[0][1:-1] signature.append(token[0] or "-") predicate.append(token[1]) signature = "".join(signature) # use signature to determine predicate type if signature == "@-": # [@attribute] predicate key = predicate[1] def select(context, result): for elem in result: if elem.get(key) is not None: yield elem return select if signature == "@-='" or signature == "@-!='": # [@attribute='value'] or [@attribute!='value'] key = predicate[1] value = predicate[-1] def select(context, result): for elem in result: if elem.get(key) == value: yield elem def select_negated(context, result): for elem in result: if (attr_value := elem.get(key)) is not None and attr_value != value: yield elem return select_negated if '!=' in signature else select if signature == "-" and not re.match(r"\-?\d+$", predicate[0]): # [tag] tag = predicate[0] def select(context, result): for elem in result: if elem.find(tag) is not None: yield elem return select if signature == ".='" or signature == ".!='" or ( (signature == "-='" or signature == "-!='") and not re.match(r"\-?\d+$", predicate[0])): # [.='value'] or [tag='value'] or [.!='value'] or [tag!='value'] tag = predicate[0] value = predicate[-1] if tag: def select(context, result): for elem in result: for e in elem.findall(tag): if "".join(e.itertext()) == value: yield elem break def select_negated(context, result): for elem in result: for e in elem.iterfind(tag): if "".join(e.itertext()) != value: yield elem break else: def select(context, result): for elem in result: if "".join(elem.itertext()) == value: yield elem def select_negated(context, result): for elem in result: if "".join(elem.itertext()) != value: yield elem return select_negated if '!=' in signature else select if signature == "-" or signature == "-()" or signature == "-()-": # [index] or [last()] or [last()-index] if signature == "-": # [index] index = int(predicate[0]) - 1 if index < 0: raise SyntaxError("XPath position >= 1 expected") else: if predicate[0] != "last": raise SyntaxError("unsupported function") if signature == "-()-": try: index = int(predicate[2]) - 1 except ValueError: raise SyntaxError("unsupported expression") if index > -2: raise SyntaxError("XPath offset from last() must be negative") else: index = -1 def select(context, result): parent_map = get_parent_map(context) for elem in result: try: parent = parent_map[elem] # FIXME: what if the selector is "*" ? elems = list(parent.findall(elem.tag)) if elems[index] is elem: yield elem except (IndexError, KeyError): pass return select raise SyntaxError("invalid predicate") ops = { "": prepare_child, "*": prepare_star, ".": prepare_self, "..": prepare_parent, "//": prepare_descendant, "[": prepare_predicate, } _cache = {} class _SelectorContext: parent_map = None def __init__(self, root): self.root = root # -------------------------------------------------------------------- ## # Generate all matching objects. def iterfind(elem, path, namespaces=None): # compile selector pattern if path[-1:] == "/": path = path + "*" # implicit all (FIXME: keep this?) cache_key = (path,) if namespaces: cache_key += tuple(sorted(namespaces.items())) try: selector = _cache[cache_key] except KeyError: if len(_cache) > 100: _cache.clear() if path[:1] == "/": raise SyntaxError("cannot use absolute path on element") next = iter(xpath_tokenizer(path, namespaces)).__next__ try: token = next() except StopIteration: return selector = [] while 1: try: selector.append(ops[token[0]](next, token)) except StopIteration: raise SyntaxError("invalid path") from None try: token = next() if token[0] == "/": token = next() except StopIteration: break _cache[cache_key] = selector # execute selector pattern result = [elem] context = _SelectorContext(elem) for select in selector: result = select(context, result) return result ## # Find first matching object. def find(elem, path, namespaces=None): return next(iterfind(elem, path, namespaces), None) ## # Find all matching objects. def findall(elem, path, namespaces=None): return list(iterfind(elem, path, namespaces)) ## # Find text for first matching object. def findtext(elem, path, default=None, namespaces=None): try: elem = next(iterfind(elem, path, namespaces)) if elem.text is None: return "" return elem.text except StopIteration: return default cElementTree.py000064400000000122151027357230007472 0ustar00# Deprecated alias for xml.etree.ElementTree from xml.etree.ElementTree import * __pycache__/ElementTree.cpython-311.pyc000064400000260670151027357230013707 0ustar00 !A?h"dZgdZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z Gdde Zd ZGd d Zifd ZdDd ZdDdZeZGddZGddZe jdZdDdZdZhdZdZdZeeedZdZdddddd d!d"Z e e_ d#Z!d$Z"d%Z#d&Z$dEddd'd(d)Z%Gd*d+ej&Z'dEddd'd(d,Z(d-Z)dFd/Z*dDd0Z+dEd1Z,Gd2d3Z-dDd4Z.dDd5Z/e.Z0dDd6Z1Gd7d8Z2Gd9d:Z3dDddd;d<Z4ej5d=ej6j7Z8Gd>d?Z9d@Z:dAZ; eZZ>e>eedS#e?$rYdSwxYw)GaLightweight XML support for Python. XML is an inherently hierarchical data format, and the most natural way to represent it is with a tree. This module has two classes for this purpose: 1. ElementTree represents the whole XML document as a tree and 2. Element represents a single node in this tree. Interactions with the whole document (reading and writing to/from files) are usually done on the ElementTree level. Interactions with a single XML element and its sub-elements are done on the Element level. Element is a flexible container object designed to store hierarchical data structures in memory. It can be described as a cross between a list and a dictionary. Each Element has a number of properties associated with it: 'tag' - a string containing the element's name. 'attributes' - a Python dictionary storing the element's attributes. 'text' - a string containing the element's text content. 'tail' - an optional string containing text after the element's end tag. And a number of child elements stored in a Python sequence. To create an element instance, use the Element constructor, or the SubElement factory function. You can also use the ElementTree class to wrap an element structure and convert it to and from XML. )CommentdumpElement ElementTree fromstringfromstringlistindent iselement iterparseparse ParseErrorPIProcessingInstructionQName SubElementtostring tostringlist TreeBuilderVERSIONXMLXMLID XMLParser XMLPullParserregister_namespace canonicalizeC14NWriterTargetz1.3.0N) ElementPathceZdZdZdS)r zAn error when parsing an XML document. In addition to its exception value, a ParseError contains two extra attributes: 'code' - the specific exception code 'position' - the line and column of the error N)__name__ __module__ __qualname____doc__./usr/lib64/python3.11/xml/etree/ElementTree.pyr r ks Dr%r c"t|dS)z2Return True if *element* appears to be an Element.tag)hasattr)elements r&r r ys 7E " ""r%ceZdZdZdZ dZ dZ dZ ifdZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZdZddZddZddZddZdZddZdZdZdZddZ dZ!dS)rahAn XML element. This class is the reference implementation of the Element interface. An element's length is its number of subelements. That means if you want to check if an element is truly empty, you should check BOTH its length AND its text attribute. The element tag, attribute names, and attribute values can be either bytes or strings. *tag* is the element name. *attrib* is an optional dictionary containing element attributes. *extra* are additional element attributes given as keyword arguments. Example form: text...tail Nc t|tstd|jj||_i|||_g|_dS)Nzattrib must be dict, not ) isinstancedict TypeError __class__r r(attrib _children)selfr(r1extras r&__init__zElement.__init__s\&$'' -) )),-- -))5) r%cJd|jj|jt|fzS)Nz<%s %r at %#x>)r0r r(idr3s r&__repr__zElement.__repr__s!4>#:DHbhh"OOOr%c.|||S)zCreate a new element with the same type. *tag* is a string containing the element name. *attrib* is a dictionary containing the element attributes. Do not call this method, use the SubElement factory function instead. )r0)r3r(r1s r& makeelementzElement.makeelements~~c6***r%c^tjdt|S)zReturn copy of current element. This creates a shallow copy. Subelements will be shared with the original tree. z7elem.copy() is deprecated. Use copy.copy(elem) instead.)warningswarnDeprecationWarning__copy__r8s r&copyz Element.copys.  E    }}r%c||j|j}|j|_|j|_||dd<|SN)r;r(r1texttail)r3elems r&r@zElement.__copy__s?$+66I I QQQ r%c*t|jSrC)lenr2r8s r&__len__zElement.__len__s4>"""r%cjtjdtdt|jdkS)NzyThe behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. stacklevelr)r=r> FutureWarningrHr2r8s r&__bool__zElement.__bool__s=  K a     4>""a''r%c|j|SrCr2r3indexs r& __getitem__zElement.__getitem__s~e$$r%ct|tr|D]}||n||||j|<dSrC)r-slice_assert_is_elementr2)r3rSr*elts r& __setitem__zElement.__setitem__sg eU # # - - -'',,,, -  # #G , , , 'ur%c|j|=dSrCrQrRs r& __delitem__zElement.__delitem__s N5 ! ! !r%cd|||j|dS)aAdd *subelement* to the end of this element. The new element will appear in document order after the last existing subelement (or directly after the text, if it's the first subelement), but before the end tag for this element. NrWr2appendr3 subelements r&r^zElement.appends4  +++ j)))))r%cn|D]1}|||j|2dS)zkAppend subelements from a sequence. *elements* is a sequence with zero or more elements. Nr])r3elementsr*s r&extendzElement.extendsJ   + +G  # #G , , , N ! !' * * * * + +r%cf|||j||dS)z(Insert *subelement* at position *index*.N)rWr2insert)r3rSr`s r&rezElement.inserts4  +++ eZ00000r%cxt|ts$tdt|jzdS)Nzexpected an Element, not %s)r- _Element_Pyr/typer )r3es r&rWzElement._assert_is_elements@![)) N9DGG)r0r rDr8s r&r9zQName.__repr__s  N333TYYY??r%c*t|jSrC)hashrDr8s r&__hash__zQName.__hash__sDIr%cbt|tr|j|jkS|j|kSrCr-rrDr3others r&__le__z QName.__le__0 eU # # +9 * *yE!!r%cbt|tr|j|jkS|j|kSrCrrs r&__lt__z QName.__lt__0 eU # # *9uz) )y5  r%cbt|tr|j|jkS|j|kSrCrrs r&__ge__z QName.__ge__rr%cbt|tr|j|jkS|j|kSrCrrs r&__gt__z QName.__gt__rr%cbt|tr|j|jkS|j|kSrCrrs r&__eq__z QName.__eq__rr%rC) r r!r"r#r5rr9rrrrrrr$r%r&rrs      @@@"""!!!"""!!!"""""r%rcreZdZdZddZdZdZddZddZddZ dd Z dd Z dd Z dd d dZ dZdS)ra%An XML element hierarchy. This class also provides support for serialization to and from standard XML. *element* is an optional root element node, *file* is an optional file handle or file name of an XML file whose contents will be used to initialize the tree with. NcF||_|r||dSdSrC)_rootr )r3r*files r&r5zElementTree.__init__s3   JJt       r%c|jS)z!Return root element of this tree.rr8s r&getrootzElementTree.getroots zr%c||_dS)zReplace root element of this tree. This will discard the current contents of the tree and replace it with the given element. Use with care! Nr)r3r*s r&_setrootzElementTree._setroot#s r%cd}t|dst|d}d} |Vt}t|dr8|||_|j|r|SS |d}|sn||.||_|j|r|SS#|r|wwxYw)a=Load external XML document into element tree. *source* is a file name or file object, *parser* is an optional parser instance that defaults to XMLParser. ParseError is raised if the parser fails to parse the document. Returns the root element of the given source document. FreadrbTN _parse_wholei)r)openrrrcloserfeed)r3sourceparser close_sourcedatas r&r zElementTree.parse-s vv&& &$''FL ~"6>22& "(!4!4V!AC$$C=c6|j|S)zCreate and return tree iterator for the root element. The iterator loops over all elements in this tree, in document order. *tag* is a string with the tag name to iterate over (default is to return all elements). )rrr3r(s r&rzElementTree.iterRszs###r%c|dddkr$d|z}tjd|ztd|j||S)a\Find first matching element by tag name or path. Same as getroot().find(path), which is Element.find() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return the first matching element, or None if no element was found. Nr/.This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rrKrL)r=r>rNrrmrns r&rmzElementTree.find^sc 8s??:D M-/34!      ztZ000r%c|dddkr$d|z}tjd|ztd|j|||S)aeFind first matching element by tag name or path. Same as getroot().findtext(path), which is Element.findtext() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return the first matching element, or None if no element was found. NrrrrrKrL)r=r>rNrrrrss r&rrzElementTree.findtexttsg 8s??:D M-/34!      z""4*===r%c|dddkr$d|z}tjd|ztd|j||S)aaFind all matching subelements by tag name or path. Same as getroot().findall(path), which is Element.findall(). *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return list containing all matching elements in document order. NrrrrrKrL)r=r>rNrrvrns r&rvzElementTree.findallse 8s??:D M-/34!      z!!$ 333r%c|dddkr$d|z}tjd|ztd|j||S)agFind all matching subelements by tag name or path. Same as getroot().iterfind(path), which is element.iterfind() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return an iterable yielding all matching elements in document order. NrrrrrKrL)r=r>rNrrxrns r&rxzElementTree.iterfindse 8s??:D M-/34!      z""4444r%Tshort_empty_elementsc|sd}n|tvrtd|z|s |dkrd}nd}t||5\}}|dkrA|s0|=|dkr%|dvr|d |d |d krt ||jn:t |j|\} } t|} | ||j| | | ddddS#1swxYwYdS) aWrite element tree to a file as XML. Arguments: *file_or_filename* -- file name or a file object opened for writing *encoding* -- the output encoding (default: US-ASCII) *xml_declaration* -- bool indicating if an XML declaration should be added to the output. If None, an XML declaration is added if encoding IS NOT either of: US-ASCII, UTF-8, or Unicode *default_namespace* -- sets the default XML namespace (for "xmlns") *method* -- either "xml" (default), "html, "text", or "c14n" *short_empty_elements* -- controls the formatting of elements that contain no content. If True (default) they are emitted as a single self-closed tag, otherwise they are emitted as a pair of start/end tags xmlzunknown method %rc14nutf-8us-asciiNunicode)rrz rDr) _serialize ValueError _get_writerlower_serialize_textr _namespaces) r3file_or_filenameencodingxml_declarationdefault_namespacemethodrwritedeclared_encodingqnamesrp serializes r&rzElementTree.writes: ;FF : % %069:: : &"% )8 4 4 E8R@QO$,^^%%22&,,..6KKK%%%()))tz2222%0=N%O%O" &v.  %VZ/CEEEE E E E E E E E E E E E E E E E E E EsB!C,,C03C0c0||dS)Nr)r)r)r3rs r& write_c14nzElementTree.write_c14nszz$vz...r%rrC)NNNN)r r!r"r#r5rrr rrmrrrvrxrrr$r%r&rrs   ####J $ $ $ $1111,>>>>,4444,5555." $ 3E $( 3E3E3E3E3Ej/////r%rc#xK |j}|dkr|t|ddpdfVdStj5}t |t jr|}nt |t jr/t j |}| |j nLt j}d|_ ||_ |j |_ |j|_n#t$rYnwxYwt j||dd}| |j |j|fVddddS#1swxYwYdS#t$rV|dkrd}t#|d|d 5}|j|fVdddYdS#1swxYwYYdSwxYw) NrrrcdSNTr$r$r%r&z_get_writer..sDr%xmlcharrefreplace )rerrorsnewlinew)rr)rrgetattr contextlib ExitStackr-ioBufferedIOBase RawIOBaseBufferedWritercallbackdetachwritableseekabletellAttributeError TextIOWrapperr)rrrstackrs r&rrs-+ & >>  y ( (!1:tDDOO O O O O O%'' +5.0ABB+DD 0",??,-=>>DNN4;////,..D$0LDM!&DJ)9(A $4$9 )'19/B04666 t{+++j(****9 + + + + + + + + + + + + + + + + + + ''' >>  y ( (H "C(,... '15*h& & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'smEB E C21E 2 C?<E >C??AE  EE7F9 F* F9*F. .F91F. 2F98F9cddiird<fd}|D])}|j}t|tr|jvr||jnHt|t r|vr ||n#|!|t ur|turt|| D]^\}}t|tr|j}|vr ||t|tr|jvr||j_|j}t|tr|jvr||j+fS)Nc |dddkr|dddd\}}|}|9t|}|dtz}|dkr||<|r |d||<dS||<dSrt d||<dS#t $rt |YdSwxYw)Nrrrzns%dr:z.add_qname/s .RaRyC 9++C33S#,,>+//44F~!'#j//!9*0 3(/5vvss$;F5MMM$'F5MMM$$3!&u  . . . &u - - - - - - .sB B/B/B//C  C ) rr(r-rrDrrr rr) rFrrr(r}rrDrprs ` @@r&rr$sD\FJ+(* $%.......8 !!h c5 ! ! ,xv%% #(### S ! ! ,&   # _G!3!32 &s + + +**,, & &JC#u%% h&   #%'' &EJf,D,D %*%%%y dE " " !ty'>'> Idi : r%c |j}|j}|tur|d|zn|tur|d|zn||}|5|r|t ||D]}t |||d|na|d|zt |} | s|r|rPt|dD]+\} } | rd| z} |d| d t| d ,| D]k\} } t| tr| j} t| tr|| j} nt| } |d || d | d l|st|s|sP|d |r|t ||D]}t |||d||d |zd zn |d|j r|t |j dSdS)N rrc|dSNrr$xs r&rz _serialize_xml..w QqTr%r}r xmlns=""rr)r(rDrr _escape_cdata_serialize_xmllistrsorted_escape_attribr-rrHrE) rrFrrprkwargsr(rDrirvks r&rras (C 9D g~~ kD !!!! % % % hoSk ; +mD))*** J Jua4HJJJJJ J E#)   &&E 9  9 &z'7'7'9'9+9>!;!;!;1( #aAAA*1----"99DAq!!U++#F!!U++."16N*1--EE&)))QQQ78888 s4yy (< c /E---...NNA"5!VT8LNNNNNdSj3&''''e  y( mDI&&'''''((r%>brhrcolimgwbrareabaselinkmetaembedframeinputparamtrackrisindexbasefontc j|j}|j}|tur|dt|zn|tur|dt|zn||}|3|r|t||D]}t |||dnu|d|zt |}|s|r|rPt|dD]+\} } | rd| z} |d| dt| d ,|D]k\} } t| tr| j} t| tr|| j} nt| } |d || d| d l|d | } |r0| d ks| d kr ||n|t||D]}t |||d| tvr|d|zd z|jr|t|jdSdS)Nr r rc|dSr r$rs r&rz!_serialize_html..rr%rrrrrrrscriptstyler)r(rDrrr_serialize_htmlrrrrr-r_escape_attrib_htmlr HTML_EMPTYrE) rrFrrprr(rDrirrrltags r&r2r2s (C 9D g~~ kM$///0000 % % % ht,,,----Sk ; +mD))*** 8 8q&$7777 8 E#)   &&E 9  9 &z'7'7'9'9+9>!;!;!;1( #aAAA*1----"99DAq!!U++#F!!U++3"16N/22EE&)))QQQ78888 E#JJJ99;;D /8##twE$KKKKE---... 8 8q&$7777:%%dSj3&''' y( mDI&&'''''((r%c||D] }|||jr||jdSdSrC)rrE)rrFparts r&rrsT  d  y dir%)rhtmlrDctjd|rtdttD]\}}||ks||krt|=|t|<dS)atRegister a namespace prefix. The registry is global, and any existing mapping for either the given prefix or the namespace URI will be removed. *prefix* is the namespace prefix, *uri* is a namespace uri. Tags and attributes in this namespace will be serialized with prefix if possible. ValueError is raised if prefix is reserved or is invalid. zns\d+$z'Prefix format reserved for internal useN)rematchrrrr)rrrrs r&rrsy x 6""DBCCC^))++,,""1 88qF{{q! N3r%rr8rdfwsdlxsxsidc)$http://www.w3.org/XML/1998/namespacezhttp://www.w3.org/1999/xhtmlz+http://www.w3.org/1999/02/22-rdf-syntax-ns#z http://schemas.xmlsoap.org/wsdl/z http://www.w3.org/2001/XMLSchemaz)http://www.w3.org/2001/XMLSchema-instancez http://purl.org/dc/elements/1.1/cRtd|dt|jd)Nzcannot serialize z (type ))r/rhr rs r&rrs1 )+/44d1D1D1DE   r%c d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw)N&&r<r>replacer/rrrs r&rrs ) $;;<<W--D $;;<<V,,D $;;<<V,,D ~ &)))"4(((((()AA A65A6c d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}d |vr|d d }d |vr|d d }d |vr|d d}|S#ttf$rt|YdSwxYw)NrErFrrGrrHr" z rz  z rIrs r&rrs ) $;;<<W--D $;;<<V,,D $;;<<V,,D 4<<<<h//D 4<<<<g..D 4<<<<g..D 4<<<<g..D ~ &)))"4(((((()sB7B:: CCc d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw)NrErFrrHrrMrIrs r&r3r3+s ) $;;<<W--D $;;<<V,,D 4<<<<h//D ~ &)))"4(((((()rKT)rrrc|dkrtjntj}t||||||||S)a Generate string representation of XML element. All subelements are included. If encoding is "unicode", a string is returned. Otherwise a bytestring is returned. *element* is an Element instance, *encoding* is an optional output encoding defaulting to US-ASCII, *method* is an optional output which can be one of "xml" (default), "html", "text" or "c14n", *default_namespace* sets the default XML namespace (for "xmlns"). Returns an (optionally) encoded string containing the XML data. rrrrr)rStringIOBytesIOrrgetvalue)r*rrrrrstreams r&rr:sm ')33R[]]]Fvx/>1B&,4H JJJ ??  r%c0eZdZdZdZdZdZdZdZdS)_ListDataStreamz7An auxiliary stream accumulating into a list reference.c||_dSrC)lst)r3rZs r&r5z_ListDataStream.__init__Ts r%cdSrr$r8s r&rz_ListDataStream.writableWtr%cdSrr$r8s r&rz_ListDataStream.seekableZr\r%c:|j|dSrC)rZr^)r3bs r&rz_ListDataStream.write]s r%c*t|jSrC)rHrZr8s r&rz_ListDataStream.tell`s48}}r%N) r r!r"r#r5rrrrr$r%r&rXrXRseAAr%rXcxg}t|}t||||||||S)NrR)rXrr)r*rrrrrrZrVs r&rrcsU C S ! !Fvx/>1B&,4H JJJ Jr%c t|tst|}|tjd|j}|r |ddkr!tjddSdS)a#Write element tree or element structure to sys.stdout. This function should be used for debugging only. *elem* is either an ElementTree, or a single Element. The exact output format is implementation dependent. In this version, it's written as an ordinary XML file. r)rrN)r-rrsysstdoutrrE)rFrEs r&rrps dK ( (!4  JJszIJ... <<>> D 48t## $#r% ct|tr|}|dkrtd|t |sdSd|zzgfd|ddS)a&Indent an XML document by inserting newlines and indentation space after elements. *tree* is the ElementTree or Element to modify. The (root) element itself will not be changed, but the tail text of all elements in its subtree will be adapted. *space* is the whitespace to insert for each indentation level, two space characters by default. *level* is the initial indentation level. Setting this to a higher value than 0 can be used for indenting subtrees that are more deeply nested inside of a document. rz,Initial indentation level must be >= 0, got Nrc|dz} |}n0#t$r#|z}|YnwxYw|jr|js||_|D]D}t |r |||jr|js||_E|js||_dSdSr ) IndexErrorr^rDstriprHrE)rFlevel child_levelchild_indentationchild_indent_children indentationsspaces r&roz indent.._indent_childrensai  3 ,[ 9   3 3 3 ,U 3e ;     1 2 2 2 2 2 3y *  1 1 *)DI / /E5zz 5   444: /UZ%5%5%7%7 /. z!! -%e,EJJJ - -s *>>)r-rrrrH)treerqrkrorps ` @@r&rrs$ $$||~~ qyyOOOPPP t9955=()L-------,T1r%cNt}||||S)zParse XML document into element tree. *source* is a filename or file object containing XML data, *parser* is an optional parser instance defaulting to XMLParser. Return an ElementTree instance. )rr )rrrrs r&r r s& ==DJJvv Kr%ct||tdstddndfdGfddtjj}|}d |_tj||S) aJIncrementally parse XML document into ElementTree. This class also reports what's going on to the user based on the *events* it is initialized with. The supported events are the strings "start", "end", "start-ns" and "end-ns" (the "ns" events are used to get detailed namespace information). If *events* is omitted, only "end" events are reported. *source* is a filename or file object containing XML data, *events* is a list of events to report back, *parser* is an optional parser instance. Returns an iterator providing (event, elem) pairs. )events_parserrrTFc3K Ed{V|d}|sn|H}Ed{V}|||_r|dSdS#r|wwxYw)NTi@) read_eventsrr_close_and_return_rootrootr)rrrzitr pullparserwrs r&iteratorziterparse..iterators  &%11333333333{{9--%%%  &4466D!--// / / / / / / /B~    |   s B B))Cc<eZdZjZfdZdS)$iterparse..IterParseIteratorc8rdSdSrC)r)r3rrs r&__del__z,iterparse..IterParseIterator.__del__s&    r%N)r r!r"__next__r)rr~rsr&IterParseIteratorrsE8F##,        r%rN) rr)r collectionsabcIteratorrzweakrefref) rrurrr{rr~r|r}s ` @@@@r&r r s"ff===J 66 " "fd##  $KO4    BBG RB Ir%c:eZdZd dddZdZdZdZdZdZdS) rN)rvctj|_|ptt |_|d}|j|j|dS)Nr)end)rdeque _events_queuerrrv _setevents)r3rurvs r&r5zXMLPullParser.__init__s[ ).00A);=="A"A"A >F  2F;;;;;r%c|jtd|rO |j|dS#t$r%}|j|Yd}~dSd}~wwxYwdS)Feed encoded data to parser.Nz!feed() called after end of stream)rvrr SyntaxErrorrr^)r3rexcs r&rzXMLPullParser.feed s < @AA A  / / !!$''''' / / /"))#......... / / /s6 A%A  A%cF|j}d|_|SrC)rvr)r3rzs r&ryz$XMLPullParser._close_and_return_roots!|!!##  r%c.|dS)zFinish feeding data to parser. Unlike XMLParser, does not return the root element. Use read_events() to consume elements from XMLPullParser. N)ryr8s r&rzXMLPullParser.closes ##%%%%%r%c#K|j}|r3|}t|tr||V|1dSdS)zReturn an iterator over currently available (event, elem) pairs. Events are consumed from the internal event queue as they are retrieved from the iterator. N)rpopleftr- Exception)r3ruevents r&rxzXMLPullParser.read_events%se # NN$$E%++        r%cd|jtd|jdS)Nz"flush() called after end of stream)rvrflushr8s r&rzXMLPullParser.flush3s3 < ABB B r%rC) r r!r"r5rryrrxrr$r%r&rrs >r%c|stt}|||}i}|D]}|d}|r|||<||fS)aParse XML document from string constant for its IDs. *text* is a string containing XML data, *parser* is an optional parser instance, defaulting to the standard XMLParser. Returns an (Element, dict) tuple, in which the dict maps element id:s to elements. rr7)rrrrrr|)rDrrridsrFr7s r&rrJs 1+--000 KK <<>>D C  XXd^^  CG 9r%c|stt}|D]}|||S)zParse XML document from sequence of string fragments. *sequence* is a list of other sequence, *parser* is an optional parser instance, defaulting to the standard XMLParser. Returns an Element instance. rr)sequencerrDs r&rrbsR 1+--000 D <<>>r%cXeZdZdZdddddddZdZdZdZd Zd Z d Z dd Z d Z dS)ra8Generic element structure builder. This builder converts a sequence of start, data, and end method calls to a well-formed element structure. You can use this class to build an element structure using a custom XML parser, or a parser for some other XML-like format. *element_factory* is an optional element factory which is called to create new Element instances, as necessary. *comment_factory* is a factory to create comments to be used instead of the standard factory. If *insert_comments* is false (the default), comments will not be inserted into the tree. *pi_factory* is a factory to create processing instructions to be used instead of the standard factory. If *insert_pis* is false (the default), processing instructions will not be inserted into the tree. NF)comment_factory pi_factoryinsert_comments insert_piscg|_g|_d|_d|_d|_|t }||_||_|t}||_ ||_ |t}||_ dSrC) _data_elem_lastr_tailr_comment_factoryrr _pi_factoryrr_factory)r3element_factoryrrrrs r&r5zTreeBuilder.__init__sr      "%O /.  .J%$  "%O' r%cvt|jdks Jd|j Jd|jS)z;Flush builder buffers and return toplevel document Element.rzmissing end tagsNzmissing toplevel element)rHrrr8s r&rzTreeBuilder.closesC4:!###%7###z%%'A%%%zr%c|jrv|jfd|j}|jr#|jj Jd||j_n"|jj Jd||j_g|_dSdS)Nrzinternal error (tail)zinternal error (text))rrjoinrrErDr3rDs r&_flushzTreeBuilder._flushs : z%wwtz**:+:?224K222&*DJOO:?224K222&*DJODJJJ  r%c:|j|dS)zAdd text to current element.N)rr^r3rs r&rzTreeBuilder.datas $r%c||||x|_}|jr!|jd|n|j||_|j|d|_|S)zOpen new element and return it. *tag* is the element name, *attrs* is a dict containing element attributes. rcNr)rrrrr^rr)r3r(attrsrFs r&startzTreeBuilder.starts  MM#u555 T :  JrN ! !$ ' ' ' ' Z DJ $  r%c||j|_|jj|ksJd|jjd|dd|_|jS)zOClose and return current Element. *tag* is the element name. zend tag mismatch (expected z, got rCr)rrpoprr(rrs r&rzTreeBuilder.endsk Z^^%% z~$$$$:>>>333(%$$ zr%cD||j|j|S)z`Create a comment using the comment_factory. *text* is the text of the comment. )_handle_singlerrrs r&commentzTreeBuilder.comments) ""  !4#7?? ?r%cF||j|j||S)zCreate a processing instruction using the pi_factory. *target* is the target name of the processing instruction. *text* is the data of the processing instruction, or ''. )rrr)r3rrDs r&pizTreeBuilder.pis* ""  dovt== =r%c||}|rI|||_|jr |jd|d|_|S)Nrcr)rrrr^r)r3factoryreargsrFs r&rzTreeBuilder._handle_singlesYw~   KKMMMDJz , 2%%d+++DJ r%rC) r r!r"r#r5rrrrrrrrr$r%r&rrts&(!%$!&5((((((      "   ???====r%rcbeZdZdZddddZdZdZdZdZd Z d Z d Z d Z d Z dZdZdS)raaElement structure builder for XML source data based on the expat parser. *target* is an optional target object which defaults to an instance of the standard TreeBuilder class, *encoding* is an optional encoding string which if given, overrides the encoding specified in the XML file: http://www.iana.org/assignments/character-sets N)rrc@ ddlm}n3#t$r& ddl}n#t$rtdwxYwYnwxYw||d}|t }|x|_|_|x|_|_ |j |_ i|_ |j |_t|dr |j|_t|dr |j|_t|dr |j|_t|dr |j|_t|d r |j|_t|d r |j|_t|d r |j|_d |_d |_d|_ i|_! d |j"z|_#dS#tH$rYdSwxYw)Nrexpatz7No module named expat; use SimpleXMLTreeBuilder insteadrrrstart_nsend_nsrrrrzExpat %d.%d.%d)% xml.parsersr ImportErrorpyexpat ParserCreaterrrvr_targeterror_error_names_defaultDefaultHandlerExpandr)_startStartElementHandler_endEndElementHandler _start_nsStartNamespaceDeclHandler_end_nsEndNamespaceDeclHandlerrCharacterDataHandlerrCommentHandlerrProcessingInstructionHandler buffer_textordered_attributes_doctypeentity version_infoversionr)r3rrrrs r&r5zXMLParser.__init__s  ) ) ) ) ) ) )    '''''   !M (' ##Hc22 > ]]F%++ dl%++ dlk  &*m# 67 # # 5)-F & 65 ! ! 1'+yF $ 6: & & >/3~F , 68 $ $ :-1\F * 66 " " 6*0+F ' 69 % % 3$*NF ! 64  <28)F /$%!   +e.@@DLLL    DD s. 99399>F FFc|j}|j}|D]}|dkrd|_|||jfd}||_#|dkr|||jfd}||_=|dkr0t|jdr |||j fd}n||fd }||_ s|d kr0t|jd r |||j fd }n||fd }||_ |dkr|||fd}||_ |dkr|||fd}||_td|zdS)Nrrc4|||||fdSrCr$)r( attrib_inrr^rs r&handlerz%XMLParser._setevents..handler1s)FE55i#8#89:::::r%rc2||||fdSrCr$)r(rr^rs r&rz%XMLParser._setevents..handler6s%FE33s88,-----r%zstart-nsrc4|||||fdSrCr$)rrrr^rs r&rz%XMLParser._setevents..handler=s)xx'<'<=>>>>>r%c,|||pd|pdffdSNrr$)rrrr^s r&rz%XMLParser._setevents..handlerAs* "ciR'@ABBBBBr%zend-nsrc2||||fdSrCr$)rrr^rs r&rz%XMLParser._setevents..handlerGs%vvf~~677777r%c ||dfdSrCr$)rrr^s r&rz%XMLParser._setevents..handlerKst}-----r%rcP|||j|fdSrC)rr)rDrr^r3s r&rz%XMLParser._setevents..handlerOs-FE4;#6#6t#<#<=>>>>>r%rcR|||j||fdSrC)rr) pi_targetrrr^r3s r&rz%XMLParser._setevents..handlerSs-FE4;>>)T#B#BCDDDDDr%zunknown event %r)rvr^rrrrrr)rrrrrrrr)r3 events_queueevents_to_reportrr^ event_namers r&rzXMLParser._setevents%s$** B* BJW$$,-)2fCCCC3:00x''4;11..8'+|88888/9....18..y(((26????(/%%t##3=f!%EEEE7>33 !3j!@AAAU* B* Br%cbt|}|j|_|j|jf|_|rC)r codelinenooffsetposition)r3rerrs r& _raiseerrorzXMLParser._raiseerrorZs-:|U\1  r%cn |j|}n%#t$r|}d|vrd|z}||j|<YnwxYw|S)Nrr)rKeyError)r3r}names r&_fixnamezXMLParser._fixname`s` $;s#DD $ $ $Dd{{Tz#DK     $  s 22c@|j|pd|pdSr)rrr3rrs r&rzXMLParser._start_nsks"{##FLb#)<<tdt|dD]}||dz||||< |j||S)NrrKr)rrangerHrr)r3r( attr_listfixnamer1is r&rzXMLParser._startqs-gcll  ?1c)nna00 ? ?09!A#wwy|,,--{  f---r%c\|j||SrC)rrrrs r&rzXMLParser._end}s"{t}}S11222r%c|dd}|dkr |jj}n#t$rYdSwxYw ||j|dddS#t$raddlm}|d||jj |jj fz}d|_ |jj |_ |jj |_ |wxYw|dkr|dd d kr g|_dS|j|d kr d|_dS|}|sdS|j|t#|j}|d kr|jd}|d kr|dkr|j\}}} } | r | dd} n|dkr|dkr|j\}}} d} ndSt%|jdr%|j|| | ddn*t%|drt)jdt,d|_dSdSdS)NrrErcrrz'undefined entity %s: line %d, column %d r z RuntimeWarning) r3rDr data_handlerrrnrhrpubidsystems r&rzXMLParser._defaults}bqb S== #{/ !      T[ad455555   ------kk=4;6K133 ![8 ![:   s]]tBQBx;66DMMM ] &}} $ ::< AAA A) B) A63B5A66B Bcp|j} |jd|jddn,#|j$r}||Yd}~nd}~wwxYw|j|dS#|j|wxYw)NFr%)rGetReparseDeferralEnabledSetReparseDeferralEnabledrrr)r3 was_enabledrs r&rzXMLParser.flushsk;;==  ? K 1 1% 8 8 8 K  c5 ) ) ) ){     Q          K 1 1+ > > > > >DK 1 1+ > > > >s/5AB A:A50B5A::BB5)r r!r"r#r5rrrrrrrrrrrr$r%r&rrs"&+++++Z3B3B3Bj   ===000 . . .3334%4%4%l   ***"?????r%r)out from_filec H||tdd}|tjx}}tt |jfi|}|*|||n|t|||| ndS)a3Convert XML to its C14N 2.0 serialised form. If *out* is provided, it must be a file or file-like object that receives the serialised canonical XML output (text, not bytes) through its ``.write()`` method. To write to a file, open it in text mode with encoding "utf-8". If *out* is not provided, this function returns the output as text string. Either *xml_data* (an XML string) or *from_file* (a file path or file-like object) must be provided as input. The configuration options are the same as for the ``C14NWriterTarget``. Nz:Either 'xml_data' or 'from_file' must be provided as inputr)r) rrrSrrrrrr rU)xml_datar!r"optionssiors r&rrsI-UVVV C {KMM!c .syDDGDD E E EF H    i'''' _3<<>>>$6r%z ^\w+:\w+$ceZdZdZdddddddddZefdZdZddZd Z d j fd Z d Z d Z ddZdZdZdZdS)ra Canonicalization writer target for the XMLParser. Serialises parse events to XML C14N 2.0. The *write* function is used for writing out the resulting data stream as text (not bytes). To write to a file, open it in text mode with encoding "utf-8" and pass its ``.write`` method. Configuration options: - *with_comments*: set to true to include comments - *strip_text*: set to true to strip whitespace before and after text content - *rewrite_prefixes*: set to true to replace namespace prefixes by "n{number}" - *qname_aware_tags*: a set of qname aware tag names in which prefixes should be replaced in text content - *qname_aware_attrs*: a set of qname aware attribute names in which prefixes should be replaced in text content - *exclude_attrs*: a set of attribute names that should not be serialised - *exclude_tags*: a set of tag names that should not be serialised FN) with_comments strip_textrewrite_prefixesqname_aware_tagsqname_aware_attrs exclude_attrs exclude_tagscX||_g|_||_||_|rt |nd|_|rt |nd|_||_|rt ||_nd|_|rt |j |_ nd|_ dgg|_ g|_ |s>|j tt|j gi|_dg|_d|_d|_d|_d|_dS)N)rArFr)_writer_with_comments _strip_textr_exclude_attrs _exclude_tags_rewrite_prefixes_qname_aware_tags intersection_find_qname_aware_attrs_declared_ns_stack _ns_stackr^rrr _prefix_map_preserve_space_pending_start _root_seen _root_done_ignored_depth) r3rr(r)r*r+r,r-r.s r&r5zC14NWriterTarget.__init__sE  +%4AKc-000t2>HS...D!1  *%()9%:%:D " "%)D "  0+./@+A+A+ND ( (+/D ( <$ #  @ N ! !$~';';'='=">"> ? ? ? b!!! %w"r%c#:K||D] }|r|Ed{V dSrCr$)r3ns_stack _reversedrps r&_iter_namespacesz!C14NWriterTarget._iter_namespaces7sJ#)H-- & &J &%%%%%%%% & &r%c|dd\}}||jD]\}}||kr d|d|cStd|d|d)NrrrrzPrefix z of QName "" is not declared in scope)splitrDr:r)r3 prefixed_namerrrps r&_resolve_prefix_namez%C14NWriterTarget._resolve_prefix_name<s$**322 ++DN;; * *FCF{{)C))4)))))_6__m___```r%c|4|dddkr|ddddnd|f\}}n|}t}||jD]4\}}||kr||vr|r|d|n|||fcS||5|jrd||jvr|j|}n!dt|jx}|j|<|jd||f|d|||fS|s d|vr|||fS||j D]=\}}||kr2|jd||f|r|d|n|||fcS>|s|||fStd|d ) Nrrrrrrrcz Namespace "rF) rrrDr9addr5r;rHr^r:r)r3rrr( prefixes_seenurs r&_qnamezC14NWriterTarget._qnameCs$ ;38!93C3CuQRRy''Q///"eHCC ..t/FGG & &IAvCxxF-77,2;&((3(((S#EEEE   f % % % %  ! /d&&&)#.1LS9I5J5J1L1LL)#.  #B ' . .V} = = =$$s$$c3. . !r..S= ..t~>> F FIAvCxx'+22C=AAA,2;&((3(((S#EEEE !S= FsFFFGGGr%cL|js|j|dSdSrC)r@rr^rs r&rzC14NWriterTarget.datahs3" $ J  d # # # # # $ $r%rcd||j}|jdd=|jr!|jds|}|j7|jdc}|_|rt |r|nd}|jg||R|dS|r+|jr&|t|dSdSdSNrc) rr2r<rjr=_looks_like_prefix_namerr>r0_escape_cdata_c14n)r3 _join_textrr qname_texts r&rzC14NWriterTarget._flushlsz$*%% JqqqM   D$8$< ::<D  F C/////r%cj"|r fd|D}|h|}i}|/|x}||<||jh|rf|}|rL|D]H} || } t | r/| x}|| <||Ind}nd}jfdt|dD} |r!d|D} | ng} |rlt|D]J\} }|| |vr||vr| ||d}| | \}} }| |r|n| |fK| d}j |r|dkn j d j }|d | |dz| r(|d d | D|d |*|t| ||dd_j gdS)Nc.i|]\}}|jv||Sr$)r3).0rrr3s r& z+C14NWriterTarget._start..s,TTTdaq@S7S7SQ7S7S7Sr%c(i|]}||Sr$r$)r\r parse_qnames r&r]z+C14NWriterTarget._start..s/444qKKNN444r%c.|ddS)Nrr)rG)rs r&rz)C14NWriterTarget._start..s!''#q//r%rc*g|]\}}|rd|znd|fS)zxmlns:xmlnsr$)r\rrs r& z+C14NWriterTarget._start..s@C'-9F""'3?r%rz+{http://www.w3.org/XML/1998/namespace}spacepreservercrrc@g|]\}}d|dt|dS)rrr)_escape_attrib_c14n)r\rrs r&rcz+C14NWriterTarget._start..s9TTT$!Q=q==$7$:$:===TTTr%rT)r3rrJrLr8rSrOrsortr^r|r<r0rrTr>r:)r3r(rrYrVrresolved_namesrqattrs attr_namer parsed_qnamesrrr attr_qnamerspace_behaviourrr_s` @r&rzC14NWriterTarget._starts6   *u *TTTTekkmmTTTE  !151J1J:1V1V VEN:. JJu     ' 3 311%88F !'**I!),E.u55*8<8Q8QRW8X8XXu 5 5))) * Fk 4444F 11535353444   #1I NN    I  Hu{{}}-- H H1%!v++!~:M:M%nQ&78;A-:1-=* Is  "B**A!FGGGG ))$QRR ##-< *Oz ) )%b) + + +   cM#&q))***  W E"''TT)TTTUU V V V c   ! E$]>*3M%Nq%QRR S S S b!!!!!r%c|jr|xjdzc_dS|jr||d||dd|jt|jdk|_|j |j dS)Nrrrr) r@rrr0rOr<rrHr?r9r:rs r&rzC14NWriterTarget.ends      1 $   F :  KKMMM /S))!,///000   """d233q8 ##%%% r%c0|jsdS|jrdS|jr|dn"|jr|jr||dt|d|js|ddSdS)Nrz)r1r@r?r0r>rrrTrs r&rzC14NWriterTarget.comments"  F    F ?  KK     _   KKMMM 8-d33888999  KK       r%c4|jrdS|jr|dn"|jr|jr|||rd|dt |dnd|d|js|ddSdS)Nrz)r@r?r0r>rrrT)r3rrs r&rzC14NWriterTarget.pis    F ?  KK     _   KKMMM :> S 6 6 6,T22 6 6 6 6OOOO U U U  KK       r%rC)r r!r"r#r5reversedrDrJrOrrrrrrrrrr$r%r&rrs, %"&$#$# # # # # J4<&&&& aaa#H#H#H#HJ$$$!# 2 2 2 2111000"C"C"C"C"J           r%rc& d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw) NrErFrrGrrHrN rIrs r&rTrTs) $;;<<W--D $;;<<V,,D $;;<<V,,D 4<<<<g..D ~ &)))"4(((((()sA)A,, BBc d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}d |vr|d d }d |vr|d d }|S#ttf$rt|YdSwxYw) NrErFrrGrrMrOz rz rNrsrIrs r&rfrfs) $;;<<W--D $;;<<V,,D $;;<<X..D 4<<<<g..D 4<<<<g..D 4<<<<g..D ~ &)))"4(((((()sBB CC)r)_set_factoriesrCr)rfr)@r#__all__rrdr:r=rrcollections.abcrrrrrr r rrrrr rrcontextmanagerrrrr4r2rrrrrrrr3rrrXrrrr r rrrrrrrrcompileUNICODEr;rSrrTrfrg _elementtreerurr$r%r&r|s'!!P   (             ### jjjjjjjjZ $&$     +"+"+"+"+"+"+"+"`_/_/_/_/_/_/_/_/H /+/+/+b;;;;z0(0(0(d 0(0(0(d    !!!*-2$*38(.(,16(,  %3!   ))) )))8 ) ) )!T"&0b'" !%&*     &////l    5555p77777777t",     $vvvvvvvvth?h?h?h?h?h?h?h?Z7tt77777<%"*\2:>>DD)))&))). 3K++++++N7122222   DD s E77F?F__pycache__/cElementTree.cpython-311.opt-1.pyc000064400000000314151027357230014774 0ustar00 !A?hRddlTdS))*N)xml.etree.ElementTree//usr/lib64/python3.11/xml/etree/cElementTree.pyrs$#####r__pycache__/ElementPath.cpython-311.pyc000064400000041521151027357230013674 0ustar00 !A?h6ddlZejdZddZdZdZdZdZdZd Z d Z d Z d Z eee e e e d Z iZGddZddZddZddZddZdS)Nz`('[^']*'|\"[^\"]*\"|::|//?|\.\.|\(\)|!=|[/.*:\[\]\(\)@=])|((?:\{[^}]+\})?[^/\[\]\(\)@!=\s]+)|\s+c#K|r|dnd}d}t|D]}|\}}|r|ddkrsd|vrW|dd\}} |st|d||d|fVn6#t$rt d|zdwxYw|r|s |d|d|fVn|Vd}|V|d k}dS) NFr{:}z!prefix %r not found in prefix map@)getxpath_tokenizer_refindallsplitKeyError SyntaxError) pattern namespacesdefault_namespaceparsing_attributetokenttypetagprefixuris ./usr/lib64/python3.11/xml/etree/ElementPath.pyxpath_tokenizerrJsY.8B r***d#++G44-- s  -3q6S==czz!iiQ// ^%'&%Z-?-?-?!EEEEEE^^^%&IF&RSSY]]^" +< e):):):CC@@@@@@ %  KKK %  %--s +BB%cv|j}|/ix|_}|jD] }|D]}|||< |SN) parent_maprootiter)contextrpes rget_parent_mapr#bs_#J*,,Z""$$ " "A " " ! 1  " c:|dddkp |dddkS)N{*}}*rs r_is_wildcard_tagr,ls' rr7e  /s233x4//r$cttcdkrfd}ndkrfd}ndddkr<ddtt dddfd}nPd dd kr0dd tdtfd }nt d |S)Nz{*}*c3@K|D]}|jr|VdSrr+)r resultelem _isinstance_strs rselectz_prepare_tag..selectvs@  ;tx..JJJ  r$z{}*c3\K|D]%}|j}|r|ddkr|V&dS)Nrrr+)r r/r0el_tagr1r2s rr3z_prepare_tag..select|sS  ;vt,,c1A1AJJJ  r$r&r'c3hK|D]+}|j}|ks|r|kr|V,dSrr+) r r/r0r5r1r2no_nssuffixrs rr3z_prepare_tag..selectsY  S==KK$=$==&-SYBYBYJJJ  r$r(r)c3\K|D]%}|j}|r|kr|V&dSrr+)r r/r0r5r1r2nsns_onlys rr3z_prepare_tag..selectsS  ;vt,,B1F1FJJJ  r$zinternal parser error, got ) isinstancestrslicelen RuntimeError)rr3r1r2r8r<r=r9s` @@@@@@r _prepare_tagrCpsi"CK f}}                RaRE  QRRs6{{lD))!""g           RSST   "Xc"gg&&          >>>??? Mr$c|dtrtfd}ndddkr ddfd}|S)Nrc4d}|||S)Nc3$K|D] }|Ed{V dSrr*)r/r0s r select_childz3prepare_child..select..select_childs2"$$D#OOOOOOOO$$r$r*r r/rG select_tags rr3zprepare_child..selects0 $ $ $:g||F';';<< K|D]}|D]}|jkr|VdSrr+r r/r0r"rs rr3zprepare_child..selectsI    Au||   r$)r,rCnextrr3rIrs @@r prepare_childrOs (C !#&&  = = = = = = rr7d??abb'C     Mr$c d}|S)Nc3$K|D] }|Ed{V dSrr*)r r/r0s rr3zprepare_star..selects2  DOOOOOOOO  r$r*rNrr3s r prepare_starrSs Mr$c d}|S)Nc3K|Ed{VdSrr*)r r/s rr3zprepare_self..selects$r$r*rRs r prepare_selfrVs Mr$c$ |}n#t$rYdSwxYw|ddkrdn |ds |dntdtrtfd}ndddkr ddfd}|S) Nr*rzinvalid descendantc4d}|||S)Nc3RK|D]!}|D] }||ur|V "dSrr)r/r0r"s rrGz8prepare_descendant..select..select_childsN"$$D!YY[[$$D=="#GGG$$$r$r*rHs rr3z"prepare_descendant..selects0 $ $ $ :g||F';';<< .selectsQ  3  A}}   r$) StopIterationrr,rCrMs @@rprepare_descendantr^s  Qx3 1X0Ah./// !#&&  = = = = = = rr7d??abb'C     Ms  c d}|S)Nc3hKt|}i}|D]}||vr||}||vr d||<|VdSr)r#)r r/r result_mapr0parents rr3zprepare_parent..selectse#G,,   ! !Dz!!#D)++)-Jv& LLL  ! !r$r*rRs rprepare_parentrcs ! ! ! Mr$c g}g} |}n#t$rYdSwxYw|ddkrnl|dkr2|dr$|ddddvrd|dddf}||dpd||dd |}|d kr|dfd }|S|d ks|d kr$|d|d  fd} fd}d|vr|n|S|dkr*tjd|ds|dfd}|S|dks-|dks'|dks|dkrLtjd|ds1|d|d r  fd} fd}n fd} fd}d|vr|n|S|dks |dks|dkr|dkr.t |ddz dkrt dnp|ddkrt d|dkrM t |d dz n#t$rt d!wxYwd"krt d#ndfd$}|St d%)&Nrr])rrz'"'r:-rz@-c3HK|D]}||VdSrr )r r/r0keys rr3z!prepare_predicate..selects:  88C==,JJJ  r$z@-='z@-!='c3PK|D]}|kr|V dSrri)r r/r0rjvalues rr3z!prepare_predicate..selects?  88C==E))JJJ  r$c3XK|D]#}|x} |kr|V$dSrri)r r/r0 attr_valuerjrls rselect_negatedz)prepare_predicate..select_negatedsI  "&((3--/J<uATATJJJ  r$z!=z\-?\d+$c3HK|D]}||VdSr)find)r r/r0rs rr3z!prepare_predicate..selects:  99S>>-JJJ  r$z.='z.!='z-='z-!='c3K|D]K}|D]3}d|kr|Vn4LdSNr)r joinitertextr r/r0r"rrls rr3z!prepare_predicate..selectsn"""D!\\#..""771::<<00E99"&JJJ!E:""r$c3K|D]K}|D]3}d|kr|Vn4LdSrs)iterfindrtrurvs rroz)prepare_predicate..select_negated"sn"""D!]]3//""771::<<00E99"&JJJ!E:""r$c3tK|D]1}d|kr|V2dSrsrtrur r/r0rls rr3z!prepare_predicate..select)I"##Dwwt}}//588" ##r$c3tK|D]1}d|kr|V2dSrsrzr{s rroz)prepare_predicate..select_negated-r|r$z-()z-()-zXPath position >= 1 expectedlastzunsupported functionr6zunsupported expressionr(z)XPath offset from last() must be negativec3Kt|}|D]W} ||}t||j}||ur|VA#tt f$rYTwxYwdSr)r#listr r IndexErrorr)r r/rr0rbelemsindexs rr3z!prepare_predicate..selectEs'00J  '-F !9!9::EU|t++" "H-D  s=AA*)A*zinvalid predicate)r]appendrtrematchintr ValueError) rNr signature predicater3rorrjrrls @@@@rprepare_predicatersII # DFFEE    FF  8s??  H    8 (a! --q!B$'EqS)))q""" # ""IDl      Fi722l"             "&!2!2~~>CYq\ B Bl      EY&00 %  9#6#6HZ166$7l"   # " " " " " "  " " " " " " " # # # # # # # # # #"&!2!2~~>C9--f1D1D    ! %%)Eqyy!"@AAA|v%%!"8999F""@ ! --1EE!@@@%&>???@2::%&QRRR      ) * **s  $$6HH))rrX.z..z//[ceZdZdZdZdS)_SelectorContextNc||_dSr)r)selfrs r__init__z_SelectorContext.__init__`s  r$)__name__ __module__ __qualname__rrr*r$rrr^s(Jr$rcZ|dddkr|dz}|f}|r1|tt|z } t|}n.#t$r t tdkrt|dddkrtdtt||j } |}n#t$rYYdSwxYwg} | t|d||n#t$rtddwxYw |}|ddkr |}n#t$rYnwxYw|t|<YnwxYw|g}t|}|D]} | ||}|S) Nr:/rXdrz#cannot use absolute path on elementrz invalid path)tuplesorteditems_cacherrAclearrrr__next__r]ropsr) r0pathr cache_keyselectorrNrr/r r3s rrxrxhs  BCCyCczI7U6*"2"2"4"455666 %)$ %%% v;;   LLNNN 8s??CDD DOD*5566? DFFEE    FFF   <E!H dE : :;;;;  < < <!.11t; < 8s?? DFFE      %y-%0VFt$$G))(( Mss AA;F C! F! C0+F/C00F7/D'&F'EF E'&F' E41F3E44FFc@tt|||dSr)rNrxr0rrs rrqrqs tZ00$ 7 77r$c>tt|||Sr)rrxrs rr r s tZ00 1 11r$c tt|||}|jdS|jS#t$r|cYSwxYwrs)rNrxtextr])r0rdefaultrs rfindtextrsYHT44455 9 2y s%00 ??r)NN)rcompiler rr#r,rCrOrSrVr^rcrrrrrxrqr rr*r$rrstv RZ    ----0000&&&R&  >   n+n+n+b        ''''X8888 2222 r$__pycache__/ElementInclude.cpython-311.pyc000064400000011016151027357230014357 0ustar00 !A?hddlZddlmZddlmZdZedzZedzZdZGd d e Z Gd d e Z dd Z ddefdZ dZdS)N) ElementTree)urljoinz!{http://www.w3.org/2001/XInclude}includefallbackceZdZdS)FatalIncludeErrorN__name__ __module__ __qualname__1/usr/lib64/python3.11/xml/etree/ElementInclude.pyr r CDrr ceZdZdS)LimitedRecursiveIncludeErrorNr rrrrrGrrrc4|dkrOt|d5}tj|}dddn #1swxYwYnB|sd}t|d|5}|}dddn #1swxYwY|S)NxmlrbzUTF-8r)encoding)openrparsegetrootread)hrefrrfiledatas rdefault_loaderr!Ws ~~ $   5$T**2244D 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 H $h / / / 499;;D                Ks#'A  AA,B  BBc|d}n|dkrtd|zt|dr|}|t}t ||||t dS)Nrz;expected non-negative depth or None for 'max_depth', got %rr) ValueErrorhasattrrr!_includeset)elemloaderbase_url max_depths rrrtsv QVYbbccctY||~~ ~ T68Y66666rcNd}|t|kr||}|jtkr|d}|rt ||}|dd}|dkr||vrt d|z|dkrt d|z|||||} | t d|d|tj| } t| |||d z || ||j r| j pd |j z| _ | ||<n|d kr}||||d } | t d|d||j r | |j z } |r||d z } | j pd | z| _ n|j pd | z|_ ||=t d |z|jtkrt d|jzt||||||d z }|t|k dSdS)Nrrrrzrecursive include of %sz5maximum xinclude depth reached when including file %sz cannot load z as rtextrz)unknown parse type in xi:include tag (%r)z0xi:fallback tag must be child of xi:include (%r))lentagXINCLUDE_INCLUDEgetrr raddcopyr&removetailr.XINCLUDE_FALLBACK) r(r)r*r+ _parent_hrefsierrnoder.s rr&r&s A c$ii-- G 5$ $ $55==D /x..EE'5))E~~=((+,E,LMMM>>6ORVVXXX!!$'''vdE**<++26$$>yvtY]MJJJ$$T***6;!%bAF :DIQ&vdE155+<+<==<++26$$>6#AFND9!9D!%bD 8DII!%bD 8DIG'?%GU' ' '#BQUJ  Q)] C C C Qg c$ii------r)N)r4r-r urllib.parserXINCLUDEr1r7DEFAULT_MAX_INCLUSION_DEPTH SyntaxErrorr rr!rr&rrrr@sf  .i'z)               #4      :1 7 7 7 766666r__pycache__/ElementPath.cpython-311.opt-1.pyc000064400000041521151027357230014633 0ustar00 !A?h6ddlZejdZddZdZdZdZdZdZd Z d Z d Z d Z eee e e e d Z iZGddZddZddZddZddZdS)Nz`('[^']*'|\"[^\"]*\"|::|//?|\.\.|\(\)|!=|[/.*:\[\]\(\)@=])|((?:\{[^}]+\})?[^/\[\]\(\)@!=\s]+)|\s+c#K|r|dnd}d}t|D]}|\}}|r|ddkrsd|vrW|dd\}} |st|d||d|fVn6#t$rt d|zdwxYw|r|s |d|d|fVn|Vd}|V|d k}dS) NFr{:}z!prefix %r not found in prefix map@)getxpath_tokenizer_refindallsplitKeyError SyntaxError) pattern namespacesdefault_namespaceparsing_attributetokenttypetagprefixuris ./usr/lib64/python3.11/xml/etree/ElementPath.pyxpath_tokenizerrJsY.8B r***d#++G44-- s  -3q6S==czz!iiQ// ^%'&%Z-?-?-?!EEEEEE^^^%&IF&RSSY]]^" +< e):):):CC@@@@@@ %  KKK %  %--s +BB%cv|j}|/ix|_}|jD] }|D]}|||< |SN) parent_maprootiter)contextrpes rget_parent_mapr#bs_#J*,,Z""$$ " "A " " ! 1  " c:|dddkp |dddkS)N{*}}*rs r_is_wildcard_tagr,ls' rr7e  /s233x4//r$cttcdkrfd}ndkrfd}ndddkr<ddtt dddfd}nPd dd kr0dd tdtfd }nt d |S)Nz{*}*c3@K|D]}|jr|VdSrr+)r resultelem _isinstance_strs rselectz_prepare_tag..selectvs@  ;tx..JJJ  r$z{}*c3\K|D]%}|j}|r|ddkr|V&dS)Nrrr+)r r/r0el_tagr1r2s rr3z_prepare_tag..select|sS  ;vt,,c1A1AJJJ  r$r&r'c3hK|D]+}|j}|ks|r|kr|V,dSrr+) r r/r0r5r1r2no_nssuffixrs rr3z_prepare_tag..selectsY  S==KK$=$==&-SYBYBYJJJ  r$r(r)c3\K|D]%}|j}|r|kr|V&dSrr+)r r/r0r5r1r2nsns_onlys rr3z_prepare_tag..selectsS  ;vt,,B1F1FJJJ  r$zinternal parser error, got ) isinstancestrslicelen RuntimeError)rr3r1r2r8r<r=r9s` @@@@@@r _prepare_tagrCpsi"CK f}}                RaRE  QRRs6{{lD))!""g           RSST   "Xc"gg&&          >>>??? Mr$c|dtrtfd}ndddkr ddfd}|S)Nrc4d}|||S)Nc3$K|D] }|Ed{V dSrr*)r/r0s r select_childz3prepare_child..select..select_childs2"$$D#OOOOOOOO$$r$r*r r/rG select_tags rr3zprepare_child..selects0 $ $ $:g||F';';<< K|D]}|D]}|jkr|VdSrr+r r/r0r"rs rr3zprepare_child..selectsI    Au||   r$)r,rCnextrr3rIrs @@r prepare_childrOs (C !#&&  = = = = = = rr7d??abb'C     Mr$c d}|S)Nc3$K|D] }|Ed{V dSrr*)r r/r0s rr3zprepare_star..selects2  DOOOOOOOO  r$r*rNrr3s r prepare_starrSs Mr$c d}|S)Nc3K|Ed{VdSrr*)r r/s rr3zprepare_self..selects$r$r*rRs r prepare_selfrVs Mr$c$ |}n#t$rYdSwxYw|ddkrdn |ds |dntdtrtfd}ndddkr ddfd}|S) Nr*rzinvalid descendantc4d}|||S)Nc3RK|D]!}|D] }||ur|V "dSrr)r/r0r"s rrGz8prepare_descendant..select..select_childsN"$$D!YY[[$$D=="#GGG$$$r$r*rHs rr3z"prepare_descendant..selects0 $ $ $ :g||F';';<< .selectsQ  3  A}}   r$) StopIterationrr,rCrMs @@rprepare_descendantr^s  Qx3 1X0Ah./// !#&&  = = = = = = rr7d??abb'C     Ms  c d}|S)Nc3hKt|}i}|D]}||vr||}||vr d||<|VdSr)r#)r r/r result_mapr0parents rr3zprepare_parent..selectse#G,,   ! !Dz!!#D)++)-Jv& LLL  ! !r$r*rRs rprepare_parentrcs ! ! ! Mr$c g}g} |}n#t$rYdSwxYw|ddkrnl|dkr2|dr$|ddddvrd|dddf}||dpd||dd |}|d kr|dfd }|S|d ks|d kr$|d|d  fd} fd}d|vr|n|S|dkr*tjd|ds|dfd}|S|dks-|dks'|dks|dkrLtjd|ds1|d|d r  fd} fd}n fd} fd}d|vr|n|S|dks |dks|dkr|dkr.t |ddz dkrt dnp|ddkrt d|dkrM t |d dz n#t$rt d!wxYwd"krt d#ndfd$}|St d%)&Nrr])rrz'"'r:-rz@-c3HK|D]}||VdSrr )r r/r0keys rr3z!prepare_predicate..selects:  88C==,JJJ  r$z@-='z@-!='c3PK|D]}|kr|V dSrri)r r/r0rjvalues rr3z!prepare_predicate..selects?  88C==E))JJJ  r$c3XK|D]#}|x} |kr|V$dSrri)r r/r0 attr_valuerjrls rselect_negatedz)prepare_predicate..select_negatedsI  "&((3--/J<uATATJJJ  r$z!=z\-?\d+$c3HK|D]}||VdSr)find)r r/r0rs rr3z!prepare_predicate..selects:  99S>>-JJJ  r$z.='z.!='z-='z-!='c3K|D]K}|D]3}d|kr|Vn4LdSNr)r joinitertextr r/r0r"rrls rr3z!prepare_predicate..selectsn"""D!\\#..""771::<<00E99"&JJJ!E:""r$c3K|D]K}|D]3}d|kr|Vn4LdSrs)iterfindrtrurvs rroz)prepare_predicate..select_negated"sn"""D!]]3//""771::<<00E99"&JJJ!E:""r$c3tK|D]1}d|kr|V2dSrsrtrur r/r0rls rr3z!prepare_predicate..select)I"##Dwwt}}//588" ##r$c3tK|D]1}d|kr|V2dSrsrzr{s rroz)prepare_predicate..select_negated-r|r$z-()z-()-zXPath position >= 1 expectedlastzunsupported functionr6zunsupported expressionr(z)XPath offset from last() must be negativec3Kt|}|D]W} ||}t||j}||ur|VA#tt f$rYTwxYwdSr)r#listr r IndexErrorr)r r/rr0rbelemsindexs rr3z!prepare_predicate..selectEs'00J  '-F !9!9::EU|t++" "H-D  s=AA*)A*zinvalid predicate)r]appendrtrematchintr ValueError) rNr signature predicater3rorrjrrls @@@@rprepare_predicatersII # DFFEE    FF  8s??  H    8 (a! --q!B$'EqS)))q""" # ""IDl      Fi722l"             "&!2!2~~>CYq\ B Bl      EY&00 %  9#6#6HZ166$7l"   # " " " " " "  " " " " " " " # # # # # # # # # #"&!2!2~~>C9--f1D1D    ! %%)Eqyy!"@AAA|v%%!"8999F""@ ! --1EE!@@@%&>???@2::%&QRRR      ) * **s  $$6HH))rrX.z..z//[ceZdZdZdZdS)_SelectorContextNc||_dSr)r)selfrs r__init__z_SelectorContext.__init__`s  r$)__name__ __module__ __qualname__rrr*r$rrr^s(Jr$rcZ|dddkr|dz}|f}|r1|tt|z } t|}n.#t$r t tdkrt|dddkrtdtt||j } |}n#t$rYYdSwxYwg} | t|d||n#t$rtddwxYw |}|ddkr |}n#t$rYnwxYw|t|<YnwxYw|g}t|}|D]} | ||}|S) Nr:/rXdrz#cannot use absolute path on elementrz invalid path)tuplesorteditems_cacherrAclearrrr__next__r]ropsr) r0pathr cache_keyselectorrNrr/r r3s rrxrxhs  BCCyCczI7U6*"2"2"4"455666 %)$ %%% v;;   LLNNN 8s??CDD DOD*5566? DFFEE    FFF   <E!H dE : :;;;;  < < <!.11t; < 8s?? DFFE      %y-%0VFt$$G))(( Mss AA;F C! F! C0+F/C00F7/D'&F'EF E'&F' E41F3E44FFc@tt|||dSr)rNrxr0rrs rrqrqs tZ00$ 7 77r$c>tt|||Sr)rrxrs rr r s tZ00 1 11r$c tt|||}|jdS|jS#t$r|cYSwxYwrs)rNrxtextr])r0rdefaultrs rfindtextrsYHT44455 9 2y s%00 ??r)NN)rcompiler rr#r,rCrOrSrVr^rcrrrrrxrqr rr*r$rrstv RZ    ----0000&&&R&  >   n+n+n+b        ''''X8888 2222 r$__pycache__/cElementTree.cpython-311.pyc000064400000000314151027357230014035 0ustar00 !A?hRddlTdS))*N)xml.etree.ElementTree//usr/lib64/python3.11/xml/etree/cElementTree.pyrs$#####r__pycache__/ElementTree.cpython-311.opt-1.pyc000064400000257551151027357230014652 0ustar00 !A?h"dZgdZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z Gdde Zd ZGd d Zifd ZdDd ZdDdZeZGddZGddZe jdZdDdZdZhdZdZdZeeedZdZdddddd d!d"Z e e_ d#Z!d$Z"d%Z#d&Z$dEddd'd(d)Z%Gd*d+ej&Z'dEddd'd(d,Z(d-Z)dFd/Z*dDd0Z+dEd1Z,Gd2d3Z-dDd4Z.dDd5Z/e.Z0dDd6Z1Gd7d8Z2Gd9d:Z3dDddd;d<Z4ej5d=ej6j7Z8Gd>d?Z9d@Z:dAZ; eZZ>e>eedS#e?$rYdSwxYw)GaLightweight XML support for Python. XML is an inherently hierarchical data format, and the most natural way to represent it is with a tree. This module has two classes for this purpose: 1. ElementTree represents the whole XML document as a tree and 2. Element represents a single node in this tree. Interactions with the whole document (reading and writing to/from files) are usually done on the ElementTree level. Interactions with a single XML element and its sub-elements are done on the Element level. Element is a flexible container object designed to store hierarchical data structures in memory. It can be described as a cross between a list and a dictionary. Each Element has a number of properties associated with it: 'tag' - a string containing the element's name. 'attributes' - a Python dictionary storing the element's attributes. 'text' - a string containing the element's text content. 'tail' - an optional string containing text after the element's end tag. And a number of child elements stored in a Python sequence. To create an element instance, use the Element constructor, or the SubElement factory function. You can also use the ElementTree class to wrap an element structure and convert it to and from XML. )CommentdumpElement ElementTree fromstringfromstringlistindent iselement iterparseparse ParseErrorPIProcessingInstructionQName SubElementtostring tostringlist TreeBuilderVERSIONXMLXMLID XMLParser XMLPullParserregister_namespace canonicalizeC14NWriterTargetz1.3.0N) ElementPathceZdZdZdS)r zAn error when parsing an XML document. In addition to its exception value, a ParseError contains two extra attributes: 'code' - the specific exception code 'position' - the line and column of the error N)__name__ __module__ __qualname____doc__./usr/lib64/python3.11/xml/etree/ElementTree.pyr r ks Dr%r c"t|dS)z2Return True if *element* appears to be an Element.tag)hasattr)elements r&r r ys 7E " ""r%ceZdZdZdZ dZ dZ dZ ifdZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZdZddZddZddZddZdZddZdZdZdZddZ dZ!dS)rahAn XML element. This class is the reference implementation of the Element interface. An element's length is its number of subelements. That means if you want to check if an element is truly empty, you should check BOTH its length AND its text attribute. The element tag, attribute names, and attribute values can be either bytes or strings. *tag* is the element name. *attrib* is an optional dictionary containing element attributes. *extra* are additional element attributes given as keyword arguments. Example form: text...tail Nc t|tstd|jj||_i|||_g|_dS)Nzattrib must be dict, not ) isinstancedict TypeError __class__r r(attrib _children)selfr(r1extras r&__init__zElement.__init__s\&$'' -) )),-- -))5) r%cJd|jj|jt|fzS)Nz<%s %r at %#x>)r0r r(idr3s r&__repr__zElement.__repr__s!4>#:DHbhh"OOOr%c.|||S)zCreate a new element with the same type. *tag* is a string containing the element name. *attrib* is a dictionary containing the element attributes. Do not call this method, use the SubElement factory function instead. )r0)r3r(r1s r& makeelementzElement.makeelements~~c6***r%c^tjdt|S)zReturn copy of current element. This creates a shallow copy. Subelements will be shared with the original tree. z7elem.copy() is deprecated. Use copy.copy(elem) instead.)warningswarnDeprecationWarning__copy__r8s r&copyz Element.copys.  E    }}r%c||j|j}|j|_|j|_||dd<|SN)r;r(r1texttail)r3elems r&r@zElement.__copy__s?$+66I I QQQ r%c*t|jSrC)lenr2r8s r&__len__zElement.__len__s4>"""r%cjtjdtdt|jdkS)NzyThe behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. stacklevelr)r=r> FutureWarningrHr2r8s r&__bool__zElement.__bool__s=  K a     4>""a''r%c|j|SrCr2r3indexs r& __getitem__zElement.__getitem__s~e$$r%ct|tr|D]}||n||||j|<dSrC)r-slice_assert_is_elementr2)r3rSr*elts r& __setitem__zElement.__setitem__sg eU # # - - -'',,,, -  # #G , , , 'ur%c|j|=dSrCrQrRs r& __delitem__zElement.__delitem__s N5 ! ! !r%cd|||j|dS)aAdd *subelement* to the end of this element. The new element will appear in document order after the last existing subelement (or directly after the text, if it's the first subelement), but before the end tag for this element. NrWr2appendr3 subelements r&r^zElement.appends4  +++ j)))))r%cn|D]1}|||j|2dS)zkAppend subelements from a sequence. *elements* is a sequence with zero or more elements. Nr])r3elementsr*s r&extendzElement.extendsJ   + +G  # #G , , , N ! !' * * * * + +r%cf|||j||dS)z(Insert *subelement* at position *index*.N)rWr2insert)r3rSr`s r&rezElement.inserts4  +++ eZ00000r%cxt|ts$tdt|jzdS)Nzexpected an Element, not %s)r- _Element_Pyr/typer )r3es r&rWzElement._assert_is_elements@![)) N9DGG)r0r rDr8s r&r9zQName.__repr__s  N333TYYY??r%c*t|jSrC)hashrDr8s r&__hash__zQName.__hash__sDIr%cbt|tr|j|jkS|j|kSrCr-rrDr3others r&__le__z QName.__le__0 eU # # +9 * *yE!!r%cbt|tr|j|jkS|j|kSrCrrs r&__lt__z QName.__lt__0 eU # # *9uz) )y5  r%cbt|tr|j|jkS|j|kSrCrrs r&__ge__z QName.__ge__rr%cbt|tr|j|jkS|j|kSrCrrs r&__gt__z QName.__gt__rr%cbt|tr|j|jkS|j|kSrCrrs r&__eq__z QName.__eq__rr%rC) r r!r"r#r5rr9rrrrrrr$r%r&rrs      @@@"""!!!"""!!!"""""r%rcreZdZdZddZdZdZddZddZddZ dd Z dd Z dd Z dd d dZ dZdS)ra%An XML element hierarchy. This class also provides support for serialization to and from standard XML. *element* is an optional root element node, *file* is an optional file handle or file name of an XML file whose contents will be used to initialize the tree with. NcF||_|r||dSdSrC)_rootr )r3r*files r&r5zElementTree.__init__s3   JJt       r%c|jS)z!Return root element of this tree.rr8s r&getrootzElementTree.getroots zr%c||_dS)zReplace root element of this tree. This will discard the current contents of the tree and replace it with the given element. Use with care! Nr)r3r*s r&_setrootzElementTree._setroot#s r%cd}t|dst|d}d} |Vt}t|dr8|||_|j|r|SS |d}|sn||.||_|j|r|SS#|r|wwxYw)a=Load external XML document into element tree. *source* is a file name or file object, *parser* is an optional parser instance that defaults to XMLParser. ParseError is raised if the parser fails to parse the document. Returns the root element of the given source document. FreadrbTN _parse_wholei)r)openrrrcloserfeed)r3sourceparser close_sourcedatas r&r zElementTree.parse-s vv&& &$''FL ~"6>22& "(!4!4V!AC$$C=c6|j|S)zCreate and return tree iterator for the root element. The iterator loops over all elements in this tree, in document order. *tag* is a string with the tag name to iterate over (default is to return all elements). )rrr3r(s r&rzElementTree.iterRszs###r%c|dddkr$d|z}tjd|ztd|j||S)a\Find first matching element by tag name or path. Same as getroot().find(path), which is Element.find() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return the first matching element, or None if no element was found. Nr/.This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rrKrL)r=r>rNrrmrns r&rmzElementTree.find^sc 8s??:D M-/34!      ztZ000r%c|dddkr$d|z}tjd|ztd|j|||S)aeFind first matching element by tag name or path. Same as getroot().findtext(path), which is Element.findtext() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return the first matching element, or None if no element was found. NrrrrrKrL)r=r>rNrrrrss r&rrzElementTree.findtexttsg 8s??:D M-/34!      z""4*===r%c|dddkr$d|z}tjd|ztd|j||S)aaFind all matching subelements by tag name or path. Same as getroot().findall(path), which is Element.findall(). *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return list containing all matching elements in document order. NrrrrrKrL)r=r>rNrrvrns r&rvzElementTree.findallse 8s??:D M-/34!      z!!$ 333r%c|dddkr$d|z}tjd|ztd|j||S)agFind all matching subelements by tag name or path. Same as getroot().iterfind(path), which is element.iterfind() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return an iterable yielding all matching elements in document order. NrrrrrKrL)r=r>rNrrxrns r&rxzElementTree.iterfindse 8s??:D M-/34!      z""4444r%Tshort_empty_elementsc|sd}n|tvrtd|z|s |dkrd}nd}t||5\}}|dkrA|s0|=|dkr%|dvr|d |d |d krt ||jn:t |j|\} } t|} | ||j| | | ddddS#1swxYwYdS) aWrite element tree to a file as XML. Arguments: *file_or_filename* -- file name or a file object opened for writing *encoding* -- the output encoding (default: US-ASCII) *xml_declaration* -- bool indicating if an XML declaration should be added to the output. If None, an XML declaration is added if encoding IS NOT either of: US-ASCII, UTF-8, or Unicode *default_namespace* -- sets the default XML namespace (for "xmlns") *method* -- either "xml" (default), "html, "text", or "c14n" *short_empty_elements* -- controls the formatting of elements that contain no content. If True (default) they are emitted as a single self-closed tag, otherwise they are emitted as a pair of start/end tags xmlzunknown method %rc14nutf-8us-asciiNunicode)rrz rDr) _serialize ValueError _get_writerlower_serialize_textr _namespaces) r3file_or_filenameencodingxml_declarationdefault_namespacemethodrwritedeclared_encodingqnamesrp serializes r&rzElementTree.writes: ;FF : % %069:: : &"% )8 4 4 E8R@QO$,^^%%22&,,..6KKK%%%()))tz2222%0=N%O%O" &v.  %VZ/CEEEE E E E E E E E E E E E E E E E E E EsB!C,,C03C0c0||dS)Nr)r)r)r3rs r& write_c14nzElementTree.write_c14nszz$vz...r%rrC)NNNN)r r!r"r#r5rrr rrmrrrvrxrrr$r%r&rrs   ####J $ $ $ $1111,>>>>,4444,5555." $ 3E $( 3E3E3E3E3Ej/////r%rc#xK |j}|dkr|t|ddpdfVdStj5}t |t jr|}nt |t jr/t j |}| |j nLt j}d|_ ||_ |j |_ |j|_n#t$rYnwxYwt j||dd}| |j |j|fVddddS#1swxYwYdS#t$rV|dkrd}t#|d|d 5}|j|fVdddYdS#1swxYwYYdSwxYw) NrrrcdSNTr$r$r%r&z_get_writer..sDr%xmlcharrefreplace )rerrorsnewlinew)rr)rrgetattr contextlib ExitStackr-ioBufferedIOBase RawIOBaseBufferedWritercallbackdetachwritableseekabletellAttributeError TextIOWrapperr)rrrstackrs r&rrs-+ & >>  y ( (!1:tDDOO O O O O O%'' +5.0ABB+DD 0",??,-=>>DNN4;////,..D$0LDM!&DJ)9(A $4$9 )'19/B04666 t{+++j(****9 + + + + + + + + + + + + + + + + + + ''' >>  y ( (H "C(,... '15*h& & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'smEB E C21E 2 C?<E >C??AE  EE7F9 F* F9*F. .F91F. 2F98F9cddiird<fd}|D])}|j}t|tr|jvr||jnHt|t r|vr ||n#|!|t ur|turt|| D]^\}}t|tr|j}|vr ||t|tr|jvr||j_|j}t|tr|jvr||j+fS)Nc |dddkr|dddd\}}|}|9t|}|dtz}|dkr||<|r |d||<dS||<dSrt d||<dS#t $rt |YdSwxYw)Nrrrzns%dr:z.add_qname/s .RaRyC 9++C33S#,,>+//44F~!'#j//!9*0 3(/5vvss$;F5MMM$'F5MMM$$3!&u  . . . &u - - - - - - .sB B/B/B//C  C ) rr(r-rrDrrr rr) rFrrr(r}rrDrprs ` @@r&rr$sD\FJ+(* $%.......8 !!h c5 ! ! ,xv%% #(### S ! ! ,&   # _G!3!32 &s + + +**,, & &JC#u%% h&   #%'' &EJf,D,D %*%%%y dE " " !ty'>'> Idi : r%c |j}|j}|tur|d|zn|tur|d|zn||}|5|r|t ||D]}t |||d|na|d|zt |} | s|r|rPt|dD]+\} } | rd| z} |d| d t| d ,| D]k\} } t| tr| j} t| tr|| j} nt| } |d || d | d l|st|s|sP|d |r|t ||D]}t |||d||d |zd zn |d|j r|t |j dSdS)N rrc|dSNrr$xs r&rz _serialize_xml..w QqTr%r}r xmlns=""rr)r(rDrr _escape_cdata_serialize_xmllistrsorted_escape_attribr-rrHrE) rrFrrprkwargsr(rDrirvks r&rras (C 9D g~~ kD !!!! % % % hoSk ; +mD))*** J Jua4HJJJJJ J E#)   &&E 9  9 &z'7'7'9'9+9>!;!;!;1( #aAAA*1----"99DAq!!U++#F!!U++."16N*1--EE&)))QQQ78888 s4yy (< c /E---...NNA"5!VT8LNNNNNdSj3&''''e  y( mDI&&'''''((r%>brhrcolimgwbrareabaselinkmetaembedframeinputparamtrackrisindexbasefontc j|j}|j}|tur|dt|zn|tur|dt|zn||}|3|r|t||D]}t |||dnu|d|zt |}|s|r|rPt|dD]+\} } | rd| z} |d| dt| d ,|D]k\} } t| tr| j} t| tr|| j} nt| } |d || d| d l|d | } |r0| d ks| d kr ||n|t||D]}t |||d| tvr|d|zd z|jr|t|jdSdS)Nr r rc|dSr r$rs r&rz!_serialize_html..rr%rrrrrrrscriptstyler)r(rDrrr_serialize_htmlrrrrr-r_escape_attrib_htmlr HTML_EMPTYrE) rrFrrprr(rDrirrrltags r&r2r2s (C 9D g~~ kM$///0000 % % % ht,,,----Sk ; +mD))*** 8 8q&$7777 8 E#)   &&E 9  9 &z'7'7'9'9+9>!;!;!;1( #aAAA*1----"99DAq!!U++#F!!U++3"16N/22EE&)))QQQ78888 E#JJJ99;;D /8##twE$KKKKE---... 8 8q&$7777:%%dSj3&''' y( mDI&&'''''((r%c||D] }|||jr||jdSdSrC)rrE)rrFparts r&rrsT  d  y dir%)rhtmlrDctjd|rtdttD]\}}||ks||krt|=|t|<dS)atRegister a namespace prefix. The registry is global, and any existing mapping for either the given prefix or the namespace URI will be removed. *prefix* is the namespace prefix, *uri* is a namespace uri. Tags and attributes in this namespace will be serialized with prefix if possible. ValueError is raised if prefix is reserved or is invalid. zns\d+$z'Prefix format reserved for internal useN)rematchrrrr)rrrrs r&rrsy x 6""DBCCC^))++,,""1 88qF{{q! N3r%rr8rdfwsdlxsxsidc)$http://www.w3.org/XML/1998/namespacezhttp://www.w3.org/1999/xhtmlz+http://www.w3.org/1999/02/22-rdf-syntax-ns#z http://schemas.xmlsoap.org/wsdl/z http://www.w3.org/2001/XMLSchemaz)http://www.w3.org/2001/XMLSchema-instancez http://purl.org/dc/elements/1.1/cRtd|dt|jd)Nzcannot serialize z (type ))r/rhr rs r&rrs1 )+/44d1D1D1DE   r%c d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw)N&&r<r>replacer/rrrs r&rrs ) $;;<<W--D $;;<<V,,D $;;<<V,,D ~ &)))"4(((((()AA A65A6c d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}d |vr|d d }d |vr|d d }d |vr|d d}|S#ttf$rt|YdSwxYw)NrErFrrGrrHr" z rz  z rIrs r&rrs ) $;;<<W--D $;;<<V,,D $;;<<V,,D 4<<<<h//D 4<<<<g..D 4<<<<g..D 4<<<<g..D ~ &)))"4(((((()sB7B:: CCc d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw)NrErFrrHrrMrIrs r&r3r3+s ) $;;<<W--D $;;<<V,,D 4<<<<h//D ~ &)))"4(((((()rKT)rrrc|dkrtjntj}t||||||||S)a Generate string representation of XML element. All subelements are included. If encoding is "unicode", a string is returned. Otherwise a bytestring is returned. *element* is an Element instance, *encoding* is an optional output encoding defaulting to US-ASCII, *method* is an optional output which can be one of "xml" (default), "html", "text" or "c14n", *default_namespace* sets the default XML namespace (for "xmlns"). Returns an (optionally) encoded string containing the XML data. rrrrr)rStringIOBytesIOrrgetvalue)r*rrrrrstreams r&rr:sm ')33R[]]]Fvx/>1B&,4H JJJ ??  r%c0eZdZdZdZdZdZdZdZdS)_ListDataStreamz7An auxiliary stream accumulating into a list reference.c||_dSrC)lst)r3rZs r&r5z_ListDataStream.__init__Ts r%cdSrr$r8s r&rz_ListDataStream.writableWtr%cdSrr$r8s r&rz_ListDataStream.seekableZr\r%c:|j|dSrC)rZr^)r3bs r&rz_ListDataStream.write]s r%c*t|jSrC)rHrZr8s r&rz_ListDataStream.tell`s48}}r%N) r r!r"r#r5rrrrr$r%r&rXrXRseAAr%rXcxg}t|}t||||||||S)NrR)rXrr)r*rrrrrrZrVs r&rrcsU C S ! !Fvx/>1B&,4H JJJ Jr%c t|tst|}|tjd|j}|r |ddkr!tjddSdS)a#Write element tree or element structure to sys.stdout. This function should be used for debugging only. *elem* is either an ElementTree, or a single Element. The exact output format is implementation dependent. In this version, it's written as an ordinary XML file. r)rrN)r-rrsysstdoutrrE)rFrEs r&rrps dK ( (!4  JJszIJ... <<>> D 48t## $#r% ct|tr|}|dkrtd|t |sdSd|zzgfd|ddS)a&Indent an XML document by inserting newlines and indentation space after elements. *tree* is the ElementTree or Element to modify. The (root) element itself will not be changed, but the tail text of all elements in its subtree will be adapted. *space* is the whitespace to insert for each indentation level, two space characters by default. *level* is the initial indentation level. Setting this to a higher value than 0 can be used for indenting subtrees that are more deeply nested inside of a document. rz,Initial indentation level must be >= 0, got Nrc|dz} |}n0#t$r#|z}|YnwxYw|jr|js||_|D]D}t |r |||jr|js||_E|js||_dSdSr ) IndexErrorr^rDstriprHrE)rFlevel child_levelchild_indentationchild_indent_children indentationsspaces r&roz indent.._indent_childrensai  3 ,[ 9   3 3 3 ,U 3e ;     1 2 2 2 2 2 3y *  1 1 *)DI / /E5zz 5   444: /UZ%5%5%7%7 /. z!! -%e,EJJJ - -s *>>)r-rrrrH)treerqrkrorps ` @@r&rrs$ $$||~~ qyyOOOPPP t9955=()L-------,T1r%cNt}||||S)zParse XML document into element tree. *source* is a filename or file object containing XML data, *parser* is an optional parser instance defaulting to XMLParser. Return an ElementTree instance. )rr )rrrrs r&r r s& ==DJJvv Kr%ct||tdstddndfdGfddtjj}|}d |_tj||S) aJIncrementally parse XML document into ElementTree. This class also reports what's going on to the user based on the *events* it is initialized with. The supported events are the strings "start", "end", "start-ns" and "end-ns" (the "ns" events are used to get detailed namespace information). If *events* is omitted, only "end" events are reported. *source* is a filename or file object containing XML data, *events* is a list of events to report back, *parser* is an optional parser instance. Returns an iterator providing (event, elem) pairs. )events_parserrrTFc3K Ed{V|d}|sn|H}Ed{V}|||_r|dSdS#r|wwxYw)NTi@) read_eventsrr_close_and_return_rootrootr)rrrzitr pullparserwrs r&iteratorziterparse..iterators  &%11333333333{{9--%%%  &4466D!--// / / / / / / /B~    |   s B B))Cc<eZdZjZfdZdS)$iterparse..IterParseIteratorc8rdSdSrC)r)r3rrs r&__del__z,iterparse..IterParseIterator.__del__s&    r%N)r r!r"__next__r)rr~rsr&IterParseIteratorrsE8F##,        r%rN) rr)r collectionsabcIteratorrzweakrefref) rrurrr{rr~r|r}s ` @@@@r&r r s"ff===J 66 " "fd##  $KO4    BBG RB Ir%c:eZdZd dddZdZdZdZdZdZdS) rN)rvctj|_|ptt |_|d}|j|j|dS)Nr)end)rdeque _events_queuerrrv _setevents)r3rurvs r&r5zXMLPullParser.__init__s[ ).00A);=="A"A"A >F  2F;;;;;r%c|jtd|rO |j|dS#t$r%}|j|Yd}~dSd}~wwxYwdS)Feed encoded data to parser.Nz!feed() called after end of stream)rvrr SyntaxErrorrr^)r3rexcs r&rzXMLPullParser.feed s < @AA A  / / !!$''''' / / /"))#......... / / /s6 A%A  A%cF|j}d|_|SrC)rvr)r3rzs r&ryz$XMLPullParser._close_and_return_roots!|!!##  r%c.|dS)zFinish feeding data to parser. Unlike XMLParser, does not return the root element. Use read_events() to consume elements from XMLPullParser. N)ryr8s r&rzXMLPullParser.closes ##%%%%%r%c#K|j}|r3|}t|tr||V|1dSdS)zReturn an iterator over currently available (event, elem) pairs. Events are consumed from the internal event queue as they are retrieved from the iterator. N)rpopleftr- Exception)r3ruevents r&rxzXMLPullParser.read_events%se # NN$$E%++        r%cd|jtd|jdS)Nz"flush() called after end of stream)rvrflushr8s r&rzXMLPullParser.flush3s3 < ABB B r%rC) r r!r"r5rryrrxrr$r%r&rrs >r%c|stt}|||}i}|D]}|d}|r|||<||fS)aParse XML document from string constant for its IDs. *text* is a string containing XML data, *parser* is an optional parser instance, defaulting to the standard XMLParser. Returns an (Element, dict) tuple, in which the dict maps element id:s to elements. rr7)rrrrrr|)rDrrridsrFr7s r&rrJs 1+--000 KK <<>>D C  XXd^^  CG 9r%c|stt}|D]}|||S)zParse XML document from sequence of string fragments. *sequence* is a list of other sequence, *parser* is an optional parser instance, defaulting to the standard XMLParser. Returns an Element instance. rr)sequencerrDs r&rrbsR 1+--000 D <<>>r%cXeZdZdZdddddddZdZdZdZd Zd Z d Z dd Z d Z dS)ra8Generic element structure builder. This builder converts a sequence of start, data, and end method calls to a well-formed element structure. You can use this class to build an element structure using a custom XML parser, or a parser for some other XML-like format. *element_factory* is an optional element factory which is called to create new Element instances, as necessary. *comment_factory* is a factory to create comments to be used instead of the standard factory. If *insert_comments* is false (the default), comments will not be inserted into the tree. *pi_factory* is a factory to create processing instructions to be used instead of the standard factory. If *insert_pis* is false (the default), processing instructions will not be inserted into the tree. NF)comment_factory pi_factoryinsert_comments insert_piscg|_g|_d|_d|_d|_|t }||_||_|t}||_ ||_ |t}||_ dSrC) _data_elem_lastr_tailr_comment_factoryrr _pi_factoryrr_factory)r3element_factoryrrrrs r&r5zTreeBuilder.__init__sr      "%O /.  .J%$  "%O' r%c|jS)z;Flush builder buffers and return toplevel document Element.rr8s r&rzTreeBuilder.closes zr%c|jrJ|j:d|j}|jr ||j_n ||j_g|_dSdSNr)rrjoinrrErDr3rDs r&_flushzTreeBuilder._flushs\ : z%wwtz**:+&*DJOO'+DJODJJJ  r%c:|j|dS)zAdd text to current element.N)rr^r3rs r&rzTreeBuilder.datas $r%c||||x|_}|jr!|jd|n|j||_|j|d|_|S)zOpen new element and return it. *tag* is the element name, *attrs* is a dict containing element attributes. rcNr)rrrrr^rr)r3r(attrsrFs r&startzTreeBuilder.starts  MM#u555 T :  JrN ! !$ ' ' ' ' Z DJ $  r%c||j|_d|_|jS)zOClose and return current Element. *tag* is the element name. r)rrpoprrrs r&rzTreeBuilder.ends5 Z^^%%  zr%cD||j|j|S)z`Create a comment using the comment_factory. *text* is the text of the comment. )_handle_singlerrrs r&commentzTreeBuilder.comments) ""  !4#7?? ?r%cF||j|j||S)zCreate a processing instruction using the pi_factory. *target* is the target name of the processing instruction. *text* is the data of the processing instruction, or ''. )rrr)r3rrDs r&pizTreeBuilder.pis* ""  dovt== =r%c||}|rI|||_|jr |jd|d|_|S)Nrcr)rrrr^r)r3factoryreargsrFs r&rzTreeBuilder._handle_singlesYw~   KKMMMDJz , 2%%d+++DJ r%rC) r r!r"r#r5rrrrrrrrr$r%r&rrts&(!%$!&5((((((      "   ???====r%rcbeZdZdZddddZdZdZdZdZd Z d Z d Z d Z d Z dZdZdS)raaElement structure builder for XML source data based on the expat parser. *target* is an optional target object which defaults to an instance of the standard TreeBuilder class, *encoding* is an optional encoding string which if given, overrides the encoding specified in the XML file: http://www.iana.org/assignments/character-sets N)rrc@ ddlm}n3#t$r& ddl}n#t$rtdwxYwYnwxYw||d}|t }|x|_|_|x|_|_ |j |_ i|_ |j |_t|dr |j|_t|dr |j|_t|dr |j|_t|dr |j|_t|d r |j|_t|d r |j|_t|d r |j|_d |_d |_d|_ i|_! d |j"z|_#dS#tH$rYdSwxYw)Nrexpatz7No module named expat; use SimpleXMLTreeBuilder insteadrrrstart_nsend_nsrrrrzExpat %d.%d.%d)% xml.parsersr ImportErrorpyexpat ParserCreaterrrvr_targeterror_error_names_defaultDefaultHandlerExpandr)_startStartElementHandler_endEndElementHandler _start_nsStartNamespaceDeclHandler_end_nsEndNamespaceDeclHandlerrCharacterDataHandlerrCommentHandlerrProcessingInstructionHandler buffer_textordered_attributes_doctypeentity version_infoversionr)r3rrrrs r&r5zXMLParser.__init__s  ) ) ) ) ) ) )    '''''   !M (' ##Hc22 > ]]F%++ dl%++ dlk  &*m# 67 # # 5)-F & 65 ! ! 1'+yF $ 6: & & >/3~F , 68 $ $ :-1\F * 66 " " 6*0+F ' 69 % % 3$*NF ! 64  <28)F /$%!   +e.@@DLLL    DD s. 99399>F FFc|j}|j}|D]}|dkrd|_|||jfd}||_#|dkr|||jfd}||_=|dkr0t|jdr |||j fd}n||fd }||_ s|d kr0t|jd r |||j fd }n||fd }||_ |dkr|||fd}||_ |dkr|||fd}||_td|zdS)Nrrc4|||||fdSrCr$)r( attrib_inrr^rs r&handlerz%XMLParser._setevents..handler1s)FE55i#8#89:::::r%rc2||||fdSrCr$)r(rr^rs r&rz%XMLParser._setevents..handler6s%FE33s88,-----r%zstart-nsrc4|||||fdSrCr$)rrrr^rs r&rz%XMLParser._setevents..handler=s)xx'<'<=>>>>>r%c,|||pd|pdffdSrr$)rrrr^s r&rz%XMLParser._setevents..handlerAs* "ciR'@ABBBBBr%zend-nsrc2||||fdSrCr$)rrr^rs r&rz%XMLParser._setevents..handlerGs%vvf~~677777r%c ||dfdSrCr$)rrr^s r&rz%XMLParser._setevents..handlerKst}-----r%rcP|||j|fdSrC)rr)rDrr^r3s r&rz%XMLParser._setevents..handlerOs-FE4;#6#6t#<#<=>>>>>r%rcR|||j||fdSrC)rr) pi_targetrrr^r3s r&rz%XMLParser._setevents..handlerSs-FE4;>>)T#B#BCDDDDDr%zunknown event %r)rvr^rrrrrr)rrrrrrrr)r3 events_queueevents_to_reportrr^ event_namers r&rzXMLParser._setevents%s$** B* BJW$$,-)2fCCCC3:00x''4;11..8'+|88888/9....18..y(((26????(/%%t##3=f!%EEEE7>33 !3j!@AAAU* B* Br%cbt|}|j|_|j|jf|_|rC)r codelinenooffsetposition)r3rerrs r& _raiseerrorzXMLParser._raiseerrorZs-:|U\1  r%cn |j|}n%#t$r|}d|vrd|z}||j|<YnwxYw|S)Nrr)rKeyError)r3r}names r&_fixnamezXMLParser._fixname`s` $;s#DD $ $ $Dd{{Tz#DK     $  s 22c@|j|pd|pdSr)rrr3rrs r&rzXMLParser._start_nsks"{##FLb#)<<tdt|dD]}||dz||||< |j||S)NrrKr)rrangerHrr)r3r( attr_listfixnamer1is r&rzXMLParser._startqs-gcll  ?1c)nna00 ? ?09!A#wwy|,,--{  f---r%c\|j||SrC)rrrrs r&rzXMLParser._end}s"{t}}S11222r%c|dd}|dkr |jj}n#t$rYdSwxYw ||j|dddS#t$raddlm}|d||jj |jj fz}d|_ |jj |_ |jj |_ |wxYw|dkr|dd d kr g|_dS|j|d kr d|_dS|}|sdS|j|t#|j}|d kr|jd}|d kr|dkr|j\}}} } | r | dd} n|dkr|dkr|j\}}} d} ndSt%|jdr%|j|| | ddn*t%|drt)jdt,d|_dSdSdS)NrrErcrrz'undefined entity %s: line %d, column %d r z RuntimeWarning) r3rDr data_handlerrrnrhrpubidsystems r&rzXMLParser._defaults}bqb S== #{/ !      T[ad455555   ------kk=4;6K133 ![8 ![:   s]]tBQBx;66DMMM ] &}} $ ::< AAA A) B) A63B5A66B Bcp|j} |jd|jddn,#|j$r}||Yd}~nd}~wwxYw|j|dS#|j|wxYw)NFr%)rGetReparseDeferralEnabledSetReparseDeferralEnabledrrr)r3 was_enabledrs r&rzXMLParser.flushsk;;==  ? K 1 1% 8 8 8 K  c5 ) ) ) ){     Q          K 1 1+ > > > > >DK 1 1+ > > > >s/5AB A:A50B5A::BB5)r r!r"r#r5rrrrrrrrrrrr$r%r&rrs"&+++++Z3B3B3Bj   ===000 . . .3334%4%4%l   ***"?????r%r)out from_filec H||tdd}|tjx}}tt |jfi|}|*|||n|t|||| ndS)a3Convert XML to its C14N 2.0 serialised form. If *out* is provided, it must be a file or file-like object that receives the serialised canonical XML output (text, not bytes) through its ``.write()`` method. To write to a file, open it in text mode with encoding "utf-8". If *out* is not provided, this function returns the output as text string. Either *xml_data* (an XML string) or *from_file* (a file path or file-like object) must be provided as input. The configuration options are the same as for the ``C14NWriterTarget``. Nz:Either 'xml_data' or 'from_file' must be provided as inputr)r) rrrSrrrrrr rU)xml_datar!r"optionssiors r&rrsI-UVVV C {KMM!c .syDDGDD E E EF H    i'''' _3<<>>>$6r%z ^\w+:\w+$ceZdZdZdddddddddZefdZdZddZd Z d j fd Z d Z d Z ddZdZdZdZdS)ra Canonicalization writer target for the XMLParser. Serialises parse events to XML C14N 2.0. The *write* function is used for writing out the resulting data stream as text (not bytes). To write to a file, open it in text mode with encoding "utf-8" and pass its ``.write`` method. Configuration options: - *with_comments*: set to true to include comments - *strip_text*: set to true to strip whitespace before and after text content - *rewrite_prefixes*: set to true to replace namespace prefixes by "n{number}" - *qname_aware_tags*: a set of qname aware tag names in which prefixes should be replaced in text content - *qname_aware_attrs*: a set of qname aware attribute names in which prefixes should be replaced in text content - *exclude_attrs*: a set of attribute names that should not be serialised - *exclude_tags*: a set of tag names that should not be serialised FN) with_comments strip_textrewrite_prefixesqname_aware_tagsqname_aware_attrs exclude_attrs exclude_tagscX||_g|_||_||_|rt |nd|_|rt |nd|_||_|rt ||_nd|_|rt |j |_ nd|_ dgg|_ g|_ |s>|j tt|j gi|_dg|_d|_d|_d|_d|_dS)N)rArFr)_writer_with_comments _strip_textr_exclude_attrs _exclude_tags_rewrite_prefixes_qname_aware_tags intersection_find_qname_aware_attrs_declared_ns_stack _ns_stackr^rrr _prefix_map_preserve_space_pending_start _root_seen _root_done_ignored_depth) r3rr(r)r*r+r,r-r.s r&r5zC14NWriterTarget.__init__sE  +%4AKc-000t2>HS...D!1  *%()9%:%:D " "%)D "  0+./@+A+A+ND ( (+/D ( <$ #  @ N ! !$~';';'='=">"> ? ? ? b!!! %w"r%c#:K||D] }|r|Ed{V dSrCr$)r3ns_stack _reversedrps r&_iter_namespacesz!C14NWriterTarget._iter_namespaces7sJ#)H-- & &J &%%%%%%%% & &r%c|dd\}}||jD]\}}||kr d|d|cStd|d|d)NrrrrzPrefix z of QName "" is not declared in scope)splitrDr:r)r3 prefixed_namerrrps r&_resolve_prefix_namez%C14NWriterTarget._resolve_prefix_name<s$**322 ++DN;; * *FCF{{)C))4)))))_6__m___```r%c|4|dddkr|ddddnd|f\}}n|}t}||jD]4\}}||kr||vr|r|d|n|||fcS||5|jrd||jvr|j|}n!dt|jx}|j|<|jd||f|d|||fS|s d|vr|||fS||j D]=\}}||kr2|jd||f|r|d|n|||fcS>|s|||fStd|d ) Nrrrrrrrcz Namespace "rF) rrrDr9addr5r;rHr^r:r)r3rrr( prefixes_seenurs r&_qnamezC14NWriterTarget._qnameCs$ ;38!93C3CuQRRy''Q///"eHCC ..t/FGG & &IAvCxxF-77,2;&((3(((S#EEEE   f % % % %  ! /d&&&)#.1LS9I5J5J1L1LL)#.  #B ' . .V} = = =$$s$$c3. . !r..S= ..t~>> F FIAvCxx'+22C=AAA,2;&((3(((S#EEEE !S= FsFFFGGGr%cL|js|j|dSdSrC)r@rr^rs r&rzC14NWriterTarget.datahs3" $ J  d # # # # # $ $r%rcd||j}|jdd=|jr!|jds|}|j7|jdc}|_|rt |r|nd}|jg||R|dS|r+|jr&|t|dSdSdSNrc) rr2r<rjr=_looks_like_prefix_namerr>r0_escape_cdata_c14n)r3 _join_textrr qname_texts r&rzC14NWriterTarget._flushlsz$*%% JqqqM   D$8$< ::<D  F C/////r%cj"|r fd|D}|h|}i}|/|x}||<||jh|rf|}|rL|D]H} || } t | r/| x}|| <||Ind}nd}jfdt|dD} |r!d|D} | ng} |rlt|D]J\} }|| |vr||vr| ||d}| | \}} }| |r|n| |fK| d}j |r|dkn j d j }|d | |dz| r(|d d | D|d |*|t| ||dd_j gdS)Nc.i|]\}}|jv||Sr$)r3).0rrr3s r& z+C14NWriterTarget._start..s,TTTdaq@S7S7SQ7S7S7Sr%c(i|]}||Sr$r$)r\r parse_qnames r&r]z+C14NWriterTarget._start..s/444qKKNN444r%c.|ddS)Nrr)rG)rs r&rz)C14NWriterTarget._start..s!''#q//r%rc*g|]\}}|rd|znd|fS)zxmlns:xmlnsr$)r\rrs r& z+C14NWriterTarget._start..s@C'-9F""'3?r%rz+{http://www.w3.org/XML/1998/namespace}spacepreservercrrc@g|]\}}d|dt|dS)rrr)_escape_attrib_c14n)r\rrs r&rcz+C14NWriterTarget._start..s9TTT$!Q=q==$7$:$:===TTTr%rT)r3rrJrLr8rSrOrsortr^r|r<r0rrTr>r:)r3r(rrYrVrresolved_namesrqattrs attr_namer parsed_qnamesrrr attr_qnamerspace_behaviourrr_s` @r&rzC14NWriterTarget._starts6   *u *TTTTekkmmTTTE  !151J1J:1V1V VEN:. JJu     ' 3 311%88F !'**I!),E.u55*8<8Q8QRW8X8XXu 5 5))) * Fk 4444F 11535353444   #1I NN    I  Hu{{}}-- H H1%!v++!~:M:M%nQ&78;A-:1-=* Is  "B**A!FGGGG ))$QRR ##-< *Oz ) )%b) + + +   cM#&q))***  W E"''TT)TTTUU V V V c   ! E$]>*3M%Nq%QRR S S S b!!!!!r%c|jr|xjdzc_dS|jr||d||dd|jt|jdk|_|j |j dS)Nrrrr) r@rrr0rOr<rrHr?r9r:rs r&rzC14NWriterTarget.ends      1 $   F :  KKMMM /S))!,///000   """d233q8 ##%%% r%c0|jsdS|jrdS|jr|dn"|jr|jr||dt|d|js|ddSdS)Nrz)r1r@r?r0r>rrrTrs r&rzC14NWriterTarget.comments"  F    F ?  KK     _   KKMMM 8-d33888999  KK       r%c4|jrdS|jr|dn"|jr|jr|||rd|dt |dnd|d|js|ddSdS)Nrz)r@r?r0r>rrrT)r3rrs r&rzC14NWriterTarget.pis    F ?  KK     _   KKMMM :> S 6 6 6,T22 6 6 6 6OOOO U U U  KK       r%rC)r r!r"r#r5reversedrDrJrOrrrrrrrrrr$r%r&rrs, %"&$#$# # # # # J4<&&&& aaa#H#H#H#HJ$$$!# 2 2 2 2111000"C"C"C"C"J           r%rc& d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw) NrErFrrGrrHrN rIrs r&rTrTs) $;;<<W--D $;;<<V,,D $;;<<V,,D 4<<<<g..D ~ &)))"4(((((()sA)A,, BBc d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}d |vr|d d }d |vr|d d }|S#ttf$rt|YdSwxYw) NrErFrrGrrMrOz rz rNrsrIrs r&rfrfs) $;;<<W--D $;;<<V,,D $;;<<X..D 4<<<<g..D 4<<<<g..D 4<<<<g..D ~ &)))"4(((((()sBB CC)r)_set_factoriesrCr)rfr)@r#__all__rrdr:r=rrcollections.abcrrrrrr r rrrrr rrcontextmanagerrrrr4r2rrrrrrrr3rrrXrrrr r rrrrrrrrcompileUNICODEr;rSrrTrfrg _elementtreerurr$r%r&r|s'!!P   (             ### jjjjjjjjZ $&$     +"+"+"+"+"+"+"+"`_/_/_/_/_/_/_/_/H /+/+/+b;;;;z0(0(0(d 0(0(0(d    !!!*-2$*38(.(,16(,  %3!   ))) )))8 ) ) )!T"&0b'" !%&*     &////l    5555p77777777t",     $vvvvvvvvth?h?h?h?h?h?h?h?Z7tt77777<%"*\2:>>DD)))&))). 3K++++++N7122222   DD s E77F?F__pycache__/ElementPath.cpython-311.opt-2.pyc000064400000041521151027357230014634 0ustar00 !A?h6ddlZejdZddZdZdZdZdZdZd Z d Z d Z d Z eee e e e d Z iZGddZddZddZddZddZdS)Nz`('[^']*'|\"[^\"]*\"|::|//?|\.\.|\(\)|!=|[/.*:\[\]\(\)@=])|((?:\{[^}]+\})?[^/\[\]\(\)@!=\s]+)|\s+c#K|r|dnd}d}t|D]}|\}}|r|ddkrsd|vrW|dd\}} |st|d||d|fVn6#t$rt d|zdwxYw|r|s |d|d|fVn|Vd}|V|d k}dS) NFr{:}z!prefix %r not found in prefix map@)getxpath_tokenizer_refindallsplitKeyError SyntaxError) pattern namespacesdefault_namespaceparsing_attributetokenttypetagprefixuris ./usr/lib64/python3.11/xml/etree/ElementPath.pyxpath_tokenizerrJsY.8B r***d#++G44-- s  -3q6S==czz!iiQ// ^%'&%Z-?-?-?!EEEEEE^^^%&IF&RSSY]]^" +< e):):):CC@@@@@@ %  KKK %  %--s +BB%cv|j}|/ix|_}|jD] }|D]}|||< |SN) parent_maprootiter)contextrpes rget_parent_mapr#bs_#J*,,Z""$$ " "A " " ! 1  " c:|dddkp |dddkS)N{*}}*rs r_is_wildcard_tagr,ls' rr7e  /s233x4//r$cttcdkrfd}ndkrfd}ndddkr<ddtt dddfd}nPd dd kr0dd tdtfd }nt d |S)Nz{*}*c3@K|D]}|jr|VdSrr+)r resultelem _isinstance_strs rselectz_prepare_tag..selectvs@  ;tx..JJJ  r$z{}*c3\K|D]%}|j}|r|ddkr|V&dS)Nrrr+)r r/r0el_tagr1r2s rr3z_prepare_tag..select|sS  ;vt,,c1A1AJJJ  r$r&r'c3hK|D]+}|j}|ks|r|kr|V,dSrr+) r r/r0r5r1r2no_nssuffixrs rr3z_prepare_tag..selectsY  S==KK$=$==&-SYBYBYJJJ  r$r(r)c3\K|D]%}|j}|r|kr|V&dSrr+)r r/r0r5r1r2nsns_onlys rr3z_prepare_tag..selectsS  ;vt,,B1F1FJJJ  r$zinternal parser error, got ) isinstancestrslicelen RuntimeError)rr3r1r2r8r<r=r9s` @@@@@@r _prepare_tagrCpsi"CK f}}                RaRE  QRRs6{{lD))!""g           RSST   "Xc"gg&&          >>>??? Mr$c|dtrtfd}ndddkr ddfd}|S)Nrc4d}|||S)Nc3$K|D] }|Ed{V dSrr*)r/r0s r select_childz3prepare_child..select..select_childs2"$$D#OOOOOOOO$$r$r*r r/rG select_tags rr3zprepare_child..selects0 $ $ $:g||F';';<< K|D]}|D]}|jkr|VdSrr+r r/r0r"rs rr3zprepare_child..selectsI    Au||   r$)r,rCnextrr3rIrs @@r prepare_childrOs (C !#&&  = = = = = = rr7d??abb'C     Mr$c d}|S)Nc3$K|D] }|Ed{V dSrr*)r r/r0s rr3zprepare_star..selects2  DOOOOOOOO  r$r*rNrr3s r prepare_starrSs Mr$c d}|S)Nc3K|Ed{VdSrr*)r r/s rr3zprepare_self..selects$r$r*rRs r prepare_selfrVs Mr$c$ |}n#t$rYdSwxYw|ddkrdn |ds |dntdtrtfd}ndddkr ddfd}|S) Nr*rzinvalid descendantc4d}|||S)Nc3RK|D]!}|D] }||ur|V "dSrr)r/r0r"s rrGz8prepare_descendant..select..select_childsN"$$D!YY[[$$D=="#GGG$$$r$r*rHs rr3z"prepare_descendant..selects0 $ $ $ :g||F';';<< .selectsQ  3  A}}   r$) StopIterationrr,rCrMs @@rprepare_descendantr^s  Qx3 1X0Ah./// !#&&  = = = = = = rr7d??abb'C     Ms  c d}|S)Nc3hKt|}i}|D]}||vr||}||vr d||<|VdSr)r#)r r/r result_mapr0parents rr3zprepare_parent..selectse#G,,   ! !Dz!!#D)++)-Jv& LLL  ! !r$r*rRs rprepare_parentrcs ! ! ! Mr$c g}g} |}n#t$rYdSwxYw|ddkrnl|dkr2|dr$|ddddvrd|dddf}||dpd||dd |}|d kr|dfd }|S|d ks|d kr$|d|d  fd} fd}d|vr|n|S|dkr*tjd|ds|dfd}|S|dks-|dks'|dks|dkrLtjd|ds1|d|d r  fd} fd}n fd} fd}d|vr|n|S|dks |dks|dkr|dkr.t |ddz dkrt dnp|ddkrt d|dkrM t |d dz n#t$rt d!wxYwd"krt d#ndfd$}|St d%)&Nrr])rrz'"'r:-rz@-c3HK|D]}||VdSrr )r r/r0keys rr3z!prepare_predicate..selects:  88C==,JJJ  r$z@-='z@-!='c3PK|D]}|kr|V dSrri)r r/r0rjvalues rr3z!prepare_predicate..selects?  88C==E))JJJ  r$c3XK|D]#}|x} |kr|V$dSrri)r r/r0 attr_valuerjrls rselect_negatedz)prepare_predicate..select_negatedsI  "&((3--/J<uATATJJJ  r$z!=z\-?\d+$c3HK|D]}||VdSr)find)r r/r0rs rr3z!prepare_predicate..selects:  99S>>-JJJ  r$z.='z.!='z-='z-!='c3K|D]K}|D]3}d|kr|Vn4LdSNr)r joinitertextr r/r0r"rrls rr3z!prepare_predicate..selectsn"""D!\\#..""771::<<00E99"&JJJ!E:""r$c3K|D]K}|D]3}d|kr|Vn4LdSrs)iterfindrtrurvs rroz)prepare_predicate..select_negated"sn"""D!]]3//""771::<<00E99"&JJJ!E:""r$c3tK|D]1}d|kr|V2dSrsrtrur r/r0rls rr3z!prepare_predicate..select)I"##Dwwt}}//588" ##r$c3tK|D]1}d|kr|V2dSrsrzr{s rroz)prepare_predicate..select_negated-r|r$z-()z-()-zXPath position >= 1 expectedlastzunsupported functionr6zunsupported expressionr(z)XPath offset from last() must be negativec3Kt|}|D]W} ||}t||j}||ur|VA#tt f$rYTwxYwdSr)r#listr r IndexErrorr)r r/rr0rbelemsindexs rr3z!prepare_predicate..selectEs'00J  '-F !9!9::EU|t++" "H-D  s=AA*)A*zinvalid predicate)r]appendrtrematchintr ValueError) rNr signature predicater3rorrjrrls @@@@rprepare_predicatersII # DFFEE    FF  8s??  H    8 (a! --q!B$'EqS)))q""" # ""IDl      Fi722l"             "&!2!2~~>CYq\ B Bl      EY&00 %  9#6#6HZ166$7l"   # " " " " " "  " " " " " " " # # # # # # # # # #"&!2!2~~>C9--f1D1D    ! %%)Eqyy!"@AAA|v%%!"8999F""@ ! --1EE!@@@%&>???@2::%&QRRR      ) * **s  $$6HH))rrX.z..z//[ceZdZdZdZdS)_SelectorContextNc||_dSr)r)selfrs r__init__z_SelectorContext.__init__`s  r$)__name__ __module__ __qualname__rrr*r$rrr^s(Jr$rcZ|dddkr|dz}|f}|r1|tt|z } t|}n.#t$r t tdkrt|dddkrtdtt||j } |}n#t$rYYdSwxYwg} | t|d||n#t$rtddwxYw |}|ddkr |}n#t$rYnwxYw|t|<YnwxYw|g}t|}|D]} | ||}|S) Nr:/rXdrz#cannot use absolute path on elementrz invalid path)tuplesorteditems_cacherrAclearrrr__next__r]ropsr) r0pathr cache_keyselectorrNrr/r r3s rrxrxhs  BCCyCczI7U6*"2"2"4"455666 %)$ %%% v;;   LLNNN 8s??CDD DOD*5566? DFFEE    FFF   <E!H dE : :;;;;  < < <!.11t; < 8s?? DFFE      %y-%0VFt$$G))(( Mss AA;F C! F! C0+F/C00F7/D'&F'EF E'&F' E41F3E44FFc@tt|||dSr)rNrxr0rrs rrqrqs tZ00$ 7 77r$c>tt|||Sr)rrxrs rr r s tZ00 1 11r$c tt|||}|jdS|jS#t$r|cYSwxYwrs)rNrxtextr])r0rdefaultrs rfindtextrsYHT44455 9 2y s%00 ??r)NN)rcompiler rr#r,rCrOrSrVr^rcrrrrrxrqr rr*r$rrstv RZ    ----0000&&&R&  >   n+n+n+b        ''''X8888 2222 r$__pycache__/__init__.cpython-311.pyc000064400000000230151027357230013215 0ustar00 !A?hEdS)Nr+/usr/lib64/python3.11/xml/etree/__init__.pyrsr__pycache__/ElementTree.cpython-311.opt-2.pyc000064400000213417151027357230014644 0ustar00 !A?h" gdZdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z Gdde Z dZGd d Zifd ZdCd ZdCd ZeZGddZGddZejdZdCdZdZhdZdZdZeeedZdZddddddd d!Zee_d"Z d#Z!d$Z"d%Z#dDddd&d'd(Z$Gd)d*ej%Z&dDddd&d'd+Z'd,Z(dEd.Z)dCd/Z*dDd0Z+Gd1d2Z,dCd3Z-dCd4Z.e-Z/dCd5Z0Gd6d7Z1Gd8d9Z2dCddd:d;Z3ej4dZ8d?Z9d@Z: eZ;ddAl$rYdSwxYw)F)CommentdumpElement ElementTree fromstringfromstringlistindent iselement iterparseparse ParseErrorPIProcessingInstructionQName SubElementtostring tostringlist TreeBuilderVERSIONXMLXMLID XMLParser XMLPullParserregister_namespace canonicalizeC14NWriterTargetz1.3.0N) ElementPathceZdZ dS)r N)__name__ __module__ __qualname__./usr/lib64/python3.11/xml/etree/ElementTree.pyr r ks Dr$r c$ t|dS)Ntag)hasattr)elements r%r r ys< 7E " ""r$ceZdZ dZ dZ dZ dZ ifdZdZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZddZddZddZddZdZddZdZdZdZddZdZ dS)rNc t|tstd|jj||_i|||_g|_dS)Nzattrib must be dict, not ) isinstancedict TypeError __class__r r'attrib _children)selfr'r0extras r%__init__zElement.__init__s\&$'' -) )),-- -))5) r$cJd|jj|jt|fzS)Nz<%s %r at %#x>)r/r r'idr2s r%__repr__zElement.__repr__s!4>#:DHbhh"OOOr$c0 |||SN)r/)r2r'r0s r% makeelementzElement.makeelements ~~c6***r$c` tjdt|S)Nz7elem.copy() is deprecated. Use copy.copy(elem) instead.)warningswarnDeprecationWarning__copy__r7s r%copyz Element.copys3  E    }}r$c||j|j}|j|_|j|_||dd<|Sr:)r;r'r0texttail)r2elems r%r@zElement.__copy__s?$+66I I QQQ r$c*t|jSr:)lenr1r7s r%__len__zElement.__len__s4>"""r$cjtjdtdt|jdkS)NzyThe behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. stacklevelr)r=r> FutureWarningrGr1r7s r%__bool__zElement.__bool__s=  K a     4>""a''r$c|j|Sr:r1r2indexs r% __getitem__zElement.__getitem__s~e$$r$ct|tr|D]}||n||||j|<dSr:)r,slice_assert_is_elementr1)r2rRr)elts r% __setitem__zElement.__setitem__sg eU # # - - -'',,,, -  # #G , , , 'ur$c|j|=dSr:rPrQs r% __delitem__zElement.__delitem__s N5 ! ! !r$cf |||j|dSr:rVr1appendr2 subelements r%r]zElement.appends9   +++ j)))))r$cp |D]1}|||j|2dSr:r\)r2elementsr)s r%extendzElement.extendsO   + +G  # #G , , , N ! !' * * * * + +r$ch |||j||dSr:)rVr1insert)r2rRr_s r%rdzElement.inserts76  +++ eZ00000r$cxt|ts$tdt|jzdS)Nzexpected an Element, not %s)r, _Element_Pyr.typer )r2es r%rVzElement._assert_is_elements@![)) N9DGG tt}||_|Sr:)rrrC)rCr)s r%rrs"gGGL Nr$cf tt}||_|r|jdz|z|_|S)N )rrrC)targetrCr)s r%rrs>+,,GGL 1|c)D0 Nr$cHeZdZ d dZdZdZdZdZdZdZ d Z d Z dS) rNc(|rd|d|}||_dS)N{}rC)r2 text_or_urir's r%r4zQName.__init__s*  8 8&1kk337K r$c|jSr:rr7s r%__str__z QName.__str__s yr$c2d|jjd|jdS)N)r/r rCr7s r%r8zQName.__repr__s  N333TYYY??r$c*t|jSr:)hashrCr7s r%__hash__zQName.__hash__sDIr$cbt|tr|j|jkS|j|kSr:r,rrCr2others r%__le__z QName.__le__0 eU # # +9 * *yE!!r$cbt|tr|j|jkS|j|kSr:rrs r%__lt__z QName.__lt__0 eU # # *9uz) )y5  r$cbt|tr|j|jkS|j|kSr:rrs r%__ge__z QName.__ge__rr$cbt|tr|j|jkS|j|kSr:rrs r%__gt__z QName.__gt__rr$cbt|tr|j|jkS|j|kSr:rrs r%__eq__z QName.__eq__rr$r:) r r!r"r4rr8rrrrrrr#r$r%rrs     @@@"""!!!"""!!!"""""r$rcpeZdZ ddZdZdZddZddZddZddZ dd Z dd Z dd d d Z dZ dS)rNcF||_|r||dSdSr:)_rootr )r2r)files r%r4zElementTree.__init__s3   JJt       r$c |jSr:rr7s r%getrootzElementTree.getroots /zr$c ||_dSr:r)r2r)s r%_setrootzElementTree._setroot#s  r$c d}t|dst|d}d} |Vt}t|dr8|||_|j|r|SS |d}|sn||.||_|j|r|SS#|r|wwxYw)NFreadrbT _parse_wholei)r(openrrrcloserfeed)r2sourceparser close_sourcedatas r%r zElementTree.parse-s  vv&& &$''FL ~"6>22& "(!4!4V!c8 |j|Sr:)rrr2r's r%rzElementTree.iterRs zs###r$c |dddkr$d|z}tjd|ztd|j||SNr/.zThis search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rrJrK)r=r>rMrrlrms r%rlzElementTree.find^sh  8s??:D M-/34!      ztZ000r$c |dddkr$d|z}tjd|ztd|j|||Sr)r=r>rMrrqrrs r%rqzElementTree.findtexttsl  8s??:D M-/34!      z""4*===r$c |dddkr$d|z}tjd|ztd|j||Sr)r=r>rMrrurms r%ruzElementTree.findallsj  8s??:D M-/34!      z!!$ 333r$c |dddkr$d|z}tjd|ztd|j||Sr)r=r>rMrrwrms r%rwzElementTree.iterfindsj  8s??:D M-/34!      z""4444r$Tshort_empty_elementsc |sd}n|tvrtd|z|s |dkrd}nd}t||5\}}|dkrA|s0|=|dkr%|dvr|d|d |d krt ||jn:t |j|\} } t|} | ||j| | | ddddS#1swxYwYdS) Nxmlzunknown method %rc14nutf-8us-asciiunicode)rrz rCr) _serialize ValueError _get_writerlower_serialize_textr _namespaces) r2file_or_filenameencodingxml_declarationdefault_namespacemethodrwritedeclared_encodingqnamesro serializes r%rzElementTree.writes  . ;FF : % %069:: : &"% )8 4 4 E8R@QO$,^^%%22&,,..6KKK%%%()))tz2222%0=N%O%O" &v.  %VZ/CEEEE E E E E E E E E E E E E E E E E E EsB!C--C14C1c0||dS)Nr)r)r)r2rs r% write_c14nzElementTree.write_c14nszz$vz...r$rr:)NNNN)r r!r"r4rrr rrlrqrurwrrr#r$r%rrs   ####J $ $ $ $1111,>>>>,4444,5555." $ 3E $( 3E3E3E3E3Ej/////r$rc#xK |j}|dkr|t|ddpdfVdStj5}t |t jr|}nt |t jr/t j |}| |j nLt j}d|_ ||_ |j |_ |j|_n#t$rYnwxYwt j||dd}| |j |j|fVddddS#1swxYwYdS#t$rV|dkrd}t#|d|d 5}|j|fVdddYdS#1swxYwYYdSwxYw) NrrrcdSNTr#r#r$r%z_get_writer..sDr$xmlcharrefreplace )rerrorsnewlinew)rr)rrgetattr contextlib ExitStackr,ioBufferedIOBase RawIOBaseBufferedWritercallbackdetachwritableseekabletellAttributeError TextIOWrapperr)rrrstackrs r%rrs-+ & >>  y ( (!1:tDDOO O O O O O%'' +5.0ABB+DD 0",??,-=>>DNN4;////,..D$0LDM!&DJ)9(A $4$9 )'19/B04666 t{+++j(****9 + + + + + + + + + + + + + + + + + + ''' >>  y ( (H "C(,... '15*h& & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'smEB E C21E 2 C?<E >C??AE  EE7F9 F* F9*F. .F91F. 2F98F9cddiird<fd}|D])}|j}t|tr|jvr||jnHt|t r|vr ||n#|!|t ur|turt|| D]^\}}t|tr|j}|vr ||t|tr|jvr||j_|j}t|tr|jvr||j+fS)Nc |dddkr|dddd\}}|}|9t|}|dtz}|dkr||<|r |d||<dS||<dSrt d||<dS#t $rt |YdSwxYw)Nrrrzns%dr:z.add_qname/s .RaRyC 9++C33S#,,>+//44F~!'#j//!9*0 3(/5vvss$;F5MMM$'F5MMM$$3!&u  . . . &u - - - - - - .sB B/B/B//C  C ) rr'r,rrCrrr rr) rErrr'r|r~rCrors ` @@r%rr$sD\FJ+(* $%.......8 !!h c5 ! ! ,xv%% #(### S ! ! ,&   # _G!3!32 &s + + +**,, & &JC#u%% h&   #%'' &EJf,D,D %*%%%y dE " " !ty'>'> Idi : r$c |j}|j}|tur|d|zn|tur|d|zn||}|5|r|t ||D]}t |||d|na|d|zt |} | s|r|rPt|dD]+\} } | rd| z} |d| d t| d ,| D]k\} } t| tr| j} t| tr|| j} nt| } |d || d | d l|st|s|sP|d |r|t ||D]}t |||d||d |zd zn |d|j r|t |j dSdS)N rrc|dSNrr#xs r%rz _serialize_xml..w QqTr$r|r xmlns=""rr)r'rCrr _escape_cdata_serialize_xmllistrsorted_escape_attribr,rrGrD) rrErrorkwargsr'rCrhrvks r%rras (C 9D g~~ kD !!!! % % % hoSk ; +mD))*** J Jua4HJJJJJ J E#)   &&E 9  9 &z'7'7'9'9+9>!;!;!;1( #aAAA*1----"99DAq!!U++#F!!U++."16N*1--EE&)))QQQ78888 s4yy (< c /E---...NNA"5!VT8LNNNNNdSj3&''''e  y( mDI&&'''''((r$>brhrcolimgwbrareabaselinkmetaembedframeinputparamtrackrisindexbasefontc j|j}|j}|tur|dt|zn|tur|dt|zn||}|3|r|t||D]}t |||dnu|d|zt |}|s|r|rPt|dD]+\} } | rd| z} |d| dt| d ,|D]k\} } t| tr| j} t| tr|| j} nt| } |d || d| d l|d | } |r0| d ks| d kr ||n|t||D]}t |||d| tvr|d|zd z|jr|t|jdSdS)Nr r rc|dSr r#r s r%rz!_serialize_html..rr$rrrrrrrscriptstyler)r'rCrrr_serialize_htmlrrrrr,r_escape_attrib_htmlr HTML_EMPTYrD) rrErrorr'rCrhrrrltags r%r1r1s (C 9D g~~ kM$///0000 % % % ht,,,----Sk ; +mD))*** 8 8q&$7777 8 E#)   &&E 9  9 &z'7'7'9'9+9>!;!;!;1( #aAAA*1----"99DAq!!U++#F!!U++3"16N/22EE&)))QQQ78888 E#JJJ99;;D /8##twE$KKKKE---... 8 8q&$7777:%%dSj3&''' y( mDI&&'''''((r$c||D] }|||jr||jdSdSr:)rrD)rrEparts r%rrsT  d  y dir$)rhtmlrCc tjd|rtdttD]\}}||ks||krt|=|t|<dS)Nzns\d+$z'Prefix format reserved for internal use)rematchrrrr)rrrrs r%rrs~  x 6""DBCCC^))++,,""1 88qF{{q! N3r$rr7rdfwsdlxsxsidc)$http://www.w3.org/XML/1998/namespacezhttp://www.w3.org/1999/xhtmlz+http://www.w3.org/1999/02/22-rdf-syntax-ns#z http://schemas.xmlsoap.org/wsdl/z http://www.w3.org/2001/XMLSchemaz)http://www.w3.org/2001/XMLSchema-instancez http://purl.org/dc/elements/1.1/cRtd|dt|jd)Nzcannot serialize z (type ))r.rgr rs r%rrs1 )+/44d1D1D1DE   r$c d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw)N&&r<r>replacer.rrrs r%rrs ) $;;<<W--D $;;<<V,,D $;;<<V,,D ~ &)))"4(((((()AA A65A6c d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}d |vr|d d }d |vr|d d }d |vr|d d}|S#ttf$rt|YdSwxYw)NrDrErrFrrGr" z rz  z rHrs r%rrs ) $;;<<W--D $;;<<V,,D $;;<<V,,D 4<<<<h//D 4<<<<g..D 4<<<<g..D 4<<<<g..D ~ &)))"4(((((()sB7B:: CCc d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw)NrDrErrGrrLrHrs r%r2r2+s ) $;;<<W--D $;;<<V,,D 4<<<<h//D ~ &)))"4(((((()rJT)rrrc |dkrtjntj}t||||||||S)Nrrrrr)rStringIOBytesIOrrgetvalue)r)rrrrrstreams r%rr:sr ')33R[]]]Fvx/>1B&,4H JJJ ??  r$c.eZdZ dZdZdZdZdZdS)_ListDataStreamc||_dSr:)lst)r2rYs r%r4z_ListDataStream.__init__Ts r$cdSrr#r7s r%rz_ListDataStream.writableWtr$cdSrr#r7s r%rz_ListDataStream.seekableZr[r$c:|j|dSr:)rYr])r2bs r%rz_ListDataStream.write]s r$c*t|jSr:)rGrYr7s r%rz_ListDataStream.tell`s48}}r$N)r r!r"r4rrrrr#r$r%rWrWRsbAr$rWcxg}t|}t||||||||S)NrQ)rWrr)r)rrrrrrYrUs r%rrcsU C S ! !Fvx/>1B&,4H JJJ Jr$c" t|tst|}|tjd|j}|r |ddkr!tjddSdS)Nr)rr)r,rrsysstdoutrrD)rErDs r%rrps dK ( (!4  JJszIJ... <<>> D 48t## $#r$ c t|tr|}|dkrtd|t |sdSd|zzgfd|ddS)Nrz,Initial indentation level must be >= 0, got rc|dz} |}n0#t$r#|z}|YnwxYw|jr|js||_|D]D}t |r |||jr|js||_E|js||_dSdSr ) IndexErrorr]rCstriprGrD)rElevel child_levelchild_indentationchild_indent_children indentationsspaces r%rnz indent.._indent_childrensai  3 ,[ 9   3 3 3 ,U 3e ;     1 2 2 2 2 2 3y *  1 1 *)DI / /E5zz 5   444: /UZ%5%5%7%7 /. z!! -%e,EJJJ - -s *>>)r,rrrrG)treerprjrnros ` @@r%rrs $ $$||~~ qyyOOOPPP t9955=()L-------,T1r$cP t}||||Sr:)rr )rrrqs r%r r s+ ==DJJvv Kr$c t||tdstddndfdGfddtjj}|}d|_tj||S) N)events_parserrrTFc3K Ed{V|d}|sn|H}Ed{V}|||_r|dSdS#r|wwxYw)NTi@) read_eventsrr_close_and_return_rootrootr)rrryitr pullparserwrs r%iteratorziterparse..iterators  &%11333333333{{9--%%%  &4466D!--// / / / / / / /B~    |   s B B))Cc<eZdZjZfdZdS)$iterparse..IterParseIteratorc8rdSdSr:)r)r2rrs r%__del__z,iterparse..IterParseIterator.__del__s&    r$N)r r!r"__next__r)rr}rsr%IterParseIteratorrsE8F##,        r$r) rr(r collectionsabcIteratorryweakrefref) rrtrrrzrr}r{r|s ` @@@@r%r r s  ff===J 66 " "fd##  $KO4    BBG RB Ir$c:eZdZd dddZdZdZdZdZdZdS) rN)ructj|_|ptt |_|d}|j|j|dS)Nr)end)rdeque _events_queuerrru _setevents)r2rtrus r%r4zXMLPullParser.__init__s[ ).00A);=="A"A"A >F  2F;;;;;r$c |jtd|rO |j|dS#t$r%}|j|Yd}~dSd}~wwxYwdS)Nz!feed() called after end of stream)rurr SyntaxErrorrr])r2rexcs r%rzXMLPullParser.feed s* < @AA A  / / !!$''''' / / /"))#......... / / /s7 A&A!!A&cF|j}d|_|Sr:)rur)r2rys r%rxz$XMLPullParser._close_and_return_roots!|!!##  r$c0 |dSr:)rxr7s r%rzXMLPullParser.closes! ##%%%%%r$c#K |j}|r3|}t|tr||V|1dSdSr:)rpopleftr, Exception)r2rtevents r%rwzXMLPullParser.read_events%sj # NN$$E%++        r$cd|jtd|jdS)Nz"flush() called after end of stream)rurflushr7s r%rzXMLPullParser.flush3s3 < ABB B r$r:) r r!r"r4rrxrrwrr#r$r%rrs >r$c |stt}|||}i}|D]}|d}|r|||<||fS)Nrr6)rrrrrr{)rCrrqidsrEr6s r%rrJs 1+--000 KK <<>>D C  XXd^^  CG 9r$c |stt}|D]}|||Srr)sequencerrCs r%rrbsW 1+--000 D <<>>r$cVeZdZ d ddddddZdZdZdZdZd Zd Z d d Z d Z dS)rNF)comment_factory pi_factoryinsert_comments insert_piscg|_g|_d|_d|_d|_|t }||_||_|t}||_ ||_ |t}||_ dSr:) _data_elem_lastr_tailr_comment_factoryrr _pi_factoryrr_factory)r2element_factoryrrrrs r%r4zTreeBuilder.__init__sr      "%O /.  .J%$  "%O' r$c |jSr:rr7s r%rzTreeBuilder.closesIzr$c|jrJ|j:d|j}|jr ||j_n ||j_g|_dSdSNr)rrjoinrrDrCr2rCs r%_flushzTreeBuilder._flushs\ : z%wwtz**:+&*DJOO'+DJODJJJ  r$c< |j|dSr:)rr]r2rs r%rzTreeBuilder.datas!* $r$c ||||x|_}|jr!|jd|n|j||_|j|d|_|S)Nrbr)rrrrr]rr)r2r'attrsrEs r%startzTreeBuilder.starts  MM#u555 T :  JrN ! !$ ' ' ' ' Z DJ $  r$c ||j|_d|_|jSr )rrpoprrrs r%rzTreeBuilder.ends: Z^^%%  zr$cF ||j|j|Sr:)_handle_singlerrrs r%commentzTreeBuilder.comments. ""  !4#7?? ?r$cH ||j|j||Sr:)rrr)r2rrCs r%pizTreeBuilder.pis/ ""  dovt== =r$c||}|rI|||_|jr |jd|d|_|S)Nrbr)rrrr]r)r2factoryrdargsrEs r%rzTreeBuilder._handle_singlesYw~   KKMMMDJz , 2%%d+++DJ r$r:) r r!r"r4rrrrrrrrr#r$r%rrts&(!%$!&5((((((      "   ???====r$rc`eZdZ ddddZdZdZdZdZdZd Z d Z d Z d Z d Z dZdS)rN)rrc@ ddlm}n3#t$r& ddl}n#t$rtdwxYwYnwxYw||d}|t }|x|_|_|x|_|_ |j |_ i|_ |j |_t|dr |j|_t|dr |j|_t|dr |j|_t|dr |j|_t|d r |j|_t|d r |j|_t|d r |j|_d |_d |_d|_ i|_! d |j"z|_#dS#tH$rYdSwxYw)Nrexpatz7No module named expat; use SimpleXMLTreeBuilder insteadrrrstart_nsend_nsrrrrzExpat %d.%d.%d)% xml.parsersr ImportErrorpyexpat ParserCreaterrrur_targeterror_error_names_defaultDefaultHandlerExpandr(_startStartElementHandler_endEndElementHandler _start_nsStartNamespaceDeclHandler_end_nsEndNamespaceDeclHandlerrCharacterDataHandlerrCommentHandlerrProcessingInstructionHandler buffer_textordered_attributes_doctypeentity version_infoversionr)r2rrrrs r%r4zXMLParser.__init__s  ) ) ) ) ) ) )    '''''   !M (' ##Hc22 > ]]F%++ dl%++ dlk  &*m# 67 # # 5)-F & 65 ! ! 1'+yF $ 6: & & >/3~F , 68 $ $ :-1\F * 66 " " 6*0+F ' 69 % % 3$*NF ! 64  <28)F /$%!   +e.@@DLLL    DD s. 99399>F FFc|j}|j}|D]}|dkrd|_|||jfd}||_#|dkr|||jfd}||_=|dkr0t|jdr |||j fd}n||fd }||_ s|d kr0t|jd r |||j fd }n||fd }||_ |dkr|||fd}||_ |dkr|||fd}||_td|zdS)Nrrc4|||||fdSr:r#)r' attrib_inrr]rs r%handlerz%XMLParser._setevents..handler1s)FE55i#8#89:::::r$rc2||||fdSr:r#)r'rr]rs r%rz%XMLParser._setevents..handler6s%FE33s88,-----r$zstart-nsrc4|||||fdSr:r#)rrrr]rs r%rz%XMLParser._setevents..handler=s)xx'<'<=>>>>>r$c,|||pd|pdffdSrr#)rrrr]s r%rz%XMLParser._setevents..handlerAs* "ciR'@ABBBBBr$zend-nsrc2||||fdSr:r#)rrr]rs r%rz%XMLParser._setevents..handlerGs%vvf~~677777r$c ||dfdSr:r#)rrr]s r%rz%XMLParser._setevents..handlerKst}-----r$rcP|||j|fdSr:)rr)rCrr]r2s r%rz%XMLParser._setevents..handlerOs-FE4;#6#6t#<#<=>>>>>r$rcR|||j||fdSr:)rr) pi_targetrrr]r2s r%rz%XMLParser._setevents..handlerSs-FE4;>>)T#B#BCDDDDDr$zunknown event %r)rur]rrrrrr(rrrrrrrr)r2 events_queueevents_to_reportrr] event_namers r%rzXMLParser._setevents%s$** B* BJW$$,-)2fCCCC3:00x''4;11..8'+|88888/9....18..y(((26????(/%%t##3=f!%EEEE7>33 !3j!@AAAU* B* Br$cbt|}|j|_|j|jf|_|r:)r codelinenooffsetposition)r2r~errs r% _raiseerrorzXMLParser._raiseerrorZs-:|U\1  r$cn |j|}n%#t$r|}d|vrd|z}||j|<YnwxYw|S)Nrr)rKeyError)r2r|names r%_fixnamezXMLParser._fixname`s` $;s#DD $ $ $Dd{{Tz#DK     $  s 22c@|j|pd|pdSr)rrr2rrs r%rzXMLParser._start_nsks"{##FLb#)<<tdt|dD]}||dz||||< |j||S)NrrJr)rrangerGrr)r2r' attr_listfixnamer0is r%rzXMLParser._startqs-gcll  ?1c)nna00 ? ?09!A#wwy|,,--{  f---r$c\|j||Sr:)rrrrs r%rzXMLParser._end}s"{t}}S11222r$c|dd}|dkr |jj}n#t$rYdSwxYw ||j|dddS#t$raddlm}|d||jj |jj fz}d|_ |jj |_ |jj |_ |wxYw|dkr|dd d kr g|_dS|j|d kr d|_dS|}|sdS|j|t#|j}|d kr|jd}|d kr|dkr|j\}}} } | r | dd} n|dkr|dkr|j\}}} d} ndSt%|jdr%|j|| | ddn*t%|drt)jdt,d|_dSdSdS)NrrDrbrrz'undefined entity %s: line %d, column %d r z RuntimeWarning) r2rCr data_handlerrrnrgrpubidsystems r%rzXMLParser._defaults}bqb S== #{/ !      T[ad455555   ------kk=4;6K133 ![8 ![:   s]]tBQBx;66DMMM ] &}} $ ::< AAA A* B* A74B6A77B Bcp|j} |jd|jddn,#|j$r}||Yd}~nd}~wwxYw|j|dS#|j|wxYw)NFr$)rGetReparseDeferralEnabledSetReparseDeferralEnabledrrr)r2 was_enabledrs r%rzXMLParser.flushsk;;==  ? K 1 1% 8 8 8 K  c5 ) ) ) ){     Q          K 1 1+ > > > > >DK 1 1+ > > > >s/5AB A:A50B5A::BB5)r r!r"r4rrrrrrrrrrrr#r$r%rrs"&+++++Z3B3B3Bj   ===000 . . .3334%4%4%l   ***"?????r$r)out from_filec J ||tdd}|tjx}}tt |jfi|}|*|||n|t|||| ndS)Nz:Either 'xml_data' or 'from_file' must be provided as inputr)r) rrrRrrrrrr rT)xml_datar r!optionssiors r%rrs I-UVVV C {KMM!c .syDDGDD E E EF H    i'''' _3<<>>>$6r$z ^\w+:\w+$ceZdZ dddddddddZefdZdZddZdZd j fd Z d Z d Z dd Z dZdZdZdS)rFN) with_comments strip_textrewrite_prefixesqname_aware_tagsqname_aware_attrs exclude_attrs exclude_tagscX||_g|_||_||_|rt |nd|_|rt |nd|_||_|rt ||_nd|_|rt |j |_ nd|_ dgg|_ g|_ |s>|j tt|j gi|_dg|_d|_d|_d|_d|_dS)N)r@rFr)_writer_with_comments _strip_textr_exclude_attrs _exclude_tags_rewrite_prefixes_qname_aware_tags intersection_find_qname_aware_attrs_declared_ns_stack _ns_stackr]rrr _prefix_map_preserve_space_pending_start _root_seen _root_done_ignored_depth) r2rr'r(r)r*r+r,r-s r%r4zC14NWriterTarget.__init__sE  +%4AKc-000t2>HS...D!1  *%()9%:%:D " "%)D "  0+./@+A+A+ND ( (+/D ( <$ #  @ N ! !$~';';'='=">"> ? ? ? b!!! %w"r$c#:K||D] }|r|Ed{V dSr:r#)r2ns_stack _reversedros r%_iter_namespacesz!C14NWriterTarget._iter_namespaces7sJ#)H-- & &J &%%%%%%%% & &r$c|dd\}}||jD]\}}||kr d|d|cStd|d|d)NrrrrzPrefix z of QName "" is not declared in scope)splitrCr9r)r2 prefixed_namerrrps r%_resolve_prefix_namez%C14NWriterTarget._resolve_prefix_name<s$**322 ++DN;; * *FCF{{)C))4)))))_6__m___```r$c|4|dddkr|ddddnd|f\}}n|}t}||jD]4\}}||kr||vr|r|d|n|||fcS||5|jrd||jvr|j|}n!dt|jx}|j|<|jd||f|d|||fS|s d|vr|||fS||j D]=\}}||kr2|jd||f|r|d|n|||fcS>|s|||fStd|d ) Nrrrrrrrbz Namespace "rE) rrrCr8addr4r:rGr]r9r)r2rrr' prefixes_seenurs r%_qnamezC14NWriterTarget._qnameCs$ ;38!93C3CuQRRy''Q///"eHCC ..t/FGG & &IAvCxxF-77,2;&((3(((S#EEEE   f % % % %  ! /d&&&)#.1LS9I5J5J1L1LL)#.  #B ' . .V} = = =$$s$$c3. . !r..S= ..t~>> F FIAvCxx'+22C=AAA,2;&((3(((S#EEEE !S= FsFFFGGGr$cL|js|j|dSdSr:)r?rr]rs r%rzC14NWriterTarget.datahs3" $ J  d # # # # # $ $r$rcd||j}|jdd=|jr!|jds|}|j7|jdc}|_|rt |r|nd}|jg||R|dS|r+|jr&|t|dSdSdSNrb) rr1r;rir<_looks_like_prefix_namerr=r/_escape_cdata_c14n)r2 _join_textrr qname_texts r%rzC14NWriterTarget._flushlsz$*%% JqqqM   D$8$< ::<D  F C/////r$cj"|r fd|D}|h|}i}|/|x}||<||jh|rf|}|rL|D]H} || } t | r/| x}|| <||Ind}nd}jfdt|dD} |r!d|D} | ng} |rlt|D]J\} }|| |vr||vr| ||d}| | \}} }| |r|n| |fK| d}j |r|dkn j d j }|d | |dz| r(|d d | D|d |*|t| ||dd_j gdS)Nc.i|]\}}|jv||Sr#)r2).0rrr2s r% z+C14NWriterTarget._start..s,TTTdaq@S7S7SQ7S7S7Sr$c(i|]}||Sr#r#)r[r parse_qnames r%r\z+C14NWriterTarget._start..s/444qKKNN444r$c.|ddS)Nrr)rF)rs r%rz)C14NWriterTarget._start..s!''#q//r$rc*g|]\}}|rd|znd|fS)zxmlns:xmlnsr#)r[rrs r% z+C14NWriterTarget._start..s@C'-9F""'3?r$rz+{http://www.w3.org/XML/1998/namespace}spacepreserverbrrc@g|]\}}d|dt|dS)rrr)_escape_attrib_c14n)r[rrs r%rbz+C14NWriterTarget._start..s9TTT$!Q=q==$7$:$:===TTTr$rT)r2rrIrKr7rRrNrsortr]r{r;r/rrSr=r9)r2r'rrXrUrresolved_namesrqattrs attr_namer~ parsed_qnamesrrr attr_qnamerspace_behaviourrr^s` @r%rzC14NWriterTarget._starts6   *u *TTTTekkmmTTTE  !151J1J:1V1V VEN:. JJu     ' 3 311%88F !'**I!),E.u55*8<8Q8QRW8X8XXu 5 5))) * Fk 4444F 11535353444   #1I NN    I  Hu{{}}-- H H1%!v++!~:M:M%nQ&78;A-:1-=* Is  "B**A!FGGGG ))$QRR ##-< *Oz ) )%b) + + +   cM#&q))***  W E"''TT)TTTUU V V V c   ! E$]>*3M%Nq%QRR S S S b!!!!!r$c|jr|xjdzc_dS|jr||d||dd|jt|jdk|_|j |j dS)Nrrrr) r?rrr/rNr;rrGr>r8r9rs r%rzC14NWriterTarget.ends      1 $   F :  KKMMM /S))!,///000   """d233q8 ##%%% r$c0|jsdS|jrdS|jr|dn"|jr|jr||dt|d|js|ddSdS)Nrz)r0r?r>r/r=rrrSrs r%rzC14NWriterTarget.comments"  F    F ?  KK     _   KKMMM 8-d33888999  KK       r$c4|jrdS|jr|dn"|jr|jr|||rd|dt |dnd|d|js|ddSdS)Nrz)r?r>r/r=rrrS)r2rrs r%rzC14NWriterTarget.pis    F ?  KK     _   KKMMM :> S 6 6 6,T22 6 6 6 6OOOO U U U  KK       r$r:)r r!r"r4reversedrCrIrNrrrrrrrrrr#r$r%rrs, %"&$#$# # # # # J4<&&&& aaa#H#H#H#HJ$$$!# 2 2 2 2111000"C"C"C"C"J           r$rc& d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}|S#ttf$rt|YdSwxYw) NrDrErrFrrGrM rHrs r%rSrSs) $;;<<W--D $;;<<V,,D $;;<<V,,D 4<<<<g..D ~ &)))"4(((((()sA)A,, BBc d|vr|dd}d|vr|dd}d|vr|dd}d|vr|dd}d |vr|d d }d |vr|d d }|S#ttf$rt|YdSwxYw) NrDrErrFrrLrNz rz rMrrrHrs r%reres) $;;<<W--D $;;<<V,,D $;;<<X..D 4<<<<g..D 4<<<<g..D 4<<<<g..D ~ &)))"4(((((()sBB CC)r)_set_factoriesr:r)rer)?__all__rrcr9r=rrcollections.abcrrrrrr r rrrrr rrcontextmanagerrrrr3r1rrrrrrrr2rrrWrrrr r rrrrrrrrcompileUNICODEr:rRrrSrerf _elementtreertrr#r$r%r{s"!P   (             ### jjjjjjjjZ $&$     +"+"+"+"+"+"+"+"`_/_/_/_/_/_/_/_/H /+/+/+b;;;;z0(0(0(d 0(0(0(d    !!!*-2$*38(.(,16(,  %3!   ))) )))8 ) ) )!T"&0b'" !%&*     &////l    5555p77777777t",     $vvvvvvvvth?h?h?h?h?h?h?h?Z7tt77777<%"*\2:>>DD)))&))). 3K++++++N7122222   DD s E66E?>E?__pycache__/__init__.cpython-311.opt-1.pyc000064400000000230151027357230014154 0ustar00 !A?hEdS)Nr+/usr/lib64/python3.11/xml/etree/__init__.pyrsr__pycache__/__init__.cpython-311.opt-2.pyc000064400000000230151027357230014155 0ustar00 !A?hEdS)Nr+/usr/lib64/python3.11/xml/etree/__init__.pyrsr__pycache__/cElementTree.cpython-311.opt-2.pyc000064400000000314151027357230014775 0ustar00 !A?hRddlTdS))*N)xml.etree.ElementTree//usr/lib64/python3.11/xml/etree/cElementTree.pyrs$#####r__pycache__/ElementInclude.cpython-311.opt-2.pyc000064400000011016151027357230015317 0ustar00 !A?hddlZddlmZddlmZdZedzZedzZdZGd d e Z Gd d e Z dd Z ddefdZ dZdS)N) ElementTree)urljoinz!{http://www.w3.org/2001/XInclude}includefallbackceZdZdS)FatalIncludeErrorN__name__ __module__ __qualname__1/usr/lib64/python3.11/xml/etree/ElementInclude.pyr r CDrr ceZdZdS)LimitedRecursiveIncludeErrorNr rrrrrGrrrc4|dkrOt|d5}tj|}dddn #1swxYwYnB|sd}t|d|5}|}dddn #1swxYwY|S)NxmlrbzUTF-8r)encoding)openrparsegetrootread)hrefrrfiledatas rdefault_loaderr!Ws ~~ $   5$T**2244D 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 H $h / / / 499;;D                Ks#'A  AA,B  BBc|d}n|dkrtd|zt|dr|}|t}t ||||t dS)Nrz;expected non-negative depth or None for 'max_depth', got %rr) ValueErrorhasattrrr!_includeset)elemloaderbase_url max_depths rrrtsv QVYbbccctY||~~ ~ T68Y66666rcNd}|t|kr||}|jtkr|d}|rt ||}|dd}|dkr||vrt d|z|dkrt d|z|||||} | t d|d|tj| } t| |||d z || ||j r| j pd |j z| _ | ||<n|d kr}||||d } | t d|d||j r | |j z } |r||d z } | j pd | z| _ n|j pd | z|_ ||=t d |z|jtkrt d|jzt||||||d z }|t|k dSdS)Nrrrrzrecursive include of %sz5maximum xinclude depth reached when including file %sz cannot load z as rtextrz)unknown parse type in xi:include tag (%r)z0xi:fallback tag must be child of xi:include (%r))lentagXINCLUDE_INCLUDEgetrr raddcopyr&removetailr.XINCLUDE_FALLBACK) r(r)r*r+ _parent_hrefsierrnoder.s rr&r&s A c$ii-- G 5$ $ $55==D /x..EE'5))E~~=((+,E,LMMM>>6ORVVXXX!!$'''vdE**<++26$$>yvtY]MJJJ$$T***6;!%bAF :DIQ&vdE155+<+<==<++26$$>6#AFND9!9D!%bD 8DII!%bD 8DIG'?%GU' ' '#BQUJ  Q)] C C C Qg c$ii------r)N)r4r-r urllib.parserXINCLUDEr1r7DEFAULT_MAX_INCLUSION_DEPTH SyntaxErrorr rr!rr&rrrr@sf  .i'z)               #4      :1 7 7 7 766666r__pycache__/ElementInclude.cpython-311.opt-1.pyc000064400000011016151027357230015316 0ustar00 !A?hddlZddlmZddlmZdZedzZedzZdZGd d e Z Gd d e Z dd Z ddefdZ dZdS)N) ElementTree)urljoinz!{http://www.w3.org/2001/XInclude}includefallbackceZdZdS)FatalIncludeErrorN__name__ __module__ __qualname__1/usr/lib64/python3.11/xml/etree/ElementInclude.pyr r CDrr ceZdZdS)LimitedRecursiveIncludeErrorNr rrrrrGrrrc4|dkrOt|d5}tj|}dddn #1swxYwYnB|sd}t|d|5}|}dddn #1swxYwY|S)NxmlrbzUTF-8r)encoding)openrparsegetrootread)hrefrrfiledatas rdefault_loaderr!Ws ~~ $   5$T**2244D 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 H $h / / / 499;;D                Ks#'A  AA,B  BBc|d}n|dkrtd|zt|dr|}|t}t ||||t dS)Nrz;expected non-negative depth or None for 'max_depth', got %rr) ValueErrorhasattrrr!_includeset)elemloaderbase_url max_depths rrrtsv QVYbbccctY||~~ ~ T68Y66666rcNd}|t|kr||}|jtkr|d}|rt ||}|dd}|dkr||vrt d|z|dkrt d|z|||||} | t d|d|tj| } t| |||d z || ||j r| j pd |j z| _ | ||<n|d kr}||||d } | t d|d||j r | |j z } |r||d z } | j pd | z| _ n|j pd | z|_ ||=t d |z|jtkrt d|jzt||||||d z }|t|k dSdS)Nrrrrzrecursive include of %sz5maximum xinclude depth reached when including file %sz cannot load z as rtextrz)unknown parse type in xi:include tag (%r)z0xi:fallback tag must be child of xi:include (%r))lentagXINCLUDE_INCLUDEgetrr raddcopyr&removetailr.XINCLUDE_FALLBACK) r(r)r*r+ _parent_hrefsierrnoder.s rr&r&s A c$ii-- G 5$ $ $55==D /x..EE'5))E~~=((+,E,LMMM>>6ORVVXXX!!$'''vdE**<++26$$>yvtY]MJJJ$$T***6;!%bAF :DIQ&vdE155+<+<==<++26$$>6#AFND9!9D!%bD 8DII!%bD 8DIG'?%GU' ' '#BQUJ  Q)] C C C Qg c$ii------r)N)r4r-r urllib.parserXINCLUDEr1r7DEFAULT_MAX_INCLUSION_DEPTH SyntaxErrorr rr!rr&rrrr@sf  .i'z)               #4      :1 7 7 7 766666r__init__.py000064400000003105151027357230006661 0ustar00# $Id: __init__.py 3375 2008-02-13 08:05:08Z fredrik $ # elementtree package # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2008 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. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See https://www.python.org/psf/license for licensing details.