U e5ds0@sdZddlZddlZddlZddlmZdddgZGdddZGd ddZ d d Z Gd dde Z Gd dde Z GdddZ[GdddZGdddZdS)z4Implementation of the DOM Level 3 'LS-Load' feature.N) NodeFilter DOMBuilderDOMEntityResolverDOMInputSourcec@s\eZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZdS)OptionszFeatures object that has variables set for each DOMBuilder feature. The DOMBuilder class uses an instance of this class to pass settings to the ExpatBuilder class. TFN)__name__ __module__ __qualname____doc__ namespacesnamespace_declarations validationexternal_parameter_entitiesexternal_general_entitiesZexternal_dtd_subsetvalidate_if_schemaZvalidatedatatype_normalizationcreate_entity_ref_nodesentitieswhitespace_in_element_contentcdata_sectionscommentscharset_overrides_xml_encodinginfosetsupported_mediatypes_only errorHandlerfilterrr*/usr/lib64/python3.8/xml/dom/xmlbuilder.pyr s( rc@s&eZdZdZdZdZdZdZdZdZ eeee fZ ddZ dd Z d d Z d d ZddZddZddZddZddZddZdgdgdgdgdgdgd gd!gd"gd#gd"d$gd%gd&gd'gd(gd)gd*gd+gd,gd-ggdd!d"d$d(d.d'd+d-g d/gd0gd1gd2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<ZdS)=rNrcCs t|_dSN)r_optionsselfrrr__init__:szDOMBuilder.__init__cCs|jSr"entityResolverr$rrr_get_entityResolver=szDOMBuilder._get_entityResolvercCs ||_dSr"r')r%r(rrr_set_entityResolver?szDOMBuilder._set_entityResolvercCs|jSr"rr$rrr_get_errorHandlerBszDOMBuilder._get_errorHandlercCs ||_dSr"r+)r%rrrr_set_errorHandlerDszDOMBuilder._set_errorHandlercCs|jSr"rr$rrr _get_filterGszDOMBuilder._get_filtercCs ||_dSr"r.)r%rrrr _set_filterIszDOMBuilder._set_filtercCs||rt|rdpd}z|jt||f}Wn(tk rTtjd|fdYqX|D]\}}t|j||qZntj dt |dS)Nrrzunsupported feature: %rzunknown feature: ) supportsFeature _settings _name_xformKeyErrorxmldomNotSupportedErrsetattrr# NotFoundErrrepr)r%namestateZsettingsvaluerrr setFeatureLs   zDOMBuilder.setFeaturecCst|jt|Sr")hasattrr#r3)r%r;rrrr1ZszDOMBuilder.supportsFeaturecCst||rdpdf}||jkS)Nrr)r3r2)r%r;r<keyrrr canSetFeature]szDOMBuilder.canSetFeaturer rr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr)rrrrr rr r)rBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrU)rr)rrrVrWrXcCst|}zt|j|WStk r|dkrp|j}|joj|joj|joj|joj|jph|j ph|j ph|j ph|j YSt jdt|YnXdS)Nrzfeature %s not known)r3getattrr#AttributeErrorrrrrr rrrrr5r6r9r:)r%r;Zxnameoptionsrrr getFeatures0 zDOMBuilder.getFeaturecCs.|jr|jd|}ntd|}||Sr")r( resolveEntityrparse)r%uriinputrrrparseURIszDOMBuilder.parseURIcCsRt|j}|j|_|j|_|j}|dkrF|jrFddl}|j|j}| ||SNr) copyr#rr byteStreamsystemIdurllib.requestrequestZurlopen_parse_bytestream)r%r`r[fpurllibrrrr^s zDOMBuilder.parsecCs||jkrtdtddS)Nznot a legal actionzHaven't written this yet...)_legal_actions ValueErrorNotImplementedError)r%r`ZcnodeactionrrrparseWithContexts zDOMBuilder.parseWithContextcCs ddl}|jj|}||Srb)Zxml.dom.expatbuilderr6Z expatbuilderZ makeBuilderZ parseFile)r%streamr[r5ZbuilderrrrrhszDOMBuilder._parse_bytestream)rr r r(rrZACTION_REPLACEZACTION_APPEND_AS_CHILDRENZACTION_INSERT_AFTERZACTION_INSERT_BEFORErkr&r)r*r,r-r/r0r>r1rAr2r\rar^rorhrrrrr-s  = cCs|ddS)N-_)lowerreplace)r;rrrr3sr3c@s0eZdZdZddZddZddZdd Zd S) r)_openerc Cst}||_||_|||_|||_ddl}ddl }|j |}|\}}} } } } | r| ds| | d} ||| | | | f}|j ||_|S)Nr/)rpublicIdre _get_openeropenrd_guess_media_encodingencoding posixpathZ urllib.parser^ZurlparseendswithdirnameZ urlunparsebaseURI) r%rwresourcer|rjpartsZschemeZnetlocpathZparamsZqueryZfragmentrrrr]s  zDOMEntityResolver.resolveEntitycCs2z|jWStk r,||_|jYSXdSr")rurZ_create_openerr$rrrrxs  zDOMEntityResolver._get_openercCsddl}|jSrb)rfrgZ build_opener)r%rjrrrrsz DOMEntityResolver._create_openercCsF|j}d|krB|D]&}|dr|dddSqdS)Nz Content-Typezcharset==r)rdinfoZgetplist startswithsplitrs)r%rrZparamrrrrzs    z'DOMEntityResolver._guess_media_encodingN)rr r __slots__r]rxrrzrrrrrs c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd S)!rrdcharacterStream stringDatar{rwrercCs.d|_d|_d|_d|_d|_d|_d|_dSr"rr$rrrr&szDOMInputSource.__init__cCs|jSr"rdr$rrr_get_byteStreamszDOMInputSource._get_byteStreamcCs ||_dSr"r)r%rdrrr_set_byteStreamszDOMInputSource._set_byteStreamcCs|jSr"rr$rrr_get_characterStreamsz#DOMInputSource._get_characterStreamcCs ||_dSr"r)r%rrrr_set_characterStreamsz#DOMInputSource._set_characterStreamcCs|jSr"rr$rrr_get_stringDataszDOMInputSource._get_stringDatacCs ||_dSr"r)r%datarrr_set_stringDataszDOMInputSource._set_stringDatacCs|jSr"r{r$rrr _get_encodingszDOMInputSource._get_encodingcCs ||_dSr"r)r%r{rrr _set_encodingszDOMInputSource._set_encodingcCs|jSr"rwr$rrr _get_publicId"szDOMInputSource._get_publicIdcCs ||_dSr"r)r%rwrrr _set_publicId$szDOMInputSource._set_publicIdcCs|jSr"rer$rrr _get_systemId'szDOMInputSource._get_systemIdcCs ||_dSr"r)r%rerrr _set_systemId)szDOMInputSource._set_systemIdcCs|jSr"rr$rrr _get_baseURI,szDOMInputSource._get_baseURIcCs ||_dSr"rr%r_rrr _set_baseURI.szDOMInputSource._set_baseURIN)rr r rr&rrrrrrrrrrrrrrrrrrrs  c@s>eZdZdZdZdZdZdZej Z ddZ dd Z d d Z d S) DOMBuilderFilterzSElement filter which can be used to tailor construction of a DOM instance. rrr r!cCs|jSr") whatToShowr$rrr_get_whatToShowCsz DOMBuilderFilter._get_whatToShowcCs|jSr" FILTER_ACCEPTr%Zelementrrr acceptNodeFszDOMBuilderFilter.acceptNodecCs|jSr"rrrrrstartContainerIszDOMBuilderFilter.startContainerN)rr r r rZ FILTER_REJECTZ FILTER_SKIPZFILTER_INTERRUPTrZSHOW_ALLrrrrrrrrr2s rc@sDeZdZdZdZddZddZddZd d Zd d Z d dZ dS) DocumentLSz=Mixin to create documents that conform to the load/save spec.FcCsdS)NFrr$rrr _get_asyncTszDocumentLS._get_asynccCs|rtjddS)Nz.asynchronous document loading is not supported)r5r6r7)r%flagrrr _set_asyncWszDocumentLS._set_asynccCs tddS)Nz'haven't figured out what this means yetrmr$rrrabort\szDocumentLS.abortcCs tddSNzhaven't written this yetrrrrrloadbszDocumentLS.loadcCs tddSrr)r%rrrrloadXMLeszDocumentLS.loadXMLcCs*|dkr|}n|j|k r"tj|Sr")Z ownerDocumentr5r6ZWrongDocumentErrZtoxml)r%ZsnoderrrsaveXMLhs   zDocumentLS.saveXMLN) rr r r Zasync_rrrrrrrrrrrOsrc@s,eZdZdZdZddZddZddZd S) DOMImplementationLSrrcCsF|dk rtjd||jkr$tS||jkr:tjdtddS)NzschemaType not yet supportedz'asynchronous builders are not supportedzunknown value for mode)r5r6r7MODE_SYNCHRONOUSrMODE_ASYNCHRONOUSrl)r%modeZ schemaTyperrrcreateDOMBuilderts  z$DOMImplementationLS.createDOMBuildercCs tddS)Nz-the writer interface hasn't been written yet!rr$rrrcreateDOMWritersz#DOMImplementationLS.createDOMWritercCstSr")rr$rrrcreateDOMInputSourcesz(DOMImplementationLS.createDOMInputSourceN)rr r rrrrrrrrrrps  r)r rcwarningsZxml.domr5Zxml.dom.NodeFilterr__all__rrr3objectrrrrrrrrrs   %,1!