U AT^s0c@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__:zDOMBuilder.__init__cC|jSr!entityResolverr#rrr_get_entityResolver=r&zDOMBuilder._get_entityResolvercC ||_dSr!r()r$r)rrr_set_entityResolver?r&zDOMBuilder._set_entityResolvercCr'r!rr#rrr_get_errorHandlerBr&zDOMBuilder._get_errorHandlercCr+r!r-)r$rrrr_set_errorHandlerDr&zDOMBuilder._set_errorHandlercCr'r!rr#rrr _get_filterGr&zDOMBuilder._get_filtercCr+r!r0)r$rrrr _set_filterIr&zDOMBuilder._set_filtercCs||rt|rdpd}z|jt||f}Wn(tk rTtjd|fdYqX|D]\}}t|j||qZntj dt |dS)Nrrzunsupported feature: %rzunknown feature: ) supportsFeature _settings _name_xformZKeyErrorxmldomNotSupportedErrZsetattrr" NotFoundErrrepr)r$namestateZsettingsZvaluerrr setFeatureLs   zDOMBuilder.setFeaturecCst|jt|Sr!)Zhasattrr"r5)r$r;rrrr3Zr&zDOMBuilder.supportsFeaturecCst||rdpdf}||jkS)Nrr)r5r4)r$r;r<Zkeyrrr canSetFeature]szDOMBuilder.canSetFeaturer rr rr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr)rrrrr rr r)r?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrR)rr)rrrSrTrUcCst|}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)r5Zgetattrr"AttributeErrorrrrrr rrrrr6r7r9r:)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\rWZfpurllibrrrrZs zDOMBuilder.parsecCs||jkrtdtddS)Nznot a legal actionzHaven't written this yet...)_legal_actions ValueErrorNotImplementedError)r$r\ZcnodeZactionrrrparseWithContexts zDOMBuilder.parseWithContextcCs ddl}|jj|}||Sr^)Zxml.dom.expatbuilderr7Z expatbuilderZ makeBuilderZ parseFile)r$ZstreamrWr6ZbuilderrrrrdszDOMBuilder._parse_bytestream)rrr r)rrZACTION_REPLACEZACTION_APPEND_AS_CHILDRENZACTION_INSERT_AFTERZACTION_INSERT_BEFORErfr%r*r,r.r/r1r2r=r3r>r4rXr]rZrirdrrrrr-s  = cCs|ddS)Nz-Z_)lowerZreplace)r;rrrr5r&r5c@s0eZdZdZddZddZddZdd Zd S) r)_openerc Cs|dk s tt}||_||_|||_|||_ddl }ddl }|j |}|\}}} } } } | r| ds|| d} ||| | | | f}|j ||_|S)Nrz/)ZAssertionErrorrpublicIdra _get_openerZopenr`_guess_media_encodingencoding posixpathZ urllib.parserZZurlparseZendswithZdirnameZ urlunparsebaseURI) r$rlrasourcerpreZpartsZschemeZnetlocZpathZparamsZqueryZfragmentrrrrYs   zDOMEntityResolver.resolveEntitycCs2z|jWStk r,||_|jYSXdSr!)rkrV_create_openerr#rrrrms  zDOMEntityResolver._get_openercCsddl}|jSr^)rbrcZ build_opener)r$rerrrrssz DOMEntityResolver._create_openercCsF|j}d|krB|D]&}|dr|dddSqdS)Nz Content-Typezcharset=z=r)r`infoZgetplistZ startswithZsplitrj)r$rrrtZparamrrrrns    z'DOMEntityResolver._guess_media_encodingN)rrr __slots__rYrmrsrnrrrrrs c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd S)!rr`characterStream stringDatarorlrarqcCs.d|_d|_d|_d|_d|_d|_d|_dSr!rvr#rrrr%szDOMInputSource.__init__cCr'r!r`r#rrr_get_byteStreamr&zDOMInputSource._get_byteStreamcCr+r!ry)r$r`rrr_set_byteStreamr&zDOMInputSource._set_byteStreamcCr'r!rwr#rrr_get_characterStreamr&z#DOMInputSource._get_characterStreamcCr+r!r|)r$rwrrr_set_characterStreamr&z#DOMInputSource._set_characterStreamcCr'r!rxr#rrr_get_stringDatar&zDOMInputSource._get_stringDatacCr+r!r)r$Zdatarrr_set_stringDatar&zDOMInputSource._set_stringDatacCr'r!ror#rrr _get_encodingr&zDOMInputSource._get_encodingcCr+r!r)r$rorrr _set_encodingr&zDOMInputSource._set_encodingcCr'r!rlr#rrr _get_publicId"r&zDOMInputSource._get_publicIdcCr+r!r)r$rlrrr _set_publicId$r&zDOMInputSource._set_publicIdcCr'r!rar#rrr _get_systemId'r&zDOMInputSource._get_systemIdcCr+r!r)r$rarrr _set_systemId)r&zDOMInputSource._set_systemIdcCr'r!rqr#rrr _get_baseURI,r&zDOMInputSource._get_baseURIcCr+r!rr$r[rrr _set_baseURI.r&zDOMInputSource._set_baseURIN)rrr rur%rzr{r}r~rrrrrrrrrrrrrrrs  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. rrrr cCr'r!) whatToShowr#rrr_get_whatToShowCr&z DOMBuilderFilter._get_whatToShowcCr'r! FILTER_ACCEPTr$Zelementrrr acceptNodeFr&zDOMBuilderFilter.acceptNodecCr'r!rrrrrstartContainerIr&zDOMBuilderFilter.startContainerN)rrr 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_asyncTr&zDocumentLS._get_asynccCs|rtjddS)Nz.asynchronous document loading is not supported)r6r7r8)r$Zflagrrr _set_asyncWszDocumentLS._set_asynccC tddS)Nz'haven't figured out what this means yetrhr#rrrabort\szDocumentLS.abortcCrNzhaven't written this yetrrrrrloadbr&zDocumentLS.loadcCrrr)r$rrrrrloadXMLer&zDocumentLS.loadXMLcCs*|dkr|}n|j|k r"tj|Sr!)Z ownerDocumentr6r7ZWrongDocumentErrZtoxml)r$ZsnoderrrsaveXMLhs   zDocumentLS.saveXMLN) rrr 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)r6r7r8MODE_SYNCHRONOUSrMODE_ASYNCHRONOUSrg)r$ZmodeZ schemaTyperrrcreateDOMBuilderts  z$DOMImplementationLS.createDOMBuildercCr)Nz-the writer interface hasn't been written yet!rr#rrrcreateDOMWritersz#DOMImplementationLS.createDOMWritercCstSr!)rr#rrrcreateDOMInputSourcer&z(DOMImplementationLS.createDOMInputSourceN)rrr rrrrrrrrrrps  r)r r_ZwarningsZxml.domr6Zxml.dom.NodeFilterrZ__all__rrr5ZobjectrrrrrrrrrZs   %,1!