File "ElementTree.cpython-34.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python34/lib64/python3.4/xml/etree/__pycache__/ElementTree.cpython-34.pyc
File size: 47.14 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit


j f@sdZddddddddd	d
ddd
dddddddddgZdZddlZddlZddlZddlZddlZddlm	Z	Gdd
d
e
ZddZGdddZ
iddZdd dZdd!dZeZGd"d
d
ZGd#ddZejd$d%Zdd&d'Zd(d)Zd*d+d,d-d.d/d0d1d2d3d4d5d6f
ZyeeZWnek
rYnXd7d8Zd9d:Zied;6ed<6ed=6Zd>dZid;d?6d<d@6dAdB6dCdD6dEdF6dGdH6dIdJ6Zee_dKdLZ dMdNZ!dOdPZ"dQdRZ#dddSdTdUdZ$GdVdWdWej%Z&dddSdTdXdZ'dYdZ(ddZd	Z)ddd[dZ*Gd\d]d]Z+Gd^d_d_Z,dd`dZ-ddadZ.e-Z/ddbdZ0GdcddZ1GddddZ2ye
Z3ddel4TWne5k
r|YnXdS)faLightweight 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.

CommentdumpElementElementTree
fromstringfromstringlist	iselement	iterparseparse
ParseErrorPIProcessingInstructionQName
SubElementtostringtostringlistTreeBuilderVERSIONXMLXMLID	XMLParserregister_namespacez1.3.0N)ElementPathc@seZdZdZdS)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__rr:/opt/alt/python34/lib64/python3.4/xml/etree/ElementTree.pyr
gscCs
t|dS)z2Return True if *element* appears to be an Element.tag)hasattr)elementrrrrusc@seZdZdZdZdZdZdZiddZddZ	ddZ
d	d
ZddZd
dZ
ddZddZddZddZddZddZddZddZdd Zdd!d"Zddd#d$Zdd%d&Zdd'd(Zd)d*Zdd+d,Zd-d.Zd/d0Zd1d2Zdd3d4Z dd5d6Z!d7d8Z"dS)9rahAn 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:
        <tag attrib>text<child/>...</tag>tail

    NcKsct|ts+td|jjfn|j}|j|||_||_g|_	dS)Nzattrib must be dict, not %s)

isinstancedict	TypeError	__class__rcopyupdater attrib	_children)selfr r)extrarrr__init__s
		zElement.__init__cCsdt|jt|fS)Nz<Element %s at 0x%x>)reprr id)r+rrr__repr__szElement.__repr__cCs|j||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.

        )r&)r+r r)rrrmakeelements	zElement.makeelementcCsD|j|j|j}|j|_|j|_||dd<|S)zReturn copy of current element.

        This creates a shallow copy. Subelements will be shared with the
        original tree.

        N)r1r r)texttail)r+elemrrrr's
zElement.copycCs
t|jS)N)lenr*)r+rrr__len__szElement.__len__cCs)tjdtddt|jdkS)NzyThe behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
stacklevelr)warningswarn
FutureWarningr5r*)r+rrr__bool__s
zElement.__bool__cCs|j|S)N)r*)r+indexrrr__getitem__szElement.__getitem__cCs||j|<dS)N)r*)r+r=r"rrr__setitem__szElement.__setitem__cCs|j|=dS)N)r*)r+r=rrr__delitem__szElement.__delitem__cCs!|j||jj|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.

        N)_assert_is_elementr*append)r+
subelementrrrrBs
zElement.appendcCs2x|D]}|j|qW|jj|dS)zkAppend subelements from a sequence.

        *elements* is a sequence with zero or more elements.

        N)rAr*extend)r+elementsr"rrrrDs
zElement.extendcCs$|j||jj||dS)z(Insert *subelement* at position *index*.N)rAr*insert)r+r=rCrrrrFs
zElement.insertcCs/t|ts+tdt|jndS)Nzexpected an Element, not %s)r#_Element_Pyr%typer)r+errrrAszElement._assert_is_elementcCs|jj|dS)aRemove 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.

        N)r*remove)r+rCrrrrJs
zElement.removecCstjdtdd|jS)z`(Deprecated) Return all subelements.

        Elements are returned in document order.

        zaThis method will be removed in future versions.  Use 'list(elem)' or iteration over elem instead.r7r8)r9r:DeprecationWarningr*)r+rrrgetchildrens
zElement.getchildrencCstj|||S)aFind 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.

        )rfind)r+path
namespacesrrrrM s	zElement.findcCstj||||S)aFind 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.

        )rfindtext)r+rNdefaultrOrrrrP+szElement.findtextcCstj|||S)aFind 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.

        )rfindall)r+rNrOrrrrR9s	zElement.findallcCstj|||S)a 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.

        )riterfind)r+rNrOrrrrSDs	zElement.iterfindcCs*|jjg|_d|_|_dS)zReset element.

        This function removes all subelements, clears all attributes, and sets
        the text and tail attributes to None.

        N)r)clearr*r2r3)r+rrrrTOs
	z
Element.clearcCs|jj||S)agGet 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.

        )r)get)r+keyrQrrrrUZszElement.getcCs||j|<dS)zSet 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.

        N)r))r+rVvaluerrrsetgszElement.setcCs
|jjS)zGet list of attribute names.

        Names are returned in an arbitrary order, just like an ordinary
        Python dict.  Equivalent to attrib.keys()

        )r)keys)r+rrrrYqszElement.keyscCs
|jjS)zGet element attributes as a sequence.

        The attributes are returned in arbitrary order.  Equivalent to
        attrib.items().

        Return a list of (name, value) tuples.

        )r)items)r+rrrrZzs	z
Element.itemsccsb|dkrd}n|dks0|j|kr8|Vnx#|jD]}|j|DdHqBWdS)aCreate 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.

        *N)r r*iter)r+r rIrrrr\s	zElement.itercCs)tjdtddt|j|S)NzbThis method will be removed in future versions.  Use 'elem.iter()' or 'list(elem.iter())' instead.r7r8)r9r:PendingDeprecationWarninglistr\)r+r rrrgetiterators
zElement.getiteratorccsu|j}t|tr)|dk	r)dS|jr=|jVnx1|D])}|jDdH|jrD|jVqDqDWdS)zCreate text iterator.

        The iterator loops over the element and all subelements in document
        order, returning all inner text.

        N)r r#strr2itertextr3)r+r rIrrrras		
	zElement.itertext)#rrrrr r)r2r3r-r0r1r'r6r<r>r?r@rBrDrFrArJrLrMrPrRrSrTrUrXrYrZr\r_rarrrrrzs@	





		cKs<|j}|j||j||}|j||S)aSubelement 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.

    )r'r(r1rB)parentr r)r,r"rrrrs


cCstt}||_|S)zComment 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.

    )rrr2)r2r"rrrrs		cCs6tt}||_|r2|jd||_n|S)a*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.

     )rrr2)targetr2r"rrrrs

	c@seZdZdZdddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZddZ
dS)r
aQualified 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.

    NcCs&|rd||f}n||_dS)Nz{%s}%s)r2)r+Ztext_or_urir rrrr-szQName.__init__cCs|jS)N)r2)r+rrr__str__sz
QName.__str__cCsd|jfS)Nz
<QName %r>)r2)r+rrrr0szQName.__repr__cCs
t|jS)N)hashr2)r+rrr__hash__szQName.__hash__cCs,t|tr|j|jkS|j|kS)N)r#r
r2)r+otherrrr__le__szQName.__le__cCs,t|tr|j|jkS|j|kS)N)r#r
r2)r+rhrrr__lt__szQName.__lt__cCs,t|tr|j|jkS|j|kS)N)r#r
r2)r+rhrrr__ge__szQName.__ge__cCs,t|tr|j|jkS|j|kS)N)r#r
r2)r+rhrrr__gt__szQName.__gt__cCs,t|tr|j|jkS|j|kS)N)r#r
r2)r+rhrrr__eq__szQName.__eq__cCs,t|tr|j|jkS|j|kS)N)r#r
r2)r+rhrrr__ne__szQName.__ne__)rrrrr-rer0rgrirjrkrlrmrnrrrrr
s
c@seZdZdZddddZddZddZdd	d
ZdddZdd
dZ	dddZ
ddddZdddZdddZ
ddddddddZddZdS)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.

    NcCs#||_|r|j|ndS)N)_rootr	)r+r"filerrrr-*s	zElementTree.__init__cCs|jS)z!Return root element of this tree.)ro)r+rrrgetroot0szElementTree.getrootcCs
||_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!

        N)ro)r+r"rrr_setroot4szElementTree._setrootc
Csd}t|ds-t|d}d}nz|dkrpt}t|drp|j||_|jSnx*|jd}|sPn|j|qsW|j|_|jSWd|r|jnXdS)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!openrrurorsfeedclose)r+sourceparserclose_sourcedatarrrr	>s&		
zElementTree.parsecCs|jj|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).

        )ror\)r+r rrrr\cs
zElementTree.itercCs)tjdtddt|j|S)NzbThis method will be removed in future versions.  Use 'tree.iter()' or 'list(tree.iter())' instead.r7r8)r9r:r]r^r\)r+r rrrr_ps
zElementTree.getiteratorcCsP|dddkr=d|}tjd|tddn|jj||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/.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 %rr7r8)r9r:r;rorM)r+rNrOrrrrMys
zElementTree.findcCsS|dddkr=d|}tjd|tddn|jj|||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.

        Nrr}r~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 %rr7r8)r9r:r;rorP)r+rNrQrOrrrrPs
zElementTree.findtextcCsP|dddkr=d|}tjd|tddn|jj||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.

        Nrr}r~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 %rr7r8)r9r:r;rorR)r+rNrOrrrrRs
zElementTree.findallcCsP|dddkr=d|}tjd|tddn|jj||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.

        Nrr}r~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 %rr7r8)r9r:r;rorS)r+rNrOrrrrSs
zElementTree.iterfindshort_empty_elementsTcCsB|sd}n|tkr.td|n|sR|dkrId}qRd}n|j}t||}|dkr|s|dkr|dkr|}	|dkrddl}
|
j}	n|d	|	fn|d
krt||jn>t|j|\}}t|}
|
||j||d|WdQXdS)
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-asciiNunicoderz$<?xml version='1.0' encoding='%s'?>
r2r)rrr)	
_serialize
ValueErrorlower_get_writerlocalegetpreferredencoding_serialize_textro_namespaces)r+file_or_filenameencodingZxml_declarationdefault_namespacemethodrZ	enc_lowerwriteZdeclared_encodingrqnamesrOZ	serializerrrrs2			
zElementTree.writecCs|j|ddS)Nrr)r)r+rprrr
write_c14nszElementTree.write_c14n)rrrrr-rqrrr	r\r_rMrPrRrSrrrrrrrs"

%
	5ccszy
|j}Wn`tk
ro|dkr;t|d}nt|dd|dd}|
|jVWdQXYnX|dkr|Vntj}t|tjr|}nt|tjrtj	|}|j
|jnUtj}dd|_||_y|j
|_
|j|_Wntk
r6YnXtj|d|dddd	}|j
|j|jVWdQXdS)
NrwrerrorsxmlcharrefreplacecSsdS)NTrrrrr<lambda>4sz_get_writer.<locals>.<lambda>newline
)rAttributeErrorrv
contextlib	ExitStackr#ioBufferedIOBase	RawIOBaseBufferedWritercallbackdetachwritableseekabletell
TextIOWrapper)rrrrpstackrrrrs>

			
	rcsidd6ir&d<nfdd}x`|jD]R}|j}t|tr|jkr||jqn\t|tr|kr||qn1|dk	r|tk	r|tk	rt|nx||j	D]n\}}t|tr|j}n|kr4||nt|tr|jkr||jqqW|j}t|trK|jkrK||jqKqKWfS)Ncs
y|dddkr|ddjdd\}}j|}|dkrtj|}|dkrdt}n|dkr||<qn|rd||f|<q||<nrtdn||<Wntk
rt|YnXdS)Nr{}zns%drz%s:%sz<cannot use non-qualified names with default_namespace option)rsplitrU_namespace_mapr5rr%_raise_serialization_error)Zqnameurir prefix)rrOrrr	add_qnameQs&"

z_namespaces.<locals>.add_qname)
r\r r#r
r2r`rrrrZ)r4rrr rVrWr2r)rrOrrrFs4

	$

	rcKs_|j}|j}|tkr/|d|n
|tkrL|d|n||}|dkr|r{|t|nx|D]}t|||dd|qWn|d|t|j}	|	s|r|r9x\t|jdddD]9\}
}|rd|}n|d	|t	|
fqWnx{t|	D]j\}}
t
|trm|j}nt
|
tr||
j}
nt	|
}
|d
|||
fqFWn|st|s|r2|d|r|t|nx'|D]}t|||dd|qW|d|dn
|d
|j
r[|t|j
ndS)Nz	<!--%s-->z<?%s?>r<rVcSs|dS)Nrr)xrrrrsz _serialize_xml.<locals>.<lambda>:z
 xmlns%s="%s"z %s="%s">z</z />)r r2rr
_escape_cdata_serialize_xmlr^rZsorted_escape_attribr#r
r5r3)rr4rrOrkwargsr r2rIrZvkrrrrsT		





	rZareabaseZbasefontZbrcolZframeZhrZimginputZisindexlinkmetaZparamcKsy|j}|j}|tkr5|dt|n!|tkrX|dt|n||}|dkr|r|t|nx|D]}t|||dqWn|d|t|j}|s|r|r?x\t|jdddD]9\}	}
|
rd|
}
n|d|
t	|	fqWnx{t|D]j\}
}	t
|
trs|
j}
nt
|	tr||	j}	nt|	}	|d	||
|	fqLWn|d
|j
}|r|dks|dkr||q|t|nx!|D]}t|||dqW|tkrV|d
|d
n|jru|t|jndS)Nz	<!--%s-->z<?%s?>rrVcSs|dS)Nrr)rrrrrsz!_serialize_html.<locals>.<lambda>rz
 xmlns%s="%s"z %s="%s"rZscriptZstylez</)r r2rrr_serialize_htmlr^rZrrr#r
_escape_attrib_htmlr
HTML_EMPTYr3)rr4rrOrr r2rIrZrrZltagrrrrsT		





	rcCs>x|jD]}||q
W|jr:||jndS)N)rar3)rr4partrrrrs	rrhtmlr2cCsttjd|r!tdnxBttjD].\}}||ksX||kr4t|=q4q4W|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)rematchrr^rrZ)rrrrrrrrsz$http://www.w3.org/XML/1998/namespacezhttp://www.w3.org/1999/xhtmlZrdfz+http://www.w3.org/1999/02/22-rdf-syntax-ns#Zwsdlz http://schemas.xmlsoap.org/wsdl/Zxsz http://www.w3.org/2001/XMLSchemaZxsiz)http://www.w3.org/2001/XMLSchema-instanceZdcz http://purl.org/dc/elements/1.1/cCs#td|t|jfdS)Nzcannot serialize %r (type %s))r%rHr)r2rrrr srcCsykd|kr$|jdd}nd|krE|jdd}nd|krf|jdd}n|SWn"ttfk
rt|YnXdS)N&z&amp;rz&lt;rz&gt;)replacer%rr)r2rrrr%srcCsyd|kr$|jdd}nd|krE|jdd}nd|krf|jdd}nd|kr|jdd}nd	|kr|jd	d
}n|SWn"ttfk
rt|YnXdS)Nrz&amp;rz&lt;rz&gt;"z&quot;rz&#10;)rr%rr)r2rrrr5srcCsykd|kr$|jdd}nd|krE|jdd}nd|krf|jdd}n|SWn"ttfk
rt|YnXdS)Nrz&amp;rz&gt;rz&quot;)rr%rr)r2rrrrFsrrTcCsP|dkrtjn	tj}t|j||d|d||jS)aGenerate 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".

    Returns an (optionally) encoded string containing the XML data.

    rrr)rStringIOBytesIOrrgetvalue)r"rrrstreamrrrrUs$c@sReZdZdZddZddZddZdd	Zd
dZdS)
_ListDataStreamz7An auxiliary stream accumulating into a list reference.cCs
||_dS)N)lst)r+rrrrr-jsz_ListDataStream.__init__cCsdS)NTr)r+rrrrmsz_ListDataStream.writablecCsdS)NTr)r+rrrrpsz_ListDataStream.seekablecCs|jj|dS)N)rrB)r+brrrrssz_ListDataStream.writecCs
t|jS)N)r5r)r+rrrrvsz_ListDataStream.tellN)	rrrrr-rrrrrrrrrhsrcCs8g}t|}t|j||d|d||S)Nrr)rrr)r"rrrrrrrrrys
cCsqt|tst|}n|jtjdd|jj}|sZ|ddkrmtjjdndS)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.

    rrrrN)r#rrsysstdoutrqr3)r4r3rrrrscCst}|j|||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	)ryrztreerrrr	s		cCsid}t|ds-t|d}d}nyt||||SWn|r]|jnYnXdS)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.

    FrsrtTN)r!rv_IterParseIteratorrx)ryeventsrzr{rrrrs	
c@sUeZdZdddddZddZddZd	d
ZddZdS)

XMLPullParserN_parsercCs\g|_d|_|p'tdt|_|dkrBd}n|jj|j|dS)Nrrdend)zend)
_events_queue_indexrrr
_setevents)r+rrrrrr-s			zXMLPullParser.__init__cCsw|jdkrtdn|rsy|jj|Wqstk
ro}z|jj|WYdd}~XqsXndS)zFeed encoded data to parser.Nz!feed() called after end of stream)rrrwSyntaxErrorrrB)r+r|excrrrrwszXMLPullParser.feedcCs|jj}d|_|S)N)rrx)r+rootrrr_close_and_return_roots	z$XMLPullParser._close_and_return_rootcCs|jdS)zFinish feeding data to parser.

        Unlike XMLParser, does not return the root element. Use
        read_events() to consume elements from XMLPullParser.
        N)r)r+rrrrxszXMLPullParser.closeccs|j}x|j}y||j}d||j<Wntk
rHPYnX|d7}|dt|krg|d|<d|_n	||_t|tr|q|VqWdS)zReturn an iterator over currently available (event, elem) pairs.

        Events are consumed from the internal event queue as they are
        retrieved from the iterator.
        Nrr8r)rr
IndexErrorr5r#	Exception)r+rr=eventrrrread_eventss 		


		zXMLPullParser.read_events)rrrr-rwrrxrrrrrrs

rc@s7eZdZdddZddZddZdS)	rFcCs>td|d||_||_||_d|_|_dS)Nrr)rr_file_close_filerro)r+ryrrzr{rrrr-s		z_IterParseIterator.__init__c	Csyxrx|jjD]}|SW|jjdkr7Pn|jjd}|rb|jj|q|jj|_qW|j|_Wn$|jr|jj	nYnX|jr|jj	nt
dS)Nii@)rrrrsrwrrorrrx
StopIteration)r+rr|rrr__next__s$		z_IterParseIterator.__next__cCs|S)Nr)r+rrr__iter__&sz_IterParseIterator.__iter__N)rrrr-rrrrrrrsrcCs2|stdt}n|j||jS)aParse 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.

    rd)rrrwrx)r2rzrrrr*s
cCs}|stdt}n|j||j}i}x6|jD](}|jd}|rG|||<qGqGW||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.

    rdr/)rrrwrxr\rU)r2rzrZidsr4r/rrrr;s

cCsC|stdt}nx|D]}|j|q"W|jS)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.

    rd)rrrwrx)Zsequencerzr2rrrrSs
	
c@saeZdZdZdddZddZddZd	d
ZddZd
dZ	dS)raGeneric 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.

    NcCsFg|_g|_d|_d|_|dkr9t}n||_dS)N)_data_elem_last_tailr_factory)r+Zelement_factoryrrrr-rs					zTreeBuilder.__init__cCsCt|jdks!td|jdk	s<td|jS)z;Flush builder buffers and return toplevel document Element.rzmissing end tagsNzmissing toplevel element)r5rAssertionErrorr)r+rrrrx{s!zTreeBuilder.closecCs|jr|jdk	rdj|j}|jr`|jjdksQtd||j_q|jjdks~td||j_ng|_ndS)Nrzinternal error (tail)zinternal error (text))rrjoinrr3rr2)r+r2rrr_flushs		zTreeBuilder._flushcCs|jj|dS)zAdd text to current element.N)rrB)r+r|rrrr|szTreeBuilder.datacCs`|j|j|||_}|jrC|jdj|n|jj|d|_|S)zOpen new element and return it.

        *tag* is the element name, *attrs* is a dict containing element
        attributes.

        rrr)rrrrrBr)r+r attrsr4rrrstarts
		zTreeBuilder.startcCsZ|j|jj|_|jj|ksJtd|jj|fd|_|jS)zOClose and return current Element.

        *tag* is the element name.

        z&end tag mismatch (expected %s, got %s)r)rrpoprr rr)r+r rrrrs
	zTreeBuilder.end)
rrrrr-rxrr|rrrrrrres	c@seZdZdZdddddZddZdd	Zd
dZdd
ZddZ	ddZ
ddZeZddZ
ddZdS)raElement structure builder for XML source data based on the expat parser.

    *html* are predefined HTML entities (not supported currently),
    *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

    rNcCsyddlm}WnCtk
rYyddl}Wntk
rTtdYnXYnX|j|d}|dkrt}n||_|_||_|_	|j
|_i|_|j
|_t|dr|j|_nt|dr|j|_nt|dr|j|_nt|dr=|j|_nt|d	r[|j|_nd
|_d
|_d
|_d|_i|_yd|j|_ Wnt!k
rYnXdS)Nr)expatz7No module named expat; use SimpleXMLTreeBuilder insteadrrrr|commentpirzExpat %d.%d.%d)"xml.parsersrImportErrorZpyexpatZParserCreaterrzrrd_targeterror_error_names_defaultZDefaultHandlerExpandr!_startStartElementHandler_endEndElementHandlerr|ZCharacterDataHandlerrZCommentHandlerrZProcessingInstructionHandlerZbuffer_textordered_attributesspecified_attributes_doctypeentityversion_infoversionr)r+rrdrrrzrrrr-sF

						
zXMLParser.__init__cCs|j}|j}x|D]}|dkrad|_d|_|||jdd}||_q|dkr|||jdd}||_q|dkr||dd}||_q|d	kr||d
d}||_	qt
d|qWdS)NrrcSs|||||fdS)Nr)r Z	attrib_inrrBrrrrhandlersz%XMLParser._setevents.<locals>.handlerrcSs||||fdS)Nr)r rrBrrrrrszstart-nscSs&|||pd|pdffdS)Nrr)rrrrBrrrrszend-nscSs||dfdS)Nr)rrrBrrrrszunknown event %r)rrBrrrrrrZStartNamespaceDeclHandlerZEndNamespaceDeclHandlerr)r+Zevents_queueZevents_to_reportrzrBZ
event_namerrrrrs(		
		zXMLParser._seteventscCs7t|}|j|_|j|jf|_|dS)N)r
codelinenooffsetZposition)r+rWerrrrr_raiseerrorszXMLParser._raiseerrorcCsVy|j|}Wn>tk
rQ|}d|kr@d|}n||j|<YnX|S)Nrr)rKeyError)r+rVnamerrr_fixnames

zXMLParser._fixnamecCsv|j}||}i}|rcx?tdt|dD]"}||d||||<q:Wn|jj||S)Nrr8r)rranger5rdr)r+r Z	attr_listZfixnamer)irrrrs	#zXMLParser._startcCs|jj|j|S)N)rdrr)r+r rrrr#szXMLParser._endcCs|dd}|dkry|jj}Wntk
rDdSYnXy||j|ddWqtk
rddlm}|jd||jj	|jj
f}d|_|jj	|_|jj
|_
|YqXn|dkr|ddd	krg|_n|jdk	r|d
kr7d|_dS|j}|sMdS|jj|t|j}|dkr|jd}|dkr|d
kr|j\}}}	}
|	r|	dd}	qn7|dkr|dkr|j\}}}
d}	ndSt|jdr:|jj||	|
ddnO|j|jkr|j||	|
dd|j||	|
ddnd|_qndS)Nrrr)rz'undefined entity %s: line %d, column %dr	z	<!DOCTYPErr8ZPUBLICZSYSTEMdoctyperrrrr)rdr|rrrrrrrzZErrorLineNumberZErrorColumnNumberrr
rrstriprBr5r!r_XMLParser__doctype)r+r2rZdata_handlerrrnrHrpubidsystemrrrr&sZ
	
	"	
	# zXMLParser._defaultcCstjdtdS)z(Deprecated)  Handle doctype declaration

        *name* is the Doctype name, *pubid* is the public identifier,
        and *system* is the system identifier.

        z[This method of XMLParser is deprecated.  Define doctype() method on the TreeBuilder target.N)r9r:rK)r+rrrrrrrZszXMLParser.doctypecCsSy|jj|dWn5|jk
rN}z|j|WYdd}~XnXdS)zFeed encoded data to parser.rN)rzParserr)r+r|rrrrrwjszXMLParser.feedcCsy|jjddWn5|jk
rN}z|j|WYdd}~XnXz0y|jj}Wntk
rvYnX|SWd|`|`|`|`XdS)z;Finish feeding data to parser and return element structure.rrN)	rzr rrrdrxrrr)r+rZ
close_handlerrrrrxqs 
zXMLParser.close)rrrrr-rrrrrrrrrwrxrrrrrs	*!4)r[)6r__all__rrrr9rrrrrr
rrrrrrr
rcontextmanagerrrrrrX	NameErrorrrrrrrrrrrrrrrr	rrrrrrrrrrGZ_elementtreerrrrr<module>"s)	>44=2
2

			E$K