U AT^s0@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_schemavalidatedatatype_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$r4)r&r<rrrr2ZszDOMBuilder.supportsFeaturecCst||rdpdf}||jkS)Nrr)r4r3)r&r<r=keyrrr canSetFeature]szDOMBuilder.canSetFeaturer rr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr)rrrrr rr r)rCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrUrV)rr)rrrWrXrYcCst|}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)r4getattrr$AttributeErrorrrrrr rrrrr6r7r:r;)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.requestrequesturlopen_parse_bytestream)r&rar\fpurllibrrrr_s zDOMBuilder.parsecCs||jkrtdtddS)Nznot a legal actionzHaven't written this yet...)_legal_actions ValueErrorNotImplementedError)r&raZcnodeactionrrrparseWithContexts zDOMBuilder.parseWithContextcCs ddl}|jj|}||Src)Zxml.dom.expatbuilderr7Z expatbuilderZ makeBuilderZ parseFile)r&streamr\r6ZbuilderrrrrjszDOMBuilder._parse_bytestream)rr r r)rrZACTION_REPLACEZACTION_APPEND_AS_CHILDRENZACTION_INSERT_AFTERZACTION_INSERT_BEFORErmr'r*r+r-r.r0r1r?r2rBr3r]rbr_rqrjrrrrr-s  = cCs|ddS)N-_)lowerreplace)r<rrrr4sr4c@s0eZdZdZddZddZddZdd Zd S) r)_openerc Cs|dk s tt}||_||_|||_|||_ddl }ddl }|j |}|\}}} } } } | r| ds|| d} ||| | | | f}|j ||_|S)Nr/)AssertionErrorrpublicIdrf _get_openeropenre_guess_media_encodingencoding posixpath urllib.parser_urlparseendswithdirname urlunparsebaseURI) r&rzrfsourcerrlpartsschemenetlocpathparamsqueryfragmentrrrr^s   zDOMEntityResolver.resolveEntitycCs2z|jWStk r,||_|jYSXdSr#)rwr[_create_openerr%rrrr{s  zDOMEntityResolver._get_openercCsddl}|jSrc)rgrhZ build_opener)r&rlrrrrsz DOMEntityResolver._create_openercCsF|j}d|krB|D]&}|dr|dddSqdS)Nz Content-Typezcharset==r)reinfoZgetplist startswithsplitru)r&rrZparamrrrr}s    z'DOMEntityResolver._guess_media_encodingN)rr r __slots__r^r{rr}rrrrrs c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd S)!rrecharacterStream stringDatar~rzrfrcCs.d|_d|_d|_d|_d|_d|_d|_dSr#rr%rrrr'szDOMInputSource.__init__cCs|jSr#rer%rrr_get_byteStreamszDOMInputSource._get_byteStreamcCs ||_dSr#r)r&rerrr_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#rzr%rrr _get_publicId"szDOMInputSource._get_publicIdcCs ||_dSr#r)r&rzrrr _set_publicId$szDOMInputSource._set_publicIdcCs|jSr#rfr%rrr _get_systemId'szDOMInputSource._get_systemIdcCs ||_dSr#r)r&rfrrr _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. rr r!r"cCs|jSr#) whatToShowr%rrr_get_whatToShowCsz DOMBuilderFilter._get_whatToShowcCs|jSr# FILTER_ACCEPTr&elementrrr 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)r6r7r8)r&flagrrr _set_asyncWszDocumentLS._set_asynccCs tddS)Nz'haven't figured out what this means yetror%rrrabort\szDocumentLS.abortcCs tddSNzhaven't written this yetrrrrrloadbszDocumentLS.loadcCs tddSrr)r&rrrrloadXMLeszDocumentLS.loadXMLcCs*|dkr|}n|j|k r"tj|Sr#)Z ownerDocumentr6r7ZWrongDocumentErrZtoxml)r&ZsnoderrrsaveXMLhs   zDocumentLS.saveXMLN) rr r r Zasync_rrrrrrrrrrrOsrc@s,eZdZdZdZddZddZddZd S) DOMImplementationLSrr cCsF|dk rtjd||jkr$tS||jkr:tjdtddS)NzschemaType not yet supportedz'asynchronous builders are not supportedzunknown value for mode)r6r7r8MODE_SYNCHRONOUSrMODE_ASYNCHRONOUSrn)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 rdwarningsZxml.domr6Zxml.dom.NodeFilterr__all__rrr4objectrrrrrrrrrs   %,1!