a Z^c0c@sddlZddlZddlmZgdZGdddZGdddZdd ZGd d d e Z Gd d d e Z GdddZ [GdddZ GdddZdS)N) NodeFilter) DOMBuilderDOMEntityResolverDOMInputSourcec@sXeZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdS)OptionsTFN)__name__ __module__ __qualname__ 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.9/xml/dom/xmlbuilder.pyr s& rc@seZdZdZdZdZdZdZdZdZ 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-gggd.d/gd0gd1gd2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<ZdS)=rNrcCs t|_dSN)r_optionsselfrrr__init__9zDOMBuilder.__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_errorHandlerAr%zDOMBuilder._get_errorHandlercCr*r r,)r#rrrr_set_errorHandlerCr%zDOMBuilder._set_errorHandlercCr&r rr"rrr _get_filterFr%zDOMBuilder._get_filtercCr*r r/)r#rrrr _set_filterHr%zDOMBuilder._set_filtercCs||rr|rdpd}z|jt||f}Wn&tyRtjd|fdYq0|D]\}}t|j||qXntj dt |dS)Nrrzunsupported feature: %rzunknown feature: ) supportsFeature _settings _name_xformZKeyErrorxmldomNotSupportedErrZsetattrr! NotFoundErrrepr)r#namestateZsettingsZvaluerrr setFeatureKs    zDOMBuilder.setFeaturecCst|jt|Sr )Zhasattrr!r4)r#r:rrrr2Yr%zDOMBuilder.supportsFeaturecCst||rdpdf}||jvS)Nrr)r4r3)r#r:r;Zkeyrrr canSetFeature\szDOMBuilder.canSetFeaturer rr rr rrrrrr rr rrrrrrrrrrrrrrrrrrrrrrrrrrr) r>rErFrHrL)rrrKrOrQrrr rr r)r>r?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQ)rr)rrrRrSrTcCst|}zt|j|WSty|dkrn|j}|joh|joh|joh|joh|jpf|j pf|j pf|j pf|j YSt jdt|Yn0dS)Nrzfeature %s not known)r4Zgetattrr!AttributeErrorrrrrr rrrrr5r6r8r9)r#r:Zxnameoptionsrrr getFeatures0  zDOMBuilder.getFeaturecCs.|jr|jd|}ntd|}||Sr )r( resolveEntityrparse)r#uriinputrrrparseURIszDOMBuilder.parseURIcCsRt|j}|j|_|j|_|j}|durF|jrFddl}|j|j}| ||SNr) copyr!rr byteStreamsystemIdurllib.requestrequestZurlopen_parse_bytestream)r#r[rVZfpurllibrrrrYs zDOMBuilder.parsecCs||jvrtdtddS)Nznot a legal actionzHaven't written this yet...)_legal_actions ValueErrorNotImplementedError)r#r[ZcnodeZactionrrrparseWithContexts zDOMBuilder.parseWithContextcCs ddl}|jj|}||Sr])Zxml.dom.expatbuilderr6Z expatbuilderZ makeBuilderZ parseFile)r#ZstreamrVr5ZbuilderrrrrcszDOMBuilder._parse_bytestream)rrr r(rrZACTION_REPLACEZACTION_APPEND_AS_CHILDRENZACTION_INSERT_AFTERZACTION_INSERT_BEFORErer$r)r+r-r.r0r1r<r2r=r3rWr\rYrhrcrrrrr,s  = rcCs|ddS)Nz-Z_)lowerZreplace)r:rrrr4r%r4c@s0eZdZdZddZddZddZdd Zd S) r)_openerc Cst}||_||_|||_|||_ddl}ddl }|j |}|\}}} } } } | r| ds| | d} ||| | | | f}|j ||_|S)Nrz/)rpublicIdr` _get_openerZopenr__guess_media_encodingencoding posixpathZ urllib.parserYZurlparseZendswithZdirnameZ urlunparsebaseURI) r#rkr`sourcerordZpartsZschemeZnetlocZpathZparamsZqueryZfragmentrrrrXs  zDOMEntityResolver.resolveEntitycCs0z|jWSty*||_|jYS0dSr )rjrU_create_openerr"rrrrls   zDOMEntityResolver._get_openercCsddl}|jSr])rarbZ build_opener)r#rdrrrrrsz DOMEntityResolver._create_openercCsF|j}d|vrB|D]&}|dr|dddSqdS)Nz Content-Typezcharset=z=r)r_infoZgetplistZ startswithZsplitri)r#rqrsZparamrrrrms    z'DOMEntityResolver._guess_media_encodingN)rrr __slots__rXrlrrrmrrrrrs rc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd S)!rr_characterStream stringDatarnrkr`rpcCs.d|_d|_d|_d|_d|_d|_d|_dSr rur"rrrr$szDOMInputSource.__init__cCr&r r_r"rrr_get_byteStream r%zDOMInputSource._get_byteStreamcCr*r rx)r#r_rrr_set_byteStreamr%zDOMInputSource._set_byteStreamcCr&r rvr"rrr_get_characterStreamr%z#DOMInputSource._get_characterStreamcCr*r r{)r#rvrrr_set_characterStreamr%z#DOMInputSource._set_characterStreamcCr&r rwr"rrr_get_stringDatar%zDOMInputSource._get_stringDatacCr*r r~)r#Zdatarrr_set_stringDatar%zDOMInputSource._set_stringDatacCr&r rnr"rrr _get_encodingr%zDOMInputSource._get_encodingcCr*r r)r#rnrrr _set_encodingr%zDOMInputSource._set_encodingcCr&r rkr"rrr _get_publicId!r%zDOMInputSource._get_publicIdcCr*r r)r#rkrrr _set_publicId#r%zDOMInputSource._set_publicIdcCr&r r`r"rrr _get_systemId&r%zDOMInputSource._get_systemIdcCr*r r)r#r`rrr _set_systemId(r%zDOMInputSource._set_systemIdcCr&r rpr"rrr _get_baseURI+r%zDOMInputSource._get_baseURIcCr*r rr#rZrrr _set_baseURI-r%zDOMInputSource._set_baseURIN)rrr rtr$ryrzr|r}rrrrrrrrrrrrrrrs  rc@s:eZdZdZdZdZdZejZ ddZ ddZ d d Z d S) DOMBuilderFilterrrrrcCr&r ) whatToShowr"rrr_get_whatToShowBr%z DOMBuilderFilter._get_whatToShowcCr&r  FILTER_ACCEPTr#Zelementrrr acceptNodeEr%zDOMBuilderFilter.acceptNodecCr&r rrrrrstartContainerHr%zDOMBuilderFilter.startContainerN) rrr rZ FILTER_REJECTZ FILTER_SKIPZFILTER_INTERRUPTrZSHOW_ALLrrrrrrrrr1s rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS) DocumentLSFcCsdS)NFrr"rrr _get_asyncSr%zDocumentLS._get_asynccCs|rtjddS)Nz.asynchronous document loading is not supported)r5r6r7)r#Zflagrrr _set_asyncVszDocumentLS._set_asynccC tddS)Nz'haven't figured out what this means yetrgr"rrrabort[szDocumentLS.abortcCrNzhaven't written this yetrrrrrloadar%zDocumentLS.loadcCrrr)r#rqrrrloadXMLdr%zDocumentLS.loadXMLcCs*|dur|}n|j|ur"tj|Sr )Z ownerDocumentr5r6ZWrongDocumentErrZtoxml)r#ZsnoderrrsaveXMLgs   zDocumentLS.saveXMLN) rrr Zasync_rrrrrrrrrrrNsrc@s,eZdZdZdZddZddZddZd S) DOMImplementationLSrrcCsF|durtjd||jkr$tS||jkr:tjdtddS)NzschemaType not yet supportedz'asynchronous builders are not supportedzunknown value for mode)r5r6r7MODE_SYNCHRONOUSrMODE_ASYNCHRONOUSrf)r#ZmodeZ schemaTyperrrcreateDOMBuilderss  z$DOMImplementationLS.createDOMBuildercCr)Nz-the writer interface hasn't been written yet!rr"rrrcreateDOMWriter~sz#DOMImplementationLS.createDOMWritercCstSr )rr"rrrcreateDOMInputSourcer%z(DOMImplementationLS.createDOMInputSourceN)rrr rrrrrrrrrros  r)r^Zxml.domr5Zxml.dom.NodeFilterrZ__all__rrr4ZobjectrrrrrrrrrZs  %,1!