U e5d)@sddlZddlZddlmZmZmZmZddlTddlm Z m Z ej j j ej j jfZGdddej j Z ee ddd ee d d d ee d d d ddZddZddZddZddZGddde ZGddde Zeeddd eed dd eedd d Gd!d"d"eZeed#d$d eZGd%d&d&eZeddZGd'd(d(e Zeed)d*d eed d+d d,d-ZGd.d/d/ZGd0d1d1ee Z Gd2d3d3ee Z!ee!d#d4d Gd5d6d6e!Z"ee"d7d8d ee"d9d:d d;d<Z#d=d>Z$Gd?d@d@e!Z%GdAdBdBe"Z&GdCdDdDeZ'ee'd#dEd GdFdGdGZ(GdHdIdIe(ee Z)GdJdKdKe(e Z*GdLdMdMe(ee Z+GdNdOdOe Z,GdPdQdQeZ-dRdSZ.GdTdUdUe e Z/ee/dVdWd dXdYZ0dZd[Z1d\d]Z2ddd^d_Z3ded`daZ4dfdbdcZ5dS)gN)EMPTY_NAMESPACE EMPTY_PREFIXXMLNS_NAMESPACEdomreg)*)DOMImplementationLS DocumentLSc@seZdZdZdZdZdZdZeZ ddZ d2ddZ d3dd Z d d Z d d ZddZddZddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Z dS)4NodeNcCsdS)NTselfr r '/usr/lib64/python3.8/xml/dom/minidom.py__bool__+sz Node.__bool__cCs|dd|SN) toprettyxml)r encodingr r r toxml.sz Node.toxml  cCsx|dkrt}ntjt|ddd}|jtjkrH||d|||n||d|||dkrh|S| SdS)Nxmlcharrefreplacer)rerrorsnewliner) ioStringIO TextIOWrapperBytesIOnodeTyper DOCUMENT_NODEwritexmlgetvaluedetach)r indentnewlrwriterr r r r1s   zNode.toprettyxmlcCs t|jSN)bool childNodesr r r r hasChildNodesCszNode.hasChildNodescCs|jSr%r'r r r r _get_childNodesFszNode._get_childNodescCs|jr|jdSdSNrr)r r r r _get_firstChildIszNode._get_firstChildcCs|jr|jdSdSNr)r r r r _get_lastChildMszNode._get_lastChildcCs |j|jkr,t|jD]}|||q|S|j|jkrTtjdt |t |f|j dk rj|j ||dkr~| |nz|j |}Wntk rtjYnX|jtkrt||j||||_||_|r|j|d}||_||_nd|_||_ |S)N%s cannot be child of %s)rDOCUMENT_FRAGMENT_NODEtupler' insertBefore_child_node_typesxmldomHierarchyRequestErrrepr parentNode removeChild appendChildindex ValueError NotFoundErr_nodeTypes_with_children_clear_id_cacheinsert nextSiblingpreviousSibling)r newChildrefChildcr=noder r r r4Qs8      zNode.insertBeforecCs|j|jkr*t|jD]}||q|S|j|jkrTtjdt |t |fn|jt krft ||j dk r||j |t||d|_|SNr0)rr2r3r'r<r5r6r7r8r9r@rAr:r; _append_childrC)r rHrGr r r r<qs       zNode.appendChildcCs|j|jkr(|j}|||||S|j|jkrPtjdt |t |f||kr\dS|j dk rr|j |z|j |}Wnt k rtjYnX||j |<||_ d|_ |jtks|jtkrt||j|_|j|_d|_d|_|jr||j_|jr||j_|SrI)rr2rCr;r4r5r6r7r8r9r:r'r=r>r?r@rArD)r rEoldChildrFr=r r r replaceChilds@        zNode.replaceChildcCsz|j|Wntk r.tjYnX|jdk rD|j|j_|jdk rX|j|j_d|_|_|jt krvt |d|_ |Sr%) r'remover>r6r7r?rCrDrr@rAr:r rKr r r r;s      zNode.removeChildcCsg}|jD]}|jtjkr|jsJ|r0|j|d_|jr@|j|j_|q|r|dj|jkr|d}|j|j|_|j|_|jr||j_|q||q |||jtj kr | q ||jdd<dSr-) r'rr TEXT_NODEdatarCrDunlinkappend ELEMENT_NODE normalize)r LchildrHr r r rTs*          zNode.normalizecCst|||jp|Sr%) _clone_node ownerDocument)r deepr r r cloneNodeszNode.cloneNodecCs|jj||Sr%)rXimplementation hasFeaturer featureversionr r r isSupportedszNode.isSupportedcCsdSr%r r r r r _get_localNameszNode._get_localNamecCs||kSr%r r otherr r r isSameNodeszNode.isSameNodecCs||dr|SdSdSr%)r`r r^r r r getInterfaces zNode.getInterfacec Cs0z|j|dWSttfk r*YdSXdSr+) _user_dataAttributeErrorKeyErrorr keyr r r getUserDataszNode.getUserDatacCsnd}z |j}Wntk r,i}||_YnX||krB||d}|dkr^d}|dk rj||=n ||f||<|Sr+)rgrh)r rkrPhandlerolddr r r setUserDatas    zNode.setUserDatacCsDt|dr@t|jD]&\}\}}|dk r||||||qdS)Nrg)hasattrlistrgitemsZhandle)r operationsrcZdstrkrPrmr r r _call_user_data_handlers zNode._call_user_data_handlercCs>d|_|_|jr.|jD] }|qt|_d|_d|_dSr%)r:rXr'rQNodeListrDrC)r rVr r r rQs   z Node.unlinkcCs|Sr%r r r r r __enter__szNode.__enter__cCs |dSr%)rQ)r ZetZevtbr r r __exit__sz Node.__exit__)N)rrN)!__name__ __module__ __qualname__ namespaceURIr:rXrCrDrprefixrrrr(r*r,r/r4r<rLr;rTrZr`rardrfrlrprvrQrxrzr r r r r "s:      r firstChildzFirst child node, or None.)doc lastChildzLast child node, or None. localNamez"Namespace-local name of this node.cCs2|j}|r|d}||_||_||||_dSr-)r'rDrCrRr:)r rHr'Zlastr r r rJs rJcCs$|dk r |jtjkrdS|j}qdSNTF)rr rr:rHr r r _in_document&s  rcCs6|r2|dddddddd}||dS) N&z&z>)replacewrite)r$rPr r r _write_data.srcCsD|jD]8}|jtjkr2|dks(|j|kr2||t|||q|SNr)r'rr rStagNamerR_get_elements_by_tagName_helper)parentnamercrHr r r r5s   rcCsX|jD]L}|jtjkr|dks(|j|krD|dks:|j|krD||t||||q|Sr)r'rr rSrr~rR"_get_elements_by_tagName_ns_helper)rZnsURIrrrHr r r r=s   rc@sJeZdZejZdZdZdZdZ ej ej ej ej ejejejfZddZdS)DocumentFragmentz#document-fragmentNcCs t|_dSr%)rwr'r r r r __init__TszDocumentFragment.__init__)r{r|r}r r2rnodeName nodeValue attributesr:rSrOCDATA_SECTION_NODEENTITY_REFERENCE_NODEPROCESSING_INSTRUCTION_NODE COMMENT_NODE NOTATION_NODEr5rr r r r rFsrc@seZdZdZejZdZdZdZ ej ej fZ e ddfddZddZdd Zd d Zd d ZeeeZZddZddZeeeZZddZddZeeeZddZddZddZdS)Attr)_name_valuer~_prefixr' _localNamerX ownerElementNFcCs2d|_||_||_||_t|_|jtdSr%)rrr~rrwr'rRText)r qNamer~rrr r r rbs z Attr.__init__cCs4z|jWStk r.|jdddYSXdSN:r1r.)rrhrsplitr r r r raoszAttr._get_localNamecCs|jSr%) specifiedr r r r _get_specifieduszAttr._get_specifiedcCs|jSr%)rr r r r _get_namexszAttr._get_namecCs||_|jdk rt|jdSr%)rrrAr valuer r r _set_name{s zAttr._set_namecCs|jSr%)rr r r r _get_valueszAttr._get_valuecCs6||_||jd_|jdk r&t|j||jd_dSr+)rr'rPrrArr r r _set_values    zAttr._set_valuecCs|jSr%)rr r r r _get_prefixszAttr._get_prefixcCsd|j}|dkr&|r&|tkr&tjd||_|dkr<|j}nd||jf}|jrZt|j||_ dS)Nxmlnsz5illegal use of 'xmlns' prefix for the wrong namespacez%s:%s) r~rr6r7 NamespaceErrrrrrAr)r rZnsuriZnewNamer r r _set_prefixs  zAttr._set_prefixcCsv|j}|dk rR|j|j=|j|j|jf=|jrRd|_|jd8_|jj d8_ |j D] }| qX|j dd=dS)NFr1) r_attrsr_attrsNSr~r_is_id_magic_id_nodesrX_magic_id_countr'rQ)r elemrVr r r rQs   z Attr.unlinkcCsf|jr dS|j}|j}|dks&|dkr*dS||}|dkr@dS|jrV||j|jS||jSdSr) rrXr_get_elem_infor~isIdNSrisIdrr rrinfor r r _get_isIds zAttr._get_isIdcCs\|j}|j}|dks|dkr tS||}|dkr6tS|jrL||j|jS||jSdSr%) rXr_no_typerr~getAttributeTypeNSrgetAttributeTyperrr r r _get_schemaTypes zAttr._get_schemaType) r{r|r} __slots__r ATTRIBUTE_NODErrrrrOrr5rrrarrrpropertyrrrrrrrrrrQrrr r r r rXs.   rrz True if this attribute is an ID.z'Namespace-local name of this attribute. schemaTypezSchema type for this attribute.c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ d9ddZ eZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8ZdS): NamedNodeMaprr _ownerElementcCs||_||_||_dSr%r)r attrsZattrsNSrr r r rszNamedNodeMap.__init__cCs t|jSr%)lenrr r r r _get_lengthszNamedNodeMap._get_lengthcCs4z|t|j|WStk r.YdSXdSr%)rrrkeys IndexErrorr r=r r r itemszNamedNodeMap.itemcCs*g}|jD]}||j|jfq|Sr%)rvaluesrRrrr rUrHr r r rsszNamedNodeMap.itemscCs0g}|jD]}||j|jf|jfq|Sr%)rrrRr~rrrr r r itemsNSszNamedNodeMap.itemsNScCs"t|tr||jkS||jkSdSr%) isinstancestrrrrjr r r __contains__s  zNamedNodeMap.__contains__cCs |jSr%)rrr r r r rszNamedNodeMap.keyscCs |jSr%)rrr r r r keysNSszNamedNodeMap.keysNScCs |jSr%)rrr r r r rszNamedNodeMap.valuesNcCs|j||Sr%rget)r rrr r r r szNamedNodeMap.getcCs:|jt|ddkrdSt|t|kt|t|kSdS)Nrr)rgetattridrbr r r _cmpszNamedNodeMap._cmpcCs||dkSr+rrbr r r __eq__szNamedNodeMap.__eq__cCs||dkSr+rrbr r r __ge__szNamedNodeMap.__ge__cCs||dkSr+rrbr r r __gt__szNamedNodeMap.__gt__cCs||dkSr+rrbr r r __le__szNamedNodeMap.__le__cCs||dkSr+rrbr r r __lt__!szNamedNodeMap.__lt__cCs"t|tr|j|S|j|SdSr%)rr3rr)r attname_or_tupler r r __getitem__$s  zNamedNodeMap.__getitem__cCsvt|trRz|j|}Wn0tk rHt|}|jj|_||YnX||_n t|tsdt d|}||dS)Nz%value must be a string or Attr object) rrrrirrrX setNamedItemr TypeError)r attnamerrHr r r __setitem__+s   zNamedNodeMap.__setitem__cCs(z |j|WStk r"YdSXdSr%)rrir rr r r getNamedItem:s zNamedNodeMap.getNamedItemcCs,z|j||fWStk r&YdSXdSr%)rrir r~rr r r getNamedItemNS@szNamedNodeMap.getNamedItemNScCsX||}|dk rJt|j|j|j=|j|j|jf=t|drFd|_ |St j dSNr) rrArrrrr~rrqrr6r7r?r rnr r r removeNamedItemFs    zNamedNodeMap.removeNamedItemcCsZ|||}|dk rLt|j|j|j|jf=|j|j=t|drHd|_ |St j dSr) rrArrr~rrrrqrr6r7r?r r~rrr r r removeNamedItemNSRs    zNamedNodeMap.removeNamedItemNScCstt|ts&tjdt|t|f|j|j}|r@| ||j|j<||j |j |j f<|j |_t|j|SrI)rrr6r7r8r9rrrrQrr~rrrrA)r rHrnr r r r^s   zNamedNodeMap.setNamedItemcCs ||Sr%)rr rHr r r setNamedItemNSkszNamedNodeMap.setNamedItemNScCs||}t|j|dSr%)rArrQ)r rrHr r r __delitem__ns zNamedNodeMap.__delitem__cCs|j|j|jfSr%rr r r r __getstate__sszNamedNodeMap.__getstate__cCs|\|_|_|_dSr%rr stater r r __setstate__vszNamedNodeMap.__setstate__)N) r{r|r}rrrrrsrrrrrr__len__rrrrrrrrrrrrrrrrrr r r r rs:     rZlengthz$Number of nodes in the NamedNodeMap.c@s0eZdZdZddZddZddZdd Zd S) TypeInfo namespacercCs||_||_dSr%r)r rrr r r rszTypeInfo.__init__cCs2|jrd|jj|j|jfSd|jj|jfSdS)Nz<%s %r (from %r)>z<%s %r>)r __class__r{rr r r r __repr__s  zTypeInfo.__repr__cCs|jSr%)rr r r r rszTypeInfo._get_namecCs|jSr%)rr r r r _get_namespaceszTypeInfo._get_namespaceN)r{r|r}rrrrrr r r r rs rc@s eZdZdZejZdZeZ dZ ejej ej ej ejejfZeddfddZddZdd Zd d Zd d ZddZddZddZddZddZddZddZeZddZddZ d d!Z!e!Z"d"d#Z#d$d%Z$d&d'Z%d(d)Z&d*d+Z'd9d-d.Z(d/d0Z)d1d2Z*d3d4Z+d5d6Z,d7d8Z-dS):Element) rXr:rrrr~rr'rrrCrDNrcCsBd|_||_|_||_||_t|_d|_|_d|_ d|_ dSr%) r:rrrr~rwr'rCrDrr)r rr~rrr r r rs  zElement.__init__cCs|jdkri|_i|_dSr%)rrr r r r _ensure_attributess zElement._ensure_attributescCs4z|jWStk r.|jdddYSXdSr)rrhrrr r r r raszElement._get_localNamecCs|jSr%rr r r r _get_tagNameszElement._get_tagNamecCs@|jdk r&t|jD] }|qd|_d|_t|dSr%)rrrrrQrr )r attrr r r rQs   zElement.unlinkcCs8|jdkrdSz|j|jWStk r2YdSXdSr)rrri)r rr r r getAttributes  zElement.getAttributecCs<|jdkrdSz|j||fjWStk r6YdSXdSr)rrrirr r r getAttributeNSs  zElement.getAttributeNScCsV||}|dkr4t|}||_|j|_||n||jkrR||_|jrRt|dSr%)getAttributeNoderrrXsetAttributeNoderrA)r rrrr r r setAttributes   zElement.setAttributecCst|\}}|||}|dkrHt||||}||_|j|_||n4||jkrf||_|jrft||j|kr|||_||_ dSr%) _nssplitgetAttributeNodeNSrrrXr rrArr)r r~ qualifiedNamerr localnamerr r r setAttributeNSs     zElement.setAttributeNScCs|jdkrdS|j|Sr%r)r attrnamer r r r s zElement.getAttributeNodecCs|jdkrdS|j||fSr%)rrrr r r rs zElement.getAttributeNodeNScCs|jd|fkrtjd||j|jd}|dk rD|||j |j |j fd}|dk rt||k rt||t ||||k r|S||k r|SdS)Nzattribute node already owned) rr6r7ZInuseAttributeErrrrrrremoveAttributeNoderr~r_set_attribute_node)r rZold1Zold2r r r r s    zElement.setAttributeNodecCsP|jdkrtjz|j|}Wntk r@tjYnX||dSr%)rr6r7r?rrir)r rrr r r removeAttributes  zElement.removeAttributecCsT|jdkrtjz|j||f}Wntk rDtjYnX||dSr%)rr6r7r?rir)r r~rrr r r removeAttributeNS%s  zElement.removeAttributeNScCs^|dkrtjz|j|jWntk r@tjYnXt|||j|_|Sr%) r6r7r?rrrirArQrXrr r r r.s zElement.removeAttributeNodecCs|jdkrdS||jkSNFrrr r r hasAttribute>s zElement.hasAttributecCs|jdkrdS||f|jkSr)rrr r r hasAttributeNSCs zElement.hasAttributeNScCst||tSr%rrwrr r r getElementsByTagNameHszElement.getElementsByTagNamecCst|||tSr%rrwrr r r getElementsByTagNameNSKs zElement.getElementsByTagNameNScCsd|jt|fS)Nz)rrr r r r rOszElement.__repr__rcCs||d|j|}|D],}|d|t|||j|dq$|jr|dt|jdkr|jdjt j t j fkr|jd |dddn4|||jD]}| |||||q|||d|j|fn|d |dS) Nrz %s="rrr1rrz%sz/>%s) rr_get_attributesrrrr'rrr rOrr)r r$r" addindentr#rZa_namerHr r r rRs*       zElement.writexmlcCs|t|j|j|Sr%)rrrrr r r r r mszElement._get_attributescCs|jr dSdSdSrrr r r r hasAttributesqszElement.hasAttributescCs||}||dSr%)r setIdAttributeNode)r ridAttrr r r setIdAttributeys zElement.setIdAttributecCs|||}||dSr%)rr#)r r~rr$r r r setIdAttributeNS}s zElement.setIdAttributeNScCsj|dks||jstjt|dk r4tj|jsfd|_|jd7_|j j d7_ t |dS)NTr1) rdrr6r7r?_get_containing_entrefNoModificationAllowedErrrrrXrrA)r r$r r r r#s   zElement.setIdAttributeNode)rrr).r{r|r}rr rSrrrrrrrrOrrr5rrrrarrQr r r rr rr ZsetAttributeNodeNSrrrZremoveAttributeNodeNSrrrrrrr r"r%r&r#r r r r rsT     rrz*NamedNodeMap of attributes on the element.z%Namespace-local name of this element.cCs8t||||j|j<||j|j|jf<||_dSr%)rArrrrr~rr)elementrr r r rs  rc@sbeZdZdZdZeZdZdZddZ ddZ ddZ d d Z d d Z d dZddZddZdS) Childlessr NcCsdSr%r r r r r r,szChildless._get_firstChildcCsdSr%r r r r r r/szChildless._get_lastChildcCstj|jddS)Nz nodes cannot have childrenr6r7r8rrr r r r<szChildless.appendChildcCsdSrr r r r r r(szChildless.hasChildNodescCstj|jddSNz nodes do not have childrenr+r rErFr r r r4szChildless.insertBeforecCstj|jddSr,)r6r7r?rrNr r r r;szChildless.removeChildcCsdSr%r r r r r rTszChildless.normalizecCstj|jddSr,r+r rErKr r r rLszChildless.replaceChild)r{r|r}rrZ EmptyNodeListr'rrr,r/r<r(r4r;rTrLr r r r r*sr*c@s\eZdZejZdZddZddZddZ e ee Z dd Z d d Z e e e Zdd dZdS)ProcessingInstructiontargetrPcCs||_||_dSr%r0)r r1rPr r r rszProcessingInstruction.__init__cCs|jSr%rPr r r r _get_nodeValuesz$ProcessingInstruction._get_nodeValuecCs ||_dSr%r2rr r r _set_nodeValuesz$ProcessingInstruction._set_nodeValuecCs|jSr%r1r r r r _get_nodeNamesz#ProcessingInstruction._get_nodeNamecCs ||_dSr%r5rr r r _set_nodeNamesz#ProcessingInstruction._set_nodeNamercCs|d||j|j|fdS)Nz %s%s)rr1rPr r$r"r!r#r r r rszProcessingInstruction.writexmlN)rrr)r{r|r}r rrrrr3r4rrr6r7rrr r r r r/s  r/c@sreZdZdZddZddZeZddZdd Ze eeZ Z d d Z d d Z ddZddZddZddZdS) CharacterData)_datarXr:rDrCcCs,d|_|_d|_|_d|_t|dSr)rXr:rDrCr:r rr r r r rs  zCharacterData.__init__cCs t|jSr%)rrPr r r r rszCharacterData._get_lengthcCs|jSr%r:r r r r _get_dataszCharacterData._get_datacCs ||_dSr%r;r rPr r r _set_dataszCharacterData._set_datacCs6|j}t|dkrd}nd}d|jj|dd|fS)N z...rzr)rPrrr{)r rPZ dotdotdotr r r rs  zCharacterData.__repr__cCsT|dkrtjd|t|jkr.tjd|dkrBtjd|j|||SNroffset cannot be negative#offset cannot be beyond end of datacount cannot be negativer6r7 IndexSizeErrrrPr offsetcountr r r substringDatas   zCharacterData.substringDatacCs|j||_dSr%r2)r argr r r appendDataszCharacterData.appendDatacCsZ|dkrtjd|t|jkr.tjd|rVd|jd|||j|df|_dS)NrrArB%s%s%srD)r rGrJr r r insertData s    zCharacterData.insertDatacCsl|dkrtjd|t|jkr.tjd|dkrBtjd|rh|jd||j||d|_dSr@rDrFr r r deleteDatas   zCharacterData.deleteDatacCsr|dkrtjd|t|jkr.tjd|dkrBtjd|rnd|jd|||j||df|_dS)NrrArBrCrLrD)r rGrHrJr r r replaceDatas    zCharacterData.replaceDataN)r{r|r}rrrrr<r>rrPrrrIrKrMrNrOr r r r r9s    r9zLength of the string data.c@sHeZdZdZejZdZdZddZ dddZ d d Z d d Z d dZ dS)rr z#textNcCs|dks|t|jkr"tjd|}|j|d|_|j|_|j}|jr~||jj kr~|dkrp|j |n|j |||jd||_|S)Nrzillegal offset value) rrPr6r7rErrXrCr:r'r<r4)r rGZnewTextnextr r r splitText1s zText.splitTextrcCst|d||j|fdS)NrL)rrPr8r r r r@sz Text.writexmlcCs|jg}|j}|dk rB|jtjtjfkrB|d|j|j}qqBq|j}|dk rz|jtjtjfkrz||j|j}qHqzqHd |S)Nrr) rPrDrr rOrrBrCrRjoin)r rUrr r r _get_wholeTextEs zText._get_wholeTextcCs|j}|j}|dk r@|jtjtjfkr@|j}|||}q q@q |j}|sT|||dk r|jtjtjfkr|j}|||}qTqqT|r||_|SdSdSr%) r:rDrr rOrr;rCrP)r ZcontentrrrPr r r replaceWholeTextWs*   zText.replaceWholeTextcCsF|jrdSt|}|dkr"dS|j|}|dkr:dS|SdSr)rPstrip_get_containing_elementrXrisElementContent)r rrr r r !_get_isWhitespaceInElementContentss  z&Text._get_isWhitespaceInElementContent)rrr)r{r|r}rr rOrrrrQrrSrTrXr r r r r*s rZisWhitespaceInElementContentzKTrue iff this text node contains only whitespace and is in element content.Z wholeTextz.The text of all logically-adjacent text nodes.cCs*|j}|dk r&|jtjkr|S|j}qdSr%)r:rr rSrHrGr r r rVs  rVcCs*|j}|dk r&|jtjkr|S|j}qdSr%)r:rr rrYr r r r's  r'c@s(eZdZejZdZddZdddZdS) Commentz#commentcCst|||_dSr%)r9rr:r=r r r rs zComment.__init__rcCs,d|jkrtd|d||j|fdS)Nz--z%'--' is not allowed in a comment nodez %s%s)rPr>rr8r r r rs zComment.writexmlN)rrr) r{r|r}r rrrrrr r r r rZsrZc@s$eZdZdZejZdZdddZdS) CDATASectionr z#cdata-sectionrcCs,|jddkrtd|d|jdS)Nz]]>rz$']]>' not allowed in a CDATA sectionz)rPfindr>rr8r r r rszCDATASection.writexmlN)rrr) r{r|r}rr rrrrr r r r r[sr[c@szeZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)ReadOnlySequentialNamedNodeMap_seqr cCs ||_dSr%r^)r seqr r r rsz'ReadOnlySequentialNamedNodeMap.__init__cCs t|jSr%rr_r r r r rsz&ReadOnlySequentialNamedNodeMap.__len__cCs t|jSr%rar r r r rsz*ReadOnlySequentialNamedNodeMap._get_lengthcCs"|jD]}|j|kr|SqdSr%)r_rrr r r rs  z+ReadOnlySequentialNamedNodeMap.getNamedItemcCs,|jD] }|j|kr|j|kr|SqdSr%)r_r~rrr r r rs z-ReadOnlySequentialNamedNodeMap.getNamedItemNScCs4t|tr|j|}n ||}|dkr0t||Sr%)rr3rrri)r Z name_or_tuplerHr r r rs    z*ReadOnlySequentialNamedNodeMap.__getitem__cCs4|dkr dSz |j|WStk r.YdSXdSr+)r_rrr r r rs  z#ReadOnlySequentialNamedNodeMap.itemcCstjddSNz"NamedNodeMap instance is read-onlyr6r7r(rr r r rsz.ReadOnlySequentialNamedNodeMap.removeNamedItemcCstjddSrbrcrr r r rsz0ReadOnlySequentialNamedNodeMap.removeNamedItemNScCstjddSrbrcrr r r rsz+ReadOnlySequentialNamedNodeMap.setNamedItemcCstjddSrbrcrr r r rsz-ReadOnlySequentialNamedNodeMap.setNamedItemNScCs|jgSr%r^r r r r rsz+ReadOnlySequentialNamedNodeMap.__getstate__cCs|d|_dSr+r^rr r r rsz+ReadOnlySequentialNamedNodeMap.__setstate__N)r )r{r|r}rrrrrrrrrrrrrrr r r r r]s  r]z&Number of entries in the NamedNodeMap.c@s(eZdZdZddZddZddZdS) IdentifiedpublicIdsystemIdcCs||_||_dSr%re)r rfrgr r r _identified_mixin_initsz!Identified._identified_mixin_initcCs|jSr%)rfr r r r _get_publicIdszIdentified._get_publicIdcCs|jSr%)rgr r r r _get_systemIdszIdentified._get_systemIdN)r{r|r}rrhrirjr r r r rdsrdc@sHeZdZejZdZdZdZdZ dZ ddZ ddZ ddZ d d d ZdS) DocumentTypeNcCs2t|_t|_|r&t|\}}||_|j|_dSr%)r]entities notationsrrr)r rrrr r r r s  zDocumentType.__init__cCs|jSr%)internalSubsetr r r r _get_internalSubsetsz DocumentType._get_internalSubsetcCs|jdkrtd}|j|_|j|_tjjj}|rg|j_ g|j _ |j j D]2}t |j|j |j }|j j |||||qH|jj D]N}t|j|j |j |j}|j|_|j|_|j|_|jj |||||q|||||SdSdSr%)rXrkrrr6r7UserDataHandler NODE_CLONEDrlr_rmNotationrfrgrRrvEntity notationNameactualEncodingrr_)r rYclonertrnotationeentityr r r rZs0    zDocumentType.cloneNodercCs|d||j|jr8|d||j||jfn|jrR|d||jf|jdk r||d||j|d|d|dS)Nz srsc@seZdZejZdZddZdS)rrNcCs||_|||dSr%)rrh)r rrfrgr r r rjszNotation.__init__)r{r|r}r rrrrr r r r rrfsrrc@sHeZdZddddddddgZd d Zd d Zd dZddZddZdS)DOMImplementation)core1.0)r2.0)rN)r6r)r6r)r6N)ls-loadz3.0)rNcCs|dkr d}||f|jkSr)lower _featuresr]r r r r\zszDOMImplementation.hasFeaturec Cs|r|jdk rtjd|}|dko8|dko8|dk }|sP|rPtjd|rt|\}}|dkr||dkr|tjd|r|stjd|||}|r| || ||r||_|_ ||_ ||_ |S)Nz(doctype object owned by another DOM treezElement with no namer6z$http://www.w3.org/XML/1998/namespacezillegal use of 'xml' prefixz(illegal use of prefix without namespaces) r:r6r7WrongDocumentErr_create_documentZInvalidCharacterErrrrcreateElementNSr<rXdoctyper[) r r~rrrZadd_root_elementrrr)r r r createDocuments>       z DOMImplementation.createDocumentcCst|}||_||_|Sr%)rkrfrg)r rrfrgrr r r createDocumentTypesz$DOMImplementation.createDocumentTypecCs||dr|SdSdSr%)r\rer r r rfs zDOMImplementation.getInterfacecCstSr%)Documentr r r r rsz"DOMImplementation._create_documentN) r{r|r}rr\rrrfrr r r r ros -rc@sXeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ dS) ElementInforcCs ||_dSr%rrr r r rszElementInfo.__init__cCstSr%rr Zanamer r r rszElementInfo.getAttributeTypecCstSr%rrr r r rszElementInfo.getAttributeTypeNScCsdSrr r r r r rWszElementInfo.isElementContentcCsdSrr r r r r isEmptyszElementInfo.isEmptycCsdSrr rr r r rszElementInfo.isIdcCsdSrr rr r r rszElementInfo.isIdNScCs|jSr%rr r r r rszElementInfo.__getstate__cCs ||_dSr%rrr r r rszElementInfo.__setstate__N) r{r|r}rrrrrWrrrrrr r r r rs rcCs>|jtjkr|jd|_nt|r:|jjd|j_dSr%)rr r _id_cacheclear_id_search_stackrrXrr r r rAs    rAc@sreZdZdZejejejejfZ e Z ej Z dZdZdZdZdZZdZdZdZdZdZdZdZdZddZdd Zd d Zd d ZddZ ddZ!ddZ"ddZ#ddZ$ddZ%ddZ&ddZ'ddZ(d d!Z)d"d#Z*d$d%Z+d&d'Z,d(d)Z-d*d+Z.d,d-Z/d.d/Z0d0d1Z1d2d3Z2d4d5Z3d6d7Z4d8d9Z5d:d;Z6dd?Z8d@dAZ9dBdCZ:dIdEdFZ;dGdHZ|j||jtj kr^| r^tjdt ||S)Nr0z two document elements disallowed) rr5r6r7r8r9r:r;r rS_get_documentElementr<rr r r r<3s    zDocument.appendChildcCsVz|j|Wntk r.tjYnXd|_|_d|_|j |krRd|_ |Sr%) r'rMr>r6r7r?rCrDr:documentElementrNr r r r;Cs  zDocument.removeChildcCs$|jD]}|jtjkr|SqdSr%)r'rr rSrr r r rOs  zDocument._get_documentElementcCs(|jdk r|jd|_t|dSr%)rrQr r r r r rQTs  zDocument.unlinkcCs|sdS|jddd}|j|_|j|_|j|_|jD]B}t|||}|j||jt j kr`n|jt j krr||_ ||_ q6|tjjj|||Sr%)r[rrrr_r'rWrRrr rr{rr:rvr6r7rprq)r rYrvrZ childcloner r r rZZs&      zDocument.cloneNodecCst}||_|Sr%)rrX)r ror r r createDocumentFragmentoszDocument.createDocumentFragmentcCst|}||_|Sr%)rrX)r rrxr r r createElementtszDocument.createElementcCs(t|tstdt}||_||_|SNznode contents must be a string)rrrrrPrX)r rPtr r r createTextNodeys  zDocument.createTextNodecCs(t|tstdt}||_||_|Sr)rrrr[rPrXr rPrGr r r createCDATASections  zDocument.createCDATASectioncCst|}||_|Sr%)rZrXrr r r createCommentszDocument.createCommentcCst||}||_|Sr%)r/rX)r r1rPpr r r createProcessingInstructions z$Document.createProcessingInstructioncCst|}||_d|_|Sr)rrXr)r rar r r createAttributeszDocument.createAttributecCs"t|\}}t|||}||_|Sr%)rrrX)r r~rrrrxr r r rs  zDocument.createElementNScCs*t|\}}t||||}||_d|_|Sr)rrrXr)r r~rrrrr r r createAttributeNSs  zDocument.createAttributeNScCst||||}||_|Sr%)rsrX)r rrfrgrtrxr r r _create_entityszDocument._create_entitycCst|||}||_|Sr%)rrrX)r rrfrgrr r r _create_notations zDocument._create_notationcCs||jkr|j|S|js$|js$dS|j}|dkrB|jg}||_n|sJdSd}|r|}|dd|jD||}|rB|j D]}|j r| |j |j r||j|j<|j|kr|}n |jsqq||jr ||j|j<|j|kr|}n|js>qq|jr||j|j<|j|kr.|}q|jdkrqqn>|jr|j D]*}|jrT||j|j<|j|krT|}qT|dk rNqqN|S)NcSsg|]}|jtkr|qSr )rr@).0rVr r r s z+Document.getElementById..r1)rrrrrpopextendr'rrrr~rrrrrrr)r rstackresultrHrrr r r getElementByIdsZ              zDocument.getElementByIdcCst||tSr%rrr r r rszDocument.getElementsByTagNamecCst|||tSr%rrr r r rs zDocument.getElementsByTagNameNScCs|j||Sr%)r[r\r]r r r r`szDocument.isSupportedcCs>|jtjkrtjdn|jtjkr2tjdt|||S)Nzcannot import document nodesz!cannot import document type nodes)rr rr6r7NotSupportedErrr{rW)r rHrYr r r importNodes    zDocument.importNodercCsJ|dkr|d|n|d||f|jD]}|||||q0dS)Nzz%%s)rr'r)r r$r"r!r#rrHr r r rs zDocument.writexmlcCsJ|j|k r tjd||jf|jtjtjfkr>tjd|t krd|kr| dd\}}|dkr|tjj krtj dq|dkr|tjj kr|jtjkrtj dd}|}nd}d}|jtjkr|j }|dk r|j}||nd}||_||_||_||_|jtjkr||_n*||_|dk rF|||rF|||S)Nz?cannot rename nodes from other documents; expected %s, found %sz8renameNode() only applies to element and attribute nodesrr1rzillegal use of 'xmlns' prefixz$illegal use of the 'xmlns' attribute)rXr6r7rrr rSrrrrrrrrrrrr~rrrr r#)r rr~rrrr)Zis_idr r r renameNode sb         zDocument.renameNode)rrrN)=r{r|r}rr rSrrr{r5rr[rrrrrr:rDrCrurrr_rrrrrrr}rrrrrrrr<r;rrQrZrrrrrrrrrrrrrrr`rrrr r r r rsj   : rrz#Top-level element of this document.c Cs|j|rtjjj}n tjjj}|jtj kr| |j |j }|j D]0}||j |j |j||j |j}|j|_qH|r|jD]}t|||}||qn|jtjkr|}|r|jD]}t|||}||qn|jtjkr||j}n|jtjkr||j}n|jtjkr>||j |j}nj|jtj!kr\|"|j}nL|jtj#kr|$|j |j }d|_|j|_n|jtj%krtjjj}|j&'|j(|j)|j*}||_|rg|j+_,g|j-_,|j-j,D]F} t.| j | j)| j*} || _|j-j,/| t0| dr| 1|| | q|j+j,D]b} t2| j | j)| j*| j3} | j4| _4| j5| _5| j6| _6|| _|j+j,/| t0| dr.| 1|| | q.ntj7dt8|t0|dr|1||||S)NTrvzCannot clone node %s)9rXrdr6r7rprqZ NODE_IMPORTEDrr rSrr~rrrrrrrrr'rWr<r2rrOrrPrrrrr1rrrrr{r[rrrfrgrlr_rmrrrRrqrvrsrtrurr_rr9) rHrYZnewOwnerDocumentrtrvrrrVrGrrwrxryr r r rWBs                  rWcCs,|dd}t|dkr|Sd|dfSdS)Nrr1r)rr)rZfieldsr r r rs  rcCs,|||}|\}}||||Sr%)ZgetEventZ expandNoder)funcargskwargsZeventsZtoktypeZrootNoder r r _do_pulldom_parses    rcCsH|dkr"|s"ddlm}||Sddlm}t|j|f||dSdS)Nr expatbuilderpulldom)parserbufsize)xml.domrparserr)filerrrrr r r rs     rcCsB|dkrddlm}||Sddlm}t|j|fd|iSdS)Nrrrr)rr parseStringrr)stringrrrr r r rs    rcCs@|r:t|trt|}|D]\}}tj||sdSqtjSr%)rrrZ_parse_feature_stringrr[r\)Zfeaturesfvr r r getDOMImplementations   r)NN)N)N)6rrr6rrrrZxml.dom.minicompatZxml.dom.xmlbuilderrrr7r rSrr@Z defpropertyrJrrrrrrobjectrZ AttributeListrrrrr*r/r9rrVr'rZr[r]rdrkrsrrrrrArrWrrrrrr r r r sv  y$ x )GU  ><( O*PR