3 \/@sddlZddlZddlZddlZddlZddlmZddlmZddZ ifddZ ifd d Z ifd d Z d dZ GdddejZGdddejZdddZdS)N)handler) xmlreadercCs&x |jD]\}}|j||}q W|S)N)itemsreplace)sdkeyvaluer (/usr/lib64/python3.6/xml/sax/saxutils.py__dict_replace sr cCs6|jdd}|jdd}|jdd}|r2t||}|S)N&z&>z>._wrappercs t|S)N)getattr)selfname)outr r __getattr__[sz,_gettextwriter.._wrapper.__getattr__N)__name__ __module__ __qualname__ __class__r!r )r r r _wrapperYsr&cSsdS)Nr r r r r ^sz _gettextwriter..cSsdS)NTr r r r r r'csxmlcharrefreplacerT)encodingerrorsnewline write_through)sysstdout isinstanceio TextIOBasecodecs StreamWriterStreamReaderWriter RawIOBasecloseBufferedIOBasewritablewriteseekabletellAttributeError TextIOWrapper)r r)r-r&bufferr )r r _gettextwriterHs.     r?c@seZdZd ddZddZd!dd Zd d Zd d ZddZddZ ddZ ddZ ddZ ddZ ddZddZddZdS)" XMLGeneratorN iso-8859-1FcCsVtjj|t||}|j|_|j|_ig|_|jd|_ g|_ ||_ ||_ d|_ dS)NrF)rContentHandler__init__r?r9_writeflush_flush _ns_contexts_current_context_undeclared_ns_maps _encoding_short_empty_elements_pending_start_element)rr r)Zshort_empty_elementsr r r rDss   zXMLGenerator.__init__cCsJ|drBd|dkr d|dS|j|d}|rB|d|dS|dS)Nrz$http://www.w3.org/XML/1998/namespacezxml:r:)rI)rrprefixr r r _qnames  zXMLGenerator._qnamecCs|jr|jdd|_dS)NrF)rMrE)r endElementr r r _finish_pending_start_elements z*XMLGenerator._finish_pending_start_elementcCs|jd|jdS)Nz$ )rErK)rr r r startDocumentszXMLGenerator.startDocumentcCs |jdS)N)rG)rr r r endDocumentszXMLGenerator.endDocumentcCs0|jj|jj||j|<|jj||fdS)N)rHappendrIrrJ)rrOurir r r startPrefixMappings zXMLGenerator.startPrefixMappingcCs|jd|_|jd=dS)NrrBrB)rHrI)rrOr r r endPrefixMappings zXMLGenerator.endPrefixMappingcCs^|j|jd|x*|jD]\}}|jd|t|fq W|jrPd|_n |jddS)Nrz %s=%sTr)rRrErrrLrM)rrattrsr r r r startElementszXMLGenerator.startElementcCs*|jr|jdd|_n|jd|dS)Nz/>Fz)rMrE)rrr r r rQs zXMLGenerator.endElementcCs|j|jd|j|x8|jD].\}}|rD|jd||fq$|jd|q$Wg|_x0|jD]$\}}|jd|j|t|fqfW|jrd|_n |jddS)Nrz xmlns:%s="%s"z xmlns="%s"z %s=%sTr)rRrErPrJrrrLrM)rrqnamerYrOrVr r r r startElementNSs zXMLGenerator.startElementNScCs0|jr|jdd|_n|jd|j|dS)Nz/>Fz)rMrErP)rrr[r r r endElementNSs zXMLGenerator.endElementNScCs4|r0|jt|ts"t||j}|jt|dS)N)rRr/strrKrEr)rcontentr r r characterss   zXMLGenerator.characterscCs0|r,|jt|ts"t||j}|j|dS)N)rRr/r^rKrE)rr_r r r ignorableWhitespaces   z XMLGenerator.ignorableWhitespacecCs|j|jd||fdS)Nz )rRrE)rtargetrr r r processingInstructionsz"XMLGenerator.processingInstruction)NrAF)F)r"r#r$rDrPrRrSrTrWrXrZrQr\r]r`rarcr r r r r@qs   r@c@seZdZd:ddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9ZdS); XMLFilterBaseNcCstjj|||_dS)N)r XMLReaderrD_parent)rparentr r r rDs zXMLFilterBase.__init__cCs|jj|dS)N) _err_handlererror)r exceptionr r r riszXMLFilterBase.errorcCs|jj|dS)N)rh fatalError)rrjr r r rkszXMLFilterBase.fatalErrorcCs|jj|dS)N)rhwarning)rrjr r r rlszXMLFilterBase.warningcCs|jj|dS)N) _cont_handlersetDocumentLocator)rZlocatorr r r rnsz XMLFilterBase.setDocumentLocatorcCs|jjdS)N)rmrS)rr r r rSszXMLFilterBase.startDocumentcCs|jjdS)N)rmrT)rr r r rTszXMLFilterBase.endDocumentcCs|jj||dS)N)rmrW)rrOrVr r r rWsz XMLFilterBase.startPrefixMappingcCs|jj|dS)N)rmrX)rrOr r r rX szXMLFilterBase.endPrefixMappingcCs|jj||dS)N)rmrZ)rrrYr r r rZ szXMLFilterBase.startElementcCs|jj|dS)N)rmrQ)rrr r r rQszXMLFilterBase.endElementcCs|jj|||dS)N)rmr\)rrr[rYr r r r\szXMLFilterBase.startElementNScCs|jj||dS)N)rmr])rrr[r r r r]szXMLFilterBase.endElementNScCs|jj|dS)N)rmr`)rr_r r r r`szXMLFilterBase.characterscCs|jj|dS)N)rmra)rcharsr r r rasz!XMLFilterBase.ignorableWhitespacecCs|jj||dS)N)rmrc)rrbrr r r rcsz#XMLFilterBase.processingInstructioncCs|jj|dS)N)rm skippedEntity)rrr r r rp!szXMLFilterBase.skippedEntitycCs|jj|||dS)N) _dtd_handler notationDecl)rrpublicIdsystemIdr r r rr&szXMLFilterBase.notationDeclcCs|jj||||dS)N)rqunparsedEntityDecl)rrrsrtZndatar r r ru)sz XMLFilterBase.unparsedEntityDeclcCs|jj||S)N)Z _ent_handler resolveEntity)rrsrtr r r rv.szXMLFilterBase.resolveEntitycCs@|jj||jj||jj||jj||jj|dS)N)rfZsetContentHandlerZsetErrorHandlerZsetEntityResolverZ setDTDHandlerparse)rsourcer r r rw3s     zXMLFilterBase.parsecCs|jj|dS)N)rf setLocale)rZlocaler r r ry:szXMLFilterBase.setLocalecCs |jj|S)N)rf getFeature)rrr r r rz=szXMLFilterBase.getFeaturecCs|jj||dS)N)rf setFeature)rrstater r r r{@szXMLFilterBase.setFeaturecCs |jj|S)N)rf getProperty)rrr r r r}CszXMLFilterBase.getPropertycCs|jj||dS)N)rf setProperty)rrr r r r r~FszXMLFilterBase.setPropertycCs|jS)N)rf)rr r r getParentKszXMLFilterBase.getParentcCs ||_dS)N)rf)rrgr r r setParentNszXMLFilterBase.setParent)N)r"r#r$rDrirkrlrnrSrTrWrXrZrQr\r]r`rarcrprrrurvrwryrzr{r}r~rrr r r r rds8 rdcCs t|trtj|}n^t|drt|}tj}t|jdtrH|j|n |j|t|drtt|jtrt|j |j|j dko|j dkr|j }t jjt jj|}t jj||}t jj|r|j |t|d}n$|j tjj||tjj|j }|j||S)Nreadrrrb)r/r^rZ InputSourcehasattrrZsetCharacterStreamZ setByteStreamrZ setSystemIdZgetCharacterStreamZ getByteStreamZ getSystemIdospathdirnamenormpathjoinisfileopenurllibrwZurljoinZrequestZurlopen)rxbasefZsysidZbaseheadZ sysidfilenamer r r prepare_input_sourceSs*          r)r)rZ urllib.parserZurllib.requestr0r2rrrr rrrr?rCr@rerdrr r r r s     )so