MZÂ�   ÿÿ ¸ @ ø º ´ Ã�!¸LÃ�!This program cannot be run in DOS mode. $ ³B´´÷#Úç÷#Úç÷#Úç…¢ßæA#Úç…¢Þæû#Úç…¢Ùæÿ#򍾴'çõ#Úçæ¥Ùæþ#Úçæ¥Þææ#Úçæ¥ßæß#Úç…¢Ûæð#Úç÷#Ûç{#Úçs¥Þæî#Úçs¥Øæö#ÚçRich÷#Úç PE d† ˆñg ð " * º  €Ã  @     P  Ê¢Ÿ  `Ã�€„     í P   äŸ ` # @ t PÃ�  À @ Ã�  .text ¹  º  `.rdata j+ Ã� , ¾ @ @.data PS   ê @ À.pdata # ` $ ø @ @.fptable  Â�   @ À.rsrc äŸ      @ @.reloc t @  ¾ /** * Front to the WordPress application. This file doesn't do anything, but loads PK:©ç\ÖCc©©dom/NodeFilter.pynu„[µü¤# This is the Python mapping for interface NodeFilter from # DOM2-Traversal-Range. It contains only constants. class NodeFilter: """ This is the DOM2 NodeFilter interface. It contains only constants. """ FILTER_ACCEPT = 1 FILTER_REJECT = 2 FILTER_SKIP = 3 SHOW_ALL = 0xFFFFFFFFL SHOW_ELEMENT = 0x00000001 SHOW_ATTRIBUTE = 0x00000002 SHOW_TEXT = 0x00000004 SHOW_CDATA_SECTION = 0x00000008 SHOW_ENTITY_REFERENCE = 0x00000010 SHOW_ENTITY = 0x00000020 SHOW_PROCESSING_INSTRUCTION = 0x00000040 SHOW_COMMENT = 0x00000080 SHOW_DOCUMENT = 0x00000100 SHOW_DOCUMENT_TYPE = 0x00000200 SHOW_DOCUMENT_FRAGMENT = 0x00000400 SHOW_NOTATION = 0x00000800 def acceptNode(self, node): raise NotImplementedError PK:©ç\Nz/��dom/NodeFilter.pycnu„[µü¤ó ›V~gc@sddd„ƒYZdS(t NodeFiltercBsweZdZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZd„ZRS(sL This is the DOM2 NodeFilter interface. It contains only constants. iiilÿÿiiii i@i€iiiicCs t‚dS(N(tNotImplementedError(tselftnode((s7/opt/alt/python27/lib64/python2.7/xml/dom/NodeFilter.pyt acceptNodes(t__name__t __module__t__doc__t FILTER_ACCEPTt FILTER_REJECTt FILTER_SKIPtSHOW_ALLt SHOW_ELEMENTtSHOW_ATTRIBUTEt SHOW_TEXTtSHOW_CDATA_SECTIONtSHOW_ENTITY_REFERENCEt SHOW_ENTITYtSHOW_PROCESSING_INSTRUCTIONt SHOW_COMMENTt SHOW_DOCUMENTtSHOW_DOCUMENT_TYPEtSHOW_DOCUMENT_FRAGMENTt SHOW_NOTATIONR(((s7/opt/alt/python27/lib64/python2.7/xml/dom/NodeFilter.pyRs$N((R(((s7/opt/alt/python27/lib64/python2.7/xml/dom/NodeFilter.pyttPK:©ç\Nz/��dom/NodeFilter.pyonu„[µü¤ó ›V~gc@sddd„ƒYZdS(t NodeFiltercBsweZdZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZd„ZRS(sL This is the DOM2 NodeFilter interface. It contains only constants. iiilÿÿiiii i@i€iiiicCs t‚dS(N(tNotImplementedError(tselftnode((s7/opt/alt/python27/lib64/python2.7/xml/dom/NodeFilter.pyt acceptNodes(t__name__t __module__t__doc__t FILTER_ACCEPTt FILTER_REJECTt FILTER_SKIPtSHOW_ALLt SHOW_ELEMENTtSHOW_ATTRIBUTEt SHOW_TEXTtSHOW_CDATA_SECTIONtSHOW_ENTITY_REFERENCEt SHOW_ENTITYtSHOW_PROCESSING_INSTRUCTIONt SHOW_COMMENTt SHOW_DOCUMENTtSHOW_DOCUMENT_TYPEtSHOW_DOCUMENT_FRAGMENTt SHOW_NOTATIONR(((s7/opt/alt/python27/lib64/python2.7/xml/dom/NodeFilter.pyRs$N((R(((s7/opt/alt/python27/lib64/python2.7/xml/dom/NodeFilter.pyttPK:©ç\XBžždom/__init__.pynu„[µü¤"""W3C Document Object Model implementation for Python. The Python mapping of the Document Object Model is documented in the Python Library Reference in the section on the xml.dom package. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace support added (based on the Level 2 specification) and other minor Level 2 functionality. pulldom -- DOM builder supporting on-demand tree-building for selected subtrees of the document. """ class Node: """Class giving the NodeType constants.""" # DOM implementations may use this as a base class for their own # Node implementations. If they don't, the constants defined here # should still be used as the canonical definitions as they match # the values given in the W3C recommendation. Client code can # safely refer to these values in all tests of Node.nodeType # values. ELEMENT_NODE = 1 ATTRIBUTE_NODE = 2 TEXT_NODE = 3 CDATA_SECTION_NODE = 4 ENTITY_REFERENCE_NODE = 5 ENTITY_NODE = 6 PROCESSING_INSTRUCTION_NODE = 7 COMMENT_NODE = 8 DOCUMENT_NODE = 9 DOCUMENT_TYPE_NODE = 10 DOCUMENT_FRAGMENT_NODE = 11 NOTATION_NODE = 12 #ExceptionCode INDEX_SIZE_ERR = 1 DOMSTRING_SIZE_ERR = 2 HIERARCHY_REQUEST_ERR = 3 WRONG_DOCUMENT_ERR = 4 INVALID_CHARACTER_ERR = 5 NO_DATA_ALLOWED_ERR = 6 NO_MODIFICATION_ALLOWED_ERR = 7 NOT_FOUND_ERR = 8 NOT_SUPPORTED_ERR = 9 INUSE_ATTRIBUTE_ERR = 10 INVALID_STATE_ERR = 11 SYNTAX_ERR = 12 INVALID_MODIFICATION_ERR = 13 NAMESPACE_ERR = 14 INVALID_ACCESS_ERR = 15 VALIDATION_ERR = 16 class DOMException(Exception): """Abstract base class for DOM exceptions. Exceptions with specific codes are specializations of this class.""" def __init__(self, *args, **kw): if self.__class__ is DOMException: raise RuntimeError( "DOMException should not be instantiated directly") Exception.__init__(self, *args, **kw) def _get_code(self): return self.code class IndexSizeErr(DOMException): code = INDEX_SIZE_ERR class DomstringSizeErr(DOMException): code = DOMSTRING_SIZE_ERR class HierarchyRequestErr(DOMException): code = HIERARCHY_REQUEST_ERR class WrongDocumentErr(DOMException): code = WRONG_DOCUMENT_ERR class InvalidCharacterErr(DOMException): code = INVALID_CHARACTER_ERR class NoDataAllowedErr(DOMException): code = NO_DATA_ALLOWED_ERR class NoModificationAllowedErr(DOMException): code = NO_MODIFICATION_ALLOWED_ERR class NotFoundErr(DOMException): code = NOT_FOUND_ERR class NotSupportedErr(DOMException): code = NOT_SUPPORTED_ERR class InuseAttributeErr(DOMException): code = INUSE_ATTRIBUTE_ERR class InvalidStateErr(DOMException): code = INVALID_STATE_ERR class SyntaxErr(DOMException): code = SYNTAX_ERR class InvalidModificationErr(DOMException): code = INVALID_MODIFICATION_ERR class NamespaceErr(DOMException): code = NAMESPACE_ERR class InvalidAccessErr(DOMException): code = INVALID_ACCESS_ERR class ValidationErr(DOMException): code = VALIDATION_ERR class UserDataHandler: """Class giving the operation constants for UserDataHandler.handle().""" # Based on DOM Level 3 (WD 9 April 2002) NODE_CLONED = 1 NODE_IMPORTED = 2 NODE_DELETED = 3 NODE_RENAMED = 4 XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/" XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml" EMPTY_NAMESPACE = None EMPTY_PREFIX = None from domreg import getDOMImplementation,registerDOMImplementation PK:©ç\}VBÊmmdom/__init__.pycnu„[µü¤ó ›V~gc@s:dZdd=d„ƒYZdZdZdZdZdZdZd Zd Z d Z d Z d Z dZ dZdZdZdZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd „ƒYZd!efd"„ƒYZd#efd$„ƒYZd%efd&„ƒYZd'efd(„ƒYZd)efd*„ƒYZd+efd,„ƒYZd-efd.„ƒYZ d/efd0„ƒYZ!d1efd2„ƒYZ"d3efd4„ƒYZ#d5d>d6„ƒYZ$d7Z%d8Z&d9Z'd<Z)d<Z*d:d;l+m,Z,m-Z-d<S(?s W3C Document Object Model implementation for Python. The Python mapping of the Document Object Model is documented in the Python Library Reference in the section on the xml.dom package. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace support added (based on the Level 2 specification) and other minor Level 2 functionality. pulldom -- DOM builder supporting on-demand tree-building for selected subtrees of the document. tNodecBsVeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( s$Class giving the NodeType constants.iiiiiiiii i i i (t__name__t __module__t__doc__t ELEMENT_NODEtATTRIBUTE_NODEt TEXT_NODEtCDATA_SECTION_NODEtENTITY_REFERENCE_NODEt ENTITY_NODEtPROCESSING_INSTRUCTION_NODEt COMMENT_NODEt DOCUMENT_NODEtDOCUMENT_TYPE_NODEtDOCUMENT_FRAGMENT_NODEt NOTATION_NODE(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRs iiiiiiiii i i i i iiit DOMExceptioncBs eZdZd„Zd„ZRS(smAbstract base class for DOM exceptions. Exceptions with specific codes are specializations of this class.cOs5|jtkrtdƒ‚ntj|||ŽdS(Ns0DOMException should not be instantiated directly(t __class__Rt RuntimeErrort Exceptiont__init__(tselftargstkw((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRAs cCs|jS(N(tcode(R((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyt _get_codeGs(RRRRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR=s t IndexSizeErrcBseZeZRS((RRtINDEX_SIZE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRKstDomstringSizeErrcBseZeZRS((RRtDOMSTRING_SIZE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRNstHierarchyRequestErrcBseZeZRS((RRtHIERARCHY_REQUEST_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRQstWrongDocumentErrcBseZeZRS((RRtWRONG_DOCUMENT_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR TstInvalidCharacterErrcBseZeZRS((RRtINVALID_CHARACTER_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR"WstNoDataAllowedErrcBseZeZRS((RRtNO_DATA_ALLOWED_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR$ZstNoModificationAllowedErrcBseZeZRS((RRtNO_MODIFICATION_ALLOWED_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR&]st NotFoundErrcBseZeZRS((RRt NOT_FOUND_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR(`stNotSupportedErrcBseZeZRS((RRtNOT_SUPPORTED_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR*cstInuseAttributeErrcBseZeZRS((RRtINUSE_ATTRIBUTE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR,fstInvalidStateErrcBseZeZRS((RRtINVALID_STATE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR.ist SyntaxErrcBseZeZRS((RRt SYNTAX_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR0lstInvalidModificationErrcBseZeZRS((RRtINVALID_MODIFICATION_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR2ost NamespaceErrcBseZeZRS((RRt NAMESPACE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR4rstInvalidAccessErrcBseZeZRS((RRtINVALID_ACCESS_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR6ust ValidationErrcBseZeZRS((RRtVALIDATION_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR8xstUserDataHandlercBs&eZdZdZdZdZdZRS(sBClass giving the operation constants for UserDataHandler.handle().iiii(RRRt NODE_CLONEDt NODE_IMPORTEDt NODE_DELETEDt NODE_RENAMED(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR:{s s$http://www.w3.org/XML/1998/namespaceshttp://www.w3.org/2000/xmlns/shttp://www.w3.org/1999/xhtmliÿÿÿÿ(tgetDOMImplementationtregisterDOMImplementationN(((.RRRRRR!R#R%R'R)R+R-R/R1R3R5R7R9RRRRRR R"R$R&R(R*R,R.R0R2R4R6R8R:t XML_NAMESPACEtXMLNS_NAMESPACEtXHTML_NAMESPACEtNonetEMPTY_NAMESPACEt EMPTY_PREFIXtdomregR?R@(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pytsR PK:©ç\}VBÊmmdom/__init__.pyonu„[µü¤ó ›V~gc@s:dZdd=d„ƒYZdZdZdZdZdZdZd Zd Z d Z d Z d Z dZ dZdZdZdZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd „ƒYZd!efd"„ƒYZd#efd$„ƒYZd%efd&„ƒYZd'efd(„ƒYZd)efd*„ƒYZd+efd,„ƒYZd-efd.„ƒYZ d/efd0„ƒYZ!d1efd2„ƒYZ"d3efd4„ƒYZ#d5d>d6„ƒYZ$d7Z%d8Z&d9Z'd<Z)d<Z*d:d;l+m,Z,m-Z-d<S(?s W3C Document Object Model implementation for Python. The Python mapping of the Document Object Model is documented in the Python Library Reference in the section on the xml.dom package. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace support added (based on the Level 2 specification) and other minor Level 2 functionality. pulldom -- DOM builder supporting on-demand tree-building for selected subtrees of the document. tNodecBsVeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( s$Class giving the NodeType constants.iiiiiiiii i i i (t__name__t __module__t__doc__t ELEMENT_NODEtATTRIBUTE_NODEt TEXT_NODEtCDATA_SECTION_NODEtENTITY_REFERENCE_NODEt ENTITY_NODEtPROCESSING_INSTRUCTION_NODEt COMMENT_NODEt DOCUMENT_NODEtDOCUMENT_TYPE_NODEtDOCUMENT_FRAGMENT_NODEt NOTATION_NODE(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRs iiiiiiiii i i i i iiit DOMExceptioncBs eZdZd„Zd„ZRS(smAbstract base class for DOM exceptions. Exceptions with specific codes are specializations of this class.cOs5|jtkrtdƒ‚ntj|||ŽdS(Ns0DOMException should not be instantiated directly(t __class__Rt RuntimeErrort Exceptiont__init__(tselftargstkw((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRAs cCs|jS(N(tcode(R((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyt _get_codeGs(RRRRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR=s t IndexSizeErrcBseZeZRS((RRtINDEX_SIZE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRKstDomstringSizeErrcBseZeZRS((RRtDOMSTRING_SIZE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRNstHierarchyRequestErrcBseZeZRS((RRtHIERARCHY_REQUEST_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyRQstWrongDocumentErrcBseZeZRS((RRtWRONG_DOCUMENT_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR TstInvalidCharacterErrcBseZeZRS((RRtINVALID_CHARACTER_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR"WstNoDataAllowedErrcBseZeZRS((RRtNO_DATA_ALLOWED_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR$ZstNoModificationAllowedErrcBseZeZRS((RRtNO_MODIFICATION_ALLOWED_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR&]st NotFoundErrcBseZeZRS((RRt NOT_FOUND_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR(`stNotSupportedErrcBseZeZRS((RRtNOT_SUPPORTED_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR*cstInuseAttributeErrcBseZeZRS((RRtINUSE_ATTRIBUTE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR,fstInvalidStateErrcBseZeZRS((RRtINVALID_STATE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR.ist SyntaxErrcBseZeZRS((RRt SYNTAX_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR0lstInvalidModificationErrcBseZeZRS((RRtINVALID_MODIFICATION_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR2ost NamespaceErrcBseZeZRS((RRt NAMESPACE_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR4rstInvalidAccessErrcBseZeZRS((RRtINVALID_ACCESS_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR6ust ValidationErrcBseZeZRS((RRtVALIDATION_ERRR(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR8xstUserDataHandlercBs&eZdZdZdZdZdZRS(sBClass giving the operation constants for UserDataHandler.handle().iiii(RRRt NODE_CLONEDt NODE_IMPORTEDt NODE_DELETEDt NODE_RENAMED(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pyR:{s s$http://www.w3.org/XML/1998/namespaceshttp://www.w3.org/2000/xmlns/shttp://www.w3.org/1999/xhtmliÿÿÿÿ(tgetDOMImplementationtregisterDOMImplementationN(((.RRRRRR!R#R%R'R)R+R-R/R1R3R5R7R9RRRRRR R"R$R&R(R*R,R.R0R2R4R6R8R:t XML_NAMESPACEtXMLNS_NAMESPACEtXHTML_NAMESPACEtNonetEMPTY_NAMESPACEt EMPTY_PREFIXtdomregR?R@(((s5/opt/alt/python27/lib64/python2.7/xml/dom/__init__.pytsR PK:©ç\„CxrÇ Ç dom/domreg.pynu„[µü¤"""Registration facilities for DOM. This module should not be used directly. Instead, the functions getDOMImplementation and registerDOMImplementation should be imported from xml.dom.""" from xml.dom.minicompat import * # isinstance, StringTypes # This is a list of well-known implementations. Well-known names # should be published by posting to xml-sig@python.org, and are # subsequently recorded in this file. import sys well_known_implementations = { 'minidom':'xml.dom.minidom', '4DOM': 'xml.dom.DOMImplementation', } # DOM implementations not officially registered should register # themselves with their registered = {} def registerDOMImplementation(name, factory): """registerDOMImplementation(name, factory) Register the factory function with the name. The factory function should return an object which implements the DOMImplementation interface. The factory function can either return the same object, or a new one (e.g. if that implementation supports some customization).""" registered[name] = factory def _good_enough(dom, features): "_good_enough(dom, features) -> Return 1 if the dom offers the features" for f,v in features: if not dom.hasFeature(f,v): return 0 return 1 def getDOMImplementation(name = None, features = ()): """getDOMImplementation(name = None, features = ()) -> DOM implementation. Return a suitable DOM implementation. The name is either well-known, the module name of a DOM implementation, or None. If it is not None, imports the corresponding module and returns DOMImplementation object if the import succeeds. If name is not given, consider the available implementations to find one with the required feature set. If no implementation can be found, raise an ImportError. The features list must be a sequence of (feature, version) pairs which are passed to hasFeature.""" import os creator = None mod = well_known_implementations.get(name) if mod: mod = __import__(mod, {}, {}, ['getDOMImplementation']) return mod.getDOMImplementation() elif name: return registered[name]() elif not sys.flags.ignore_environment and "PYTHON_DOM" in os.environ: return getDOMImplementation(name = os.environ["PYTHON_DOM"]) # User did not specify a name, try implementations in arbitrary # order, returning the one that has the required features if isinstance(features, StringTypes): features = _parse_feature_string(features) for creator in registered.values(): dom = creator() if _good_enough(dom, features): return dom for creator in well_known_implementations.keys(): try: dom = getDOMImplementation(name = creator) except StandardError: # typically ImportError, or AttributeError continue if _good_enough(dom, features): return dom raise ImportError,"no suitable DOM implementation found" def _parse_feature_string(s): features = [] parts = s.split() i = 0 length = len(parts) while i < length: feature = parts[i] if feature[0] in "0123456789": raise ValueError, "bad feature name: %r" % (feature,) i = i + 1 version = None if i < length: v = parts[i] if v[0] in "0123456789": i = i + 1 version = v features.append((feature, version)) return tuple(features) PK:©ç\M`j®y y dom/domreg.pycnu„[µü¤ó ›V~gc@sddZddlTddlZidd6dd6ZiZd„Zd „Zdd d „Zd „Z dS( s´Registration facilities for DOM. This module should not be used directly. Instead, the functions getDOMImplementation and registerDOMImplementation should be imported from xml.dom.iÿÿÿÿ(t*Nsxml.dom.minidomtminidomsxml.dom.DOMImplementationt4DOMcCs|t| Return 1 if the dom offers the featuresii(t hasFeature(tdomtfeaturestftv((s3/opt/alt/python27/lib64/python2.7/xml/dom/domreg.pyt _good_enough"scCs<ddl}d}tj|ƒ}|rIt|iidgƒ}|jƒS|rZt|ƒStjj rŠd|j krŠtd|j dƒSt |t ƒr¨t |ƒ}nx0tjƒD]"}|ƒ}t||ƒrµ|SqµWxQtjƒD]C}ytd|ƒ}Wntk rqènXt||ƒrè|SqèWtd‚dS(sSgetDOMImplementation(name = None, features = ()) -> DOM implementation. Return a suitable DOM implementation. The name is either well-known, the module name of a DOM implementation, or None. If it is not None, imports the corresponding module and returns DOMImplementation object if the import succeeds. If name is not given, consider the available implementations to find one with the required feature set. If no implementation can be found, raise an ImportError. The features list must be a sequence of (feature, version) pairs which are passed to hasFeature.iÿÿÿÿNtgetDOMImplementationt PYTHON_DOMRs$no suitable DOM implementation found(tostNonetwell_known_implementationstgett __import__R Rtsystflagstignore_environmenttenviront isinstancet StringTypest_parse_feature_stringtvaluesR tkeyst StandardErrort ImportError(RR RtcreatortmodR((s3/opt/alt/python27/lib64/python2.7/xml/dom/domreg.pyR )s0     cCsÍg}|jƒ}d}t|ƒ}xœ||krÂ||}|ddkr`td|f‚n|d}d}||kr¬||}|ddkr¬|d}|}q¬n|j||fƒq'Wt|ƒS(Nit 0123456789sbad feature name: %ri(tsplittlent ValueErrorRtappendttuple(tsR tpartstitlengthtfeaturetversionR ((s3/opt/alt/python27/lib64/python2.7/xml/dom/domreg.pyRTs"        (( t__doc__txml.dom.minicompatRRRRR RR R(((s3/opt/alt/python27/lib64/python2.7/xml/dom/domreg.pyts    +PK:©ç\M`j®y y dom/domreg.pyonu„[µü¤ó ›V~gc@sddZddlTddlZidd6dd6ZiZd„Zd „Zdd d „Zd „Z dS( s´Registration facilities for DOM. This module should not be used directly. Instead, the functions getDOMImplementation and registerDOMImplementation should be imported from xml.dom.iÿÿÿÿ(t*Nsxml.dom.minidomtminidomsxml.dom.DOMImplementationt4DOMcCs|t| Return 1 if the dom offers the featuresii(t hasFeature(tdomtfeaturestftv((s3/opt/alt/python27/lib64/python2.7/xml/dom/domreg.pyt _good_enough"scCs<ddl}d}tj|ƒ}|rIt|iidgƒ}|jƒS|rZt|ƒStjj rŠd|j krŠtd|j dƒSt |t ƒr¨t |ƒ}nx0tjƒD]"}|ƒ}t||ƒrµ|SqµWxQtjƒD]C}ytd|ƒ}Wntk rqènXt||ƒrè|SqèWtd‚dS(sSgetDOMImplementation(name = None, features = ()) -> DOM implementation. Return a suitable DOM implementation. The name is either well-known, the module name of a DOM implementation, or None. If it is not None, imports the corresponding module and returns DOMImplementation object if the import succeeds. If name is not given, consider the available implementations to find one with the required feature set. If no implementation can be found, raise an ImportError. The features list must be a sequence of (feature, version) pairs which are passed to hasFeature.iÿÿÿÿNtgetDOMImplementationt PYTHON_DOMRs$no suitable DOM implementation found(tostNonetwell_known_implementationstgett __import__R Rtsystflagstignore_environmenttenviront isinstancet StringTypest_parse_feature_stringtvaluesR tkeyst StandardErrort ImportError(RR RtcreatortmodR((s3/opt/alt/python27/lib64/python2.7/xml/dom/domreg.pyR )s0     cCsÍg}|jƒ}d}t|ƒ}xœ||krÂ||}|ddkr`td|f‚n|d}d}||kr¬||}|ddkr¬|d}|}q¬n|j||fƒq'Wt|ƒS(Nit 0123456789sbad feature name: %ri(tsplittlent ValueErrorRtappendttuple(tsR tpartstitlengthtfeaturetversionR ((s3/opt/alt/python27/lib64/python2.7/xml/dom/domreg.pyRTs"        (( t__doc__txml.dom.minicompatRRRRR RR R(((s3/opt/alt/python27/lib64/python2.7/xml/dom/domreg.pyts    +PK:©ç\˜”CpŽŽdom/expatbuilder.pynu„[µü¤"""Facility to use the Expat parser to load a minidom instance from a string or file. This avoids all the overhead of SAX and pulldom to gain performance. """ # Warning! # # This module is tightly bound to the implementation details of the # minidom DOM and can't be used with other DOM implementations. This # is due, in part, to a lack of appropriate methods in the DOM (there is # no way to create Entity and Notation nodes via the DOM Level 2 # interface), and for performance. The latter is the cause of some fairly # cryptic code. # # Performance hacks: # # - .character_data_handler() has an extra case in which continuing # data is appended to an existing Text node; this can be a # speedup since pyexpat can break up character data into multiple # callbacks even though we set the buffer_text attribute on the # parser. This also gives us the advantage that we don't need a # separate normalization pass. # # - Determining that a node exists is done using an identity comparison # with None rather than a truth test; this avoids searching for and # calling any methods on the node object if it exists. (A rather # nice speedup is achieved this way as well!) from xml.dom import xmlbuilder, minidom, Node from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE from xml.parsers import expat from xml.dom.minidom import _append_child, _set_attribute_node from xml.dom.NodeFilter import NodeFilter from xml.dom.minicompat import * TEXT_NODE = Node.TEXT_NODE CDATA_SECTION_NODE = Node.CDATA_SECTION_NODE DOCUMENT_NODE = Node.DOCUMENT_NODE FILTER_ACCEPT = xmlbuilder.DOMBuilderFilter.FILTER_ACCEPT FILTER_REJECT = xmlbuilder.DOMBuilderFilter.FILTER_REJECT FILTER_SKIP = xmlbuilder.DOMBuilderFilter.FILTER_SKIP FILTER_INTERRUPT = xmlbuilder.DOMBuilderFilter.FILTER_INTERRUPT theDOMImplementation = minidom.getDOMImplementation() # Expat typename -> TypeInfo _typeinfo_map = { "CDATA": minidom.TypeInfo(None, "cdata"), "ENUM": minidom.TypeInfo(None, "enumeration"), "ENTITY": minidom.TypeInfo(None, "entity"), "ENTITIES": minidom.TypeInfo(None, "entities"), "ID": minidom.TypeInfo(None, "id"), "IDREF": minidom.TypeInfo(None, "idref"), "IDREFS": minidom.TypeInfo(None, "idrefs"), "NMTOKEN": minidom.TypeInfo(None, "nmtoken"), "NMTOKENS": minidom.TypeInfo(None, "nmtokens"), } class ElementInfo(object): __slots__ = '_attr_info', '_model', 'tagName' def __init__(self, tagName, model=None): self.tagName = tagName self._attr_info = [] self._model = model def __getstate__(self): return self._attr_info, self._model, self.tagName def __setstate__(self, state): self._attr_info, self._model, self.tagName = state def getAttributeType(self, aname): for info in self._attr_info: if info[1] == aname: t = info[-2] if t[0] == "(": return _typeinfo_map["ENUM"] else: return _typeinfo_map[info[-2]] return minidom._no_type def getAttributeTypeNS(self, namespaceURI, localName): return minidom._no_type def isElementContent(self): if self._model: type = self._model[0] return type not in (expat.model.XML_CTYPE_ANY, expat.model.XML_CTYPE_MIXED) else: return False def isEmpty(self): if self._model: return self._model[0] == expat.model.XML_CTYPE_EMPTY else: return False def isId(self, aname): for info in self._attr_info: if info[1] == aname: return info[-2] == "ID" return False def isIdNS(self, euri, ename, auri, aname): # not sure this is meaningful return self.isId((auri, aname)) def _intern(builder, s): return builder._intern_setdefault(s, s) def _parse_ns_name(builder, name): assert ' ' in name parts = name.split(' ') intern = builder._intern_setdefault if len(parts) == 3: uri, localname, prefix = parts prefix = intern(prefix, prefix) qname = "%s:%s" % (prefix, localname) qname = intern(qname, qname) localname = intern(localname, localname) else: uri, localname = parts prefix = EMPTY_PREFIX qname = localname = intern(localname, localname) return intern(uri, uri), localname, prefix, qname class ExpatBuilder: """Document builder that uses Expat to build a ParsedXML.DOM document instance.""" def __init__(self, options=None): if options is None: options = xmlbuilder.Options() self._options = options if self._options.filter is not None: self._filter = FilterVisibilityController(self._options.filter) else: self._filter = None # This *really* doesn't do anything in this case, so # override it with something fast & minimal. self._finish_start_element = id self._parser = None self.reset() def createParser(self): """Create a new parser object.""" return expat.ParserCreate() def getParser(self): """Return the parser object, creating a new one if needed.""" if not self._parser: self._parser = self.createParser() self._intern_setdefault = self._parser.intern.setdefault self._parser.buffer_text = True self._parser.ordered_attributes = True self._parser.specified_attributes = True self.install(self._parser) return self._parser def reset(self): """Free all data structures used during DOM construction.""" self.document = theDOMImplementation.createDocument( EMPTY_NAMESPACE, None, None) self.curNode = self.document self._elem_info = self.document._elem_info self._cdata = False def install(self, parser): """Install the callbacks needed to build the DOM into the parser.""" # This creates circular references! parser.StartDoctypeDeclHandler = self.start_doctype_decl_handler parser.StartElementHandler = self.first_element_handler parser.EndElementHandler = self.end_element_handler parser.ProcessingInstructionHandler = self.pi_handler if self._options.entities: parser.EntityDeclHandler = self.entity_decl_handler parser.NotationDeclHandler = self.notation_decl_handler if self._options.comments: parser.CommentHandler = self.comment_handler if self._options.cdata_sections: parser.StartCdataSectionHandler = self.start_cdata_section_handler parser.EndCdataSectionHandler = self.end_cdata_section_handler parser.CharacterDataHandler = self.character_data_handler_cdata else: parser.CharacterDataHandler = self.character_data_handler parser.ExternalEntityRefHandler = self.external_entity_ref_handler parser.XmlDeclHandler = self.xml_decl_handler parser.ElementDeclHandler = self.element_decl_handler parser.AttlistDeclHandler = self.attlist_decl_handler def parseFile(self, file): """Parse a document from a file object, returning the document node.""" parser = self.getParser() first_buffer = True try: while 1: buffer = file.read(16*1024) if not buffer: break parser.Parse(buffer, 0) if first_buffer and self.document.documentElement: self._setup_subset(buffer) first_buffer = False parser.Parse("", True) except ParseEscape: pass doc = self.document self.reset() self._parser = None return doc def parseString(self, string): """Parse a document from a string, returning the document node.""" parser = self.getParser() try: parser.Parse(string, True) self._setup_subset(string) except ParseEscape: pass doc = self.document self.reset() self._parser = None return doc def _setup_subset(self, buffer): """Load the internal subset if there might be one.""" if self.document.doctype: extractor = InternalSubsetExtractor() extractor.parseString(buffer) subset = extractor.getSubset() self.document.doctype.internalSubset = subset def start_doctype_decl_handler(self, doctypeName, systemId, publicId, has_internal_subset): doctype = self.document.implementation.createDocumentType( doctypeName, publicId, systemId) doctype.ownerDocument = self.document _append_child(self.document, doctype) self.document.doctype = doctype if self._filter and self._filter.acceptNode(doctype) == FILTER_REJECT: self.document.doctype = None del self.document.childNodes[-1] doctype = None self._parser.EntityDeclHandler = None self._parser.NotationDeclHandler = None if has_internal_subset: if doctype is not None: doctype.entities._seq = [] doctype.notations._seq = [] self._parser.CommentHandler = None self._parser.ProcessingInstructionHandler = None self._parser.EndDoctypeDeclHandler = self.end_doctype_decl_handler def end_doctype_decl_handler(self): if self._options.comments: self._parser.CommentHandler = self.comment_handler self._parser.ProcessingInstructionHandler = self.pi_handler if not (self._elem_info or self._filter): self._finish_end_element = id def pi_handler(self, target, data): node = self.document.createProcessingInstruction(target, data) _append_child(self.curNode, node) if self._filter and self._filter.acceptNode(node) == FILTER_REJECT: self.curNode.removeChild(node) def character_data_handler_cdata(self, data): childNodes = self.curNode.childNodes if self._cdata: if ( self._cdata_continue and childNodes[-1].nodeType == CDATA_SECTION_NODE): childNodes[-1].appendData(data) return node = self.document.createCDATASection(data) self._cdata_continue = True elif childNodes and childNodes[-1].nodeType == TEXT_NODE: node = childNodes[-1] value = node.data + data d = node.__dict__ d['data'] = d['nodeValue'] = value return else: node = minidom.Text() d = node.__dict__ d['data'] = d['nodeValue'] = data d['ownerDocument'] = self.document _append_child(self.curNode, node) def character_data_handler(self, data): childNodes = self.curNode.childNodes if childNodes and childNodes[-1].nodeType == TEXT_NODE: node = childNodes[-1] d = node.__dict__ d['data'] = d['nodeValue'] = node.data + data return node = minidom.Text() d = node.__dict__ d['data'] = d['nodeValue'] = node.data + data d['ownerDocument'] = self.document _append_child(self.curNode, node) def entity_decl_handler(self, entityName, is_parameter_entity, value, base, systemId, publicId, notationName): if is_parameter_entity: # we don't care about parameter entities for the DOM return if not self._options.entities: return node = self.document._create_entity(entityName, publicId, systemId, notationName) if value is not None: # internal entity # node *should* be readonly, but we'll cheat child = self.document.createTextNode(value) node.childNodes.append(child) self.document.doctype.entities._seq.append(node) if self._filter and self._filter.acceptNode(node) == FILTER_REJECT: del self.document.doctype.entities._seq[-1] def notation_decl_handler(self, notationName, base, systemId, publicId): node = self.document._create_notation(notationName, publicId, systemId) self.document.doctype.notations._seq.append(node) if self._filter and self._filter.acceptNode(node) == FILTER_ACCEPT: del self.document.doctype.notations._seq[-1] def comment_handler(self, data): node = self.document.createComment(data) _append_child(self.curNode, node) if self._filter and self._filter.acceptNode(node) == FILTER_REJECT: self.curNode.removeChild(node) def start_cdata_section_handler(self): self._cdata = True self._cdata_continue = False def end_cdata_section_handler(self): self._cdata = False self._cdata_continue = False def external_entity_ref_handler(self, context, base, systemId, publicId): return 1 def first_element_handler(self, name, attributes): if self._filter is None and not self._elem_info: self._finish_end_element = id self.getParser().StartElementHandler = self.start_element_handler self.start_element_handler(name, attributes) def start_element_handler(self, name, attributes): node = self.document.createElement(name) _append_child(self.curNode, node) self.curNode = node if attributes: for i in range(0, len(attributes), 2): a = minidom.Attr(attributes[i], EMPTY_NAMESPACE, None, EMPTY_PREFIX) value = attributes[i+1] d = a.childNodes[0].__dict__ d['data'] = d['nodeValue'] = value d = a.__dict__ d['value'] = d['nodeValue'] = value d['ownerDocument'] = self.document _set_attribute_node(node, a) if node is not self.document.documentElement: self._finish_start_element(node) def _finish_start_element(self, node): if self._filter: # To be general, we'd have to call isSameNode(), but this # is sufficient for minidom: if node is self.document.documentElement: return filt = self._filter.startContainer(node) if filt == FILTER_REJECT: # ignore this node & all descendents Rejecter(self) elif filt == FILTER_SKIP: # ignore this node, but make it's children become # children of the parent node Skipper(self) else: return self.curNode = node.parentNode node.parentNode.removeChild(node) node.unlink() # If this ever changes, Namespaces.end_element_handler() needs to # be changed to match. # def end_element_handler(self, name): curNode = self.curNode self.curNode = curNode.parentNode self._finish_end_element(curNode) def _finish_end_element(self, curNode): info = self._elem_info.get(curNode.tagName) if info: self._handle_white_text_nodes(curNode, info) if self._filter: if curNode is self.document.documentElement: return if self._filter.acceptNode(curNode) == FILTER_REJECT: self.curNode.removeChild(curNode) curNode.unlink() def _handle_white_text_nodes(self, node, info): if (self._options.whitespace_in_element_content or not info.isElementContent()): return # We have element type information and should remove ignorable # whitespace; identify for text nodes which contain only # whitespace. L = [] for child in node.childNodes: if child.nodeType == TEXT_NODE and not child.data.strip(): L.append(child) # Remove ignorable whitespace from the tree. for child in L: node.removeChild(child) def element_decl_handler(self, name, model): info = self._elem_info.get(name) if info is None: self._elem_info[name] = ElementInfo(name, model) else: assert info._model is None info._model = model def attlist_decl_handler(self, elem, name, type, default, required): info = self._elem_info.get(elem) if info is None: info = ElementInfo(elem) self._elem_info[elem] = info info._attr_info.append( [None, name, None, None, default, 0, type, required]) def xml_decl_handler(self, version, encoding, standalone): self.document.version = version self.document.encoding = encoding # This is still a little ugly, thanks to the pyexpat API. ;-( if standalone >= 0: if standalone: self.document.standalone = True else: self.document.standalone = False # Don't include FILTER_INTERRUPT, since that's checked separately # where allowed. _ALLOWED_FILTER_RETURNS = (FILTER_ACCEPT, FILTER_REJECT, FILTER_SKIP) class FilterVisibilityController(object): """Wrapper around a DOMBuilderFilter which implements the checks to make the whatToShow filter attribute work.""" __slots__ = 'filter', def __init__(self, filter): self.filter = filter def startContainer(self, node): mask = self._nodetype_mask[node.nodeType] if self.filter.whatToShow & mask: val = self.filter.startContainer(node) if val == FILTER_INTERRUPT: raise ParseEscape if val not in _ALLOWED_FILTER_RETURNS: raise ValueError, \ "startContainer() returned illegal value: " + repr(val) return val else: return FILTER_ACCEPT def acceptNode(self, node): mask = self._nodetype_mask[node.nodeType] if self.filter.whatToShow & mask: val = self.filter.acceptNode(node) if val == FILTER_INTERRUPT: raise ParseEscape if val == FILTER_SKIP: # move all child nodes to the parent, and remove this node parent = node.parentNode for child in node.childNodes[:]: parent.appendChild(child) # node is handled by the caller return FILTER_REJECT if val not in _ALLOWED_FILTER_RETURNS: raise ValueError, \ "acceptNode() returned illegal value: " + repr(val) return val else: return FILTER_ACCEPT _nodetype_mask = { Node.ELEMENT_NODE: NodeFilter.SHOW_ELEMENT, Node.ATTRIBUTE_NODE: NodeFilter.SHOW_ATTRIBUTE, Node.TEXT_NODE: NodeFilter.SHOW_TEXT, Node.CDATA_SECTION_NODE: NodeFilter.SHOW_CDATA_SECTION, Node.ENTITY_REFERENCE_NODE: NodeFilter.SHOW_ENTITY_REFERENCE, Node.ENTITY_NODE: NodeFilter.SHOW_ENTITY, Node.PROCESSING_INSTRUCTION_NODE: NodeFilter.SHOW_PROCESSING_INSTRUCTION, Node.COMMENT_NODE: NodeFilter.SHOW_COMMENT, Node.DOCUMENT_NODE: NodeFilter.SHOW_DOCUMENT, Node.DOCUMENT_TYPE_NODE: NodeFilter.SHOW_DOCUMENT_TYPE, Node.DOCUMENT_FRAGMENT_NODE: NodeFilter.SHOW_DOCUMENT_FRAGMENT, Node.NOTATION_NODE: NodeFilter.SHOW_NOTATION, } class FilterCrutch(object): __slots__ = '_builder', '_level', '_old_start', '_old_end' def __init__(self, builder): self._level = 0 self._builder = builder parser = builder._parser self._old_start = parser.StartElementHandler self._old_end = parser.EndElementHandler parser.StartElementHandler = self.start_element_handler parser.EndElementHandler = self.end_element_handler class Rejecter(FilterCrutch): __slots__ = () def __init__(self, builder): FilterCrutch.__init__(self, builder) parser = builder._parser for name in ("ProcessingInstructionHandler", "CommentHandler", "CharacterDataHandler", "StartCdataSectionHandler", "EndCdataSectionHandler", "ExternalEntityRefHandler", ): setattr(parser, name, None) def start_element_handler(self, *args): self._level = self._level + 1 def end_element_handler(self, *args): if self._level == 0: # restore the old handlers parser = self._builder._parser self._builder.install(parser) parser.StartElementHandler = self._old_start parser.EndElementHandler = self._old_end else: self._level = self._level - 1 class Skipper(FilterCrutch): __slots__ = () def start_element_handler(self, *args): node = self._builder.curNode self._old_start(*args) if self._builder.curNode is not node: self._level = self._level + 1 def end_element_handler(self, *args): if self._level == 0: # We're popping back out of the node we're skipping, so we # shouldn't need to do anything but reset the handlers. self._builder._parser.StartElementHandler = self._old_start self._builder._parser.EndElementHandler = self._old_end self._builder = None else: self._level = self._level - 1 self._old_end(*args) # framework document used by the fragment builder. # Takes a string for the doctype, subset string, and namespace attrs string. _FRAGMENT_BUILDER_INTERNAL_SYSTEM_ID = \ "http://xml.python.org/entities/fragment-builder/internal" _FRAGMENT_BUILDER_TEMPLATE = ( '''\ %%s ]> &fragment-builder-internal;''' % _FRAGMENT_BUILDER_INTERNAL_SYSTEM_ID) class FragmentBuilder(ExpatBuilder): """Builder which constructs document fragments given XML source text and a context node. The context node is expected to provide information about the namespace declarations which are in scope at the start of the fragment. """ def __init__(self, context, options=None): if context.nodeType == DOCUMENT_NODE: self.originalDocument = context self.context = context else: self.originalDocument = context.ownerDocument self.context = context ExpatBuilder.__init__(self, options) def reset(self): ExpatBuilder.reset(self) self.fragment = None def parseFile(self, file): """Parse a document fragment from a file object, returning the fragment node.""" return self.parseString(file.read()) def parseString(self, string): """Parse a document fragment from a string, returning the fragment node.""" self._source = string parser = self.getParser() doctype = self.originalDocument.doctype ident = "" if doctype: subset = doctype.internalSubset or self._getDeclarations() if doctype.publicId: ident = ('PUBLIC "%s" "%s"' % (doctype.publicId, doctype.systemId)) elif doctype.systemId: ident = 'SYSTEM "%s"' % doctype.systemId else: subset = "" nsattrs = self._getNSattrs() # get ns decls from node's ancestors document = _FRAGMENT_BUILDER_TEMPLATE % (ident, subset, nsattrs) try: parser.Parse(document, 1) except: self.reset() raise fragment = self.fragment self.reset() ## self._parser = None return fragment def _getDeclarations(self): """Re-create the internal subset from the DocumentType node. This is only needed if we don't already have the internalSubset as a string. """ doctype = self.context.ownerDocument.doctype s = "" if doctype: for i in range(doctype.notations.length): notation = doctype.notations.item(i) if s: s = s + "\n " s = "%s' \ % (s, notation.publicId, notation.systemId) else: s = '%s SYSTEM "%s">' % (s, notation.systemId) for i in range(doctype.entities.length): entity = doctype.entities.item(i) if s: s = s + "\n " s = "%s" return s def _getNSattrs(self): return "" def external_entity_ref_handler(self, context, base, systemId, publicId): if systemId == _FRAGMENT_BUILDER_INTERNAL_SYSTEM_ID: # this entref is the one that we made to put the subtree # in; all of our given input is parsed in here. old_document = self.document old_cur_node = self.curNode parser = self._parser.ExternalEntityParserCreate(context) # put the real document back, parse into the fragment to return self.document = self.originalDocument self.fragment = self.document.createDocumentFragment() self.curNode = self.fragment try: parser.Parse(self._source, 1) finally: self.curNode = old_cur_node self.document = old_document self._source = None return -1 else: return ExpatBuilder.external_entity_ref_handler( self, context, base, systemId, publicId) class Namespaces: """Mix-in class for builders; adds support for namespaces.""" def _initNamespaces(self): # list of (prefix, uri) ns declarations. Namespace attrs are # constructed from this and added to the element's attrs. self._ns_ordered_prefixes = [] def createParser(self): """Create a new namespace-handling parser.""" parser = expat.ParserCreate(namespace_separator=" ") parser.namespace_prefixes = True return parser def install(self, parser): """Insert the namespace-handlers onto the parser.""" ExpatBuilder.install(self, parser) if self._options.namespace_declarations: parser.StartNamespaceDeclHandler = ( self.start_namespace_decl_handler) def start_namespace_decl_handler(self, prefix, uri): """Push this namespace declaration on our storage.""" self._ns_ordered_prefixes.append((prefix, uri)) def start_element_handler(self, name, attributes): if ' ' in name: uri, localname, prefix, qname = _parse_ns_name(self, name) else: uri = EMPTY_NAMESPACE qname = name localname = None prefix = EMPTY_PREFIX node = minidom.Element(qname, uri, prefix, localname) node.ownerDocument = self.document _append_child(self.curNode, node) self.curNode = node if self._ns_ordered_prefixes: for prefix, uri in self._ns_ordered_prefixes: if prefix: a = minidom.Attr(_intern(self, 'xmlns:' + prefix), XMLNS_NAMESPACE, prefix, "xmlns") else: a = minidom.Attr("xmlns", XMLNS_NAMESPACE, "xmlns", EMPTY_PREFIX) d = a.childNodes[0].__dict__ d['data'] = d['nodeValue'] = uri d = a.__dict__ d['value'] = d['nodeValue'] = uri d['ownerDocument'] = self.document _set_attribute_node(node, a) del self._ns_ordered_prefixes[:] if attributes: _attrs = node._attrs _attrsNS = node._attrsNS for i in range(0, len(attributes), 2): aname = attributes[i] value = attributes[i+1] if ' ' in aname: uri, localname, prefix, qname = _parse_ns_name(self, aname) a = minidom.Attr(qname, uri, localname, prefix) _attrs[qname] = a _attrsNS[(uri, localname)] = a else: a = minidom.Attr(aname, EMPTY_NAMESPACE, aname, EMPTY_PREFIX) _attrs[aname] = a _attrsNS[(EMPTY_NAMESPACE, aname)] = a d = a.childNodes[0].__dict__ d['data'] = d['nodeValue'] = value d = a.__dict__ d['ownerDocument'] = self.document d['value'] = d['nodeValue'] = value d['ownerElement'] = node if __debug__: # This only adds some asserts to the original # end_element_handler(), so we only define this when -O is not # used. If changing one, be sure to check the other to see if # it needs to be changed as well. # def end_element_handler(self, name): curNode = self.curNode if ' ' in name: uri, localname, prefix, qname = _parse_ns_name(self, name) assert (curNode.namespaceURI == uri and curNode.localName == localname and curNode.prefix == prefix), \ "element stack messed up! (namespace)" else: assert curNode.nodeName == name, \ "element stack messed up - bad nodeName" assert curNode.namespaceURI == EMPTY_NAMESPACE, \ "element stack messed up - bad namespaceURI" self.curNode = curNode.parentNode self._finish_end_element(curNode) class ExpatBuilderNS(Namespaces, ExpatBuilder): """Document builder that supports namespaces.""" def reset(self): ExpatBuilder.reset(self) self._initNamespaces() class FragmentBuilderNS(Namespaces, FragmentBuilder): """Fragment builder that supports namespaces.""" def reset(self): FragmentBuilder.reset(self) self._initNamespaces() def _getNSattrs(self): """Return string of namespace attributes from this element and ancestors.""" # XXX This needs to be re-written to walk the ancestors of the # context to build up the namespace information from # declarations, elements, and attributes found in context. # Otherwise we have to store a bunch more data on the DOM # (though that *might* be more reliable -- not clear). attrs = "" context = self.context L = [] while context: if hasattr(context, '_ns_prefix_uri'): for prefix, uri in context._ns_prefix_uri.items(): # add every new NS decl from context to L and attrs string if prefix in L: continue L.append(prefix) if prefix: declname = "xmlns:" + prefix else: declname = "xmlns" if attrs: attrs = "%s\n %s='%s'" % (attrs, declname, uri) else: attrs = " %s='%s'" % (declname, uri) context = context.parentNode return attrs class ParseEscape(Exception): """Exception raised to short-circuit parsing in InternalSubsetExtractor.""" pass class InternalSubsetExtractor(ExpatBuilder): """XML processor which can rip out the internal document type subset.""" subset = None def getSubset(self): """Return the internal subset as a string.""" return self.subset def parseFile(self, file): try: ExpatBuilder.parseFile(self, file) except ParseEscape: pass def parseString(self, string): try: ExpatBuilder.parseString(self, string) except ParseEscape: pass def install(self, parser): parser.StartDoctypeDeclHandler = self.start_doctype_decl_handler parser.StartElementHandler = self.start_element_handler def start_doctype_decl_handler(self, name, publicId, systemId, has_internal_subset): if has_internal_subset: parser = self.getParser() self.subset = [] parser.DefaultHandler = self.subset.append parser.EndDoctypeDeclHandler = self.end_doctype_decl_handler else: raise ParseEscape() def end_doctype_decl_handler(self): s = ''.join(self.subset).replace('\r\n', '\n').replace('\r', '\n') self.subset = s raise ParseEscape() def start_element_handler(self, name, attrs): raise ParseEscape() def parse(file, namespaces=True): """Parse a document, returning the resulting Document node. 'file' may be either a file name or an open file object. """ if namespaces: builder = ExpatBuilderNS() else: builder = ExpatBuilder() if isinstance(file, StringTypes): fp = open(file, 'rb') try: result = builder.parseFile(fp) finally: fp.close() else: result = builder.parseFile(file) return result def parseString(string, namespaces=True): """Parse a document from a string, returning the resulting Document node. """ if namespaces: builder = ExpatBuilderNS() else: builder = ExpatBuilder() return builder.parseString(string) def parseFragment(file, context, namespaces=True): """Parse a fragment of a document, given the context from which it was originally extracted. context should be the parent of the node(s) which are in the fragment. 'file' may be either a file name or an open file object. """ if namespaces: builder = FragmentBuilderNS(context) else: builder = FragmentBuilder(context) if isinstance(file, StringTypes): fp = open(file, 'rb') try: result = builder.parseFile(fp) finally: fp.close() else: result = builder.parseFile(file) return result def parseFragmentString(string, context, namespaces=True): """Parse a fragment of a document from a string, given the context from which it was originally extracted. context should be the parent of the node(s) which are in the fragment. """ if namespaces: builder = FragmentBuilderNS(context) else: builder = FragmentBuilder(context) return builder.parseString(string) def makeBuilder(options): """Create a builder based on an Options object.""" if options.namespaces: return ExpatBuilderNS(options) else: return ExpatBuilder(options) PK:©ç\X£¿@i…i…dom/expatbuilder.pycnu„[µü¤ó ›V~gc@südZddlmZmZmZddlmZmZmZddlm Z ddl m Z m Z ddl mZddlTejZejZejZejjZejjZejjZejjZejƒZi ejedƒd 6ejed ƒd 6ejed ƒd 6ejedƒd6ejedƒd6ejedƒd6ejedƒd6ejedƒd6ejedƒd6Zdefd„ƒYZd„Zd„Z dfd„ƒYZ!eeefZ"d efd!„ƒYZ#d"efd#„ƒYZ$d$e$fd%„ƒYZ%d&e$fd'„ƒYZ&d(Z'd)e'Z(d*e!fd+„ƒYZ)d,fd-„ƒYZ*d.e*e!fd/„ƒYZ+d0e*e)fd1„ƒYZ,d2e-fd3„ƒYZ.d4e!fd5„ƒYZ/e0d6„Z1e0d7„Z2e0d8„Z3e0d9„Z4d:„Z5d;S(<s™Facility to use the Expat parser to load a minidom instance from a string or file. This avoids all the overhead of SAX and pulldom to gain performance. iÿÿÿÿ(t xmlbuildertminidomtNode(tEMPTY_NAMESPACEt EMPTY_PREFIXtXMLNS_NAMESPACE(texpat(t _append_childt_set_attribute_node(t NodeFilter(t*tcdatatCDATAt enumerationtENUMtentitytENTITYtentitiestENTITIEStidtIDtidreftIDREFtidrefstIDREFStnmtokentNMTOKENtnmtokenstNMTOKENSt ElementInfocBsbeZd Zd d„Zd„Zd„Zd„Zd„Zd„Z d „Z d „Z d „Z RS(t _attr_infot_modelttagNamecCs||_g|_||_dS(N(R RR(tselfR tmodel((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt__init__As  cCs|j|j|jfS(N(RRR (R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt __getstate__FscCs|\|_|_|_dS(N(RRR (R!tstate((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt __setstate__IscCs\xR|jD]G}|d|kr |d}|ddkrBtdSt|dSq q WtjS(Niiþÿÿÿit(R(Rt _typeinfo_mapRt_no_type(R!tanametinfott((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytgetAttributeTypeLs cCstjS(N(RR)(R!t namespaceURIt localName((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytgetAttributeTypeNSVscCs:|jr2|jd}|tjjtjjfkStSdS(Ni(RRR"t XML_CTYPE_ANYtXML_CTYPE_MIXEDtFalse(R!ttype((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytisElementContentYs    cCs(|jr |jdtjjkStSdS(Ni(RRR"tXML_CTYPE_EMPTYR3(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytisEmptyas cCs6x/|jD]$}|d|kr |ddkSq WtS(NiiþÿÿÿR(RR3(R!R*R+((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytisIdgscCs|j||fƒS(N(R8(R!teuritenametauriR*((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytisIdNSms(RRR N( t__name__t __module__t __slots__tNoneR#R$R&R-R0R5R7R8R<(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR>s       cCs|j||ƒS(N(t_intern_setdefault(tbuilderts((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt_internqscCsÉd|kst‚|jdƒ}|j}t|ƒdkr‹|\}}}|||ƒ}d||f}|||ƒ}|||ƒ}n%|\}}t}|||ƒ}}|||ƒ|||fS(Nt is%s:%s(tAssertionErrortsplitRAtlenR(RBtnametpartstinternturit localnametprefixtqname((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt_parse_ns_namets  t ExpatBuildercBs eZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(sPDocument builder that uses Expat to build a ParsedXML.DOM document instance.cCsw|dkrtjƒ}n||_|jjdk rNt|jjƒ|_nd|_t|_d|_ |j ƒdS(N( R@RtOptionst_optionstfiltertFilterVisibilityControllert_filterRt_finish_start_elementt_parsertreset(R!toptions((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#‰s     cCs tjƒS(sCreate a new parser object.(Rt ParserCreate(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt createParser—scCsh|jsa|jƒ|_|jjj|_t|j_t|j_t|j_|j |jƒn|jS(s7Return the parser object, creating a new one if needed.( RXR\RKt setdefaultRAtTruet buffer_texttordered_attributestspecified_attributestinstall(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt getParser›s    cCs@tjtddƒ|_|j|_|jj|_t|_dS(s6Free all data structures used during DOM construction.N( ttheDOMImplementationtcreateDocumentRR@tdocumenttcurNodet _elem_infoR3t_cdata(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRY¦s  cCså|j|_|j|_|j|_|j|_|jj rK|j |_ n|j |_ |jjrr|j|_n|jjr¥|j|_|j|_|j|_n |j|_|j|_|j|_|j|_|j|_ dS(s>Install the callbacks needed to build the DOM into the parser.N(!tstart_doctype_decl_handlertStartDoctypeDeclHandlertfirst_element_handlertStartElementHandlertend_element_handlertEndElementHandlert pi_handlertProcessingInstructionHandlerRSRtentity_decl_handlertEntityDeclHandlertnotation_decl_handlertNotationDeclHandlertcommentstcomment_handlertCommentHandlertcdata_sectionststart_cdata_section_handlertStartCdataSectionHandlertend_cdata_section_handlertEndCdataSectionHandlertcharacter_data_handler_cdatatCharacterDataHandlertcharacter_data_handlertexternal_entity_ref_handlertExternalEntityRefHandlertxml_decl_handlertXmlDeclHandlertelement_decl_handlertElementDeclHandlertattlist_decl_handlertAttlistDeclHandler(R!tparser((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRb®s$              cCs²|jƒ}t}ylxU|jdƒ}|s1Pn|j|dƒ|rc|jjrc|j|ƒnt}qW|jdtƒWntk r‘nX|j}|j ƒd|_ |S(sIParse a document from a file object, returning the document node.iiiti@N( RcR^treadtParseRftdocumentElementt _setup_subsetR3t ParseEscapeRYR@RX(R!tfileR‰t first_buffertbuffertdoc((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt parseFileÅs$      cCsa|jƒ}y!|j|tƒ|j|ƒWntk r@nX|j}|jƒd|_|S(s<Parse a document from a string, returning the document node.N( RcRŒR^RŽR�RfRYR@RX(R!tstringR‰R“((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt parseStringÛs     cCsD|jjr@tƒ}|j|ƒ|jƒ}||jj_ndS(s/Load the internal subset if there might be one.N(RftdoctypetInternalSubsetExtractorR–t getSubsettinternalSubset(R!R’t extractortsubset((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRŽès     cCsù|jjj|||ƒ}|j|_t|j|ƒ||j_|jrž|jj|ƒtkržd|j_|jj d=d}d|j _ d|j _ n|rõ|dk rËg|j_g|j_nd|j _d|j _|j|j _ndS(Niÿÿÿÿ(RftimplementationtcreateDocumentTypet ownerDocumentRR—RVt acceptNodet FILTER_REJECTR@t childNodesRXRsRuRt_seqt notationsRxRqtend_doctype_decl_handlertEndDoctypeDeclHandler(R!t doctypeNametsystemIdtpublicIdthas_internal_subsetR—((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRjðs$   !       cCsO|jjr|j|j_n|j|j_|jp<|jsKt |_ ndS(N( RSRvRwRXRxRpRqRhRVRt_finish_end_element(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR¥s  cCs]|jj||ƒ}t|j|ƒ|jrY|jj|ƒtkrY|jj|ƒndS(N(RftcreateProcessingInstructionRRgRVR R¡t removeChild(R!ttargettdatatnode((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRp s!cCsû|jj}|jrd|jrF|djtkrF|dj|ƒdS|jj|ƒ}t |_nƒ|r³|djt kr³|d}|j |}|j }||d<|dt__doc__R@R#R\RcRYRbR”R–RŽRjR¥RpR~R€RrRtRwRzR|R�RlRÈRWRnR«R×R…R‡Rƒ(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRQ…s:                       RUcBsÑeZdZdZd„Zd„Zd„Zi eje j 6ej e j 6ej e j6eje j6eje j6eje j6eje j6eje j6eje j6eje j6eje j6eje j 6Z!RS(soWrapper around a DOMBuilderFilter which implements the checks to make the whatToShow filter attribute work.RTcCs ||_dS(N(RT(R!RT((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#ÕscCsu|j|j}|jj|@rm|jj|ƒ}|tkrGt‚n|tkritdt |ƒ‚n|St SdS(Ns)startContainer() returned illegal value: ( t_nodetype_maskR³RTt whatToShowRÏtFILTER_INTERRUPTR�t_ALLOWED_FILTER_RETURNSt ValueErrortreprRÅ(R!R°tmasktval((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÏØs   cCs°|j|j}|jj|@r¨|jj|ƒ}|tkrGt‚n|tkr‚|j}x|j D]}|j |ƒqgWt S|t kr¤t dt|ƒ‚n|StSdS(Ns%acceptNode() returned illegal value: (RâR³RTRãR RäR�RÑRÓR¢t appendChildR¡RåRæRçRÅ(R!R°RèRétparentRÃ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR ås     (RT("R=R>RáR?R#RÏR R t SHOW_ELEMENTRt ELEMENT_NODEtSHOW_ATTRIBUTEtATTRIBUTE_NODEt SHOW_TEXTR·tSHOW_CDATA_SECTIONR´tSHOW_ENTITY_REFERENCEtENTITY_REFERENCE_NODEt SHOW_ENTITYt ENTITY_NODEtSHOW_PROCESSING_INSTRUCTIONtPROCESSING_INSTRUCTION_NODEt SHOW_COMMENTt COMMENT_NODEt SHOW_DOCUMENTt DOCUMENT_NODEtSHOW_DOCUMENT_TYPEtDOCUMENT_TYPE_NODEtSHOW_DOCUMENT_FRAGMENTtDOCUMENT_FRAGMENT_NODEt SHOW_NOTATIONt NOTATION_NODERâ(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRUÏs$             t FilterCrutchcBseZdZd„ZRS(t_buildert_levelt _old_startt_old_endcCsOd|_||_|j}|j|_|j|_|j|_|j|_dS(Ni( RRRXRmRRoRRÈRn(R!RBR‰((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR# s      (RRRR(R=R>R?R#(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR sRÐcBs)eZdZd„Zd„Zd„ZRS(cCs>tj||ƒ|j}xdD]}t||dƒq WdS(NRqRxRR{R}R‚(RqRxRR{R}R‚(RR#RXtsetattrR@(R!RBR‰RI((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#s  cGs|jd|_dS(Ni(R(R!targs((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÈ$scGsZ|jdkrF|jj}|jj|ƒ|j|_|j|_n|jd|_dS(Nii(RRRXRbRRmRRo(R!RR‰((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRn's   ((R=R>R?R#RÈRn(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÐs RÒcBs eZdZd„Zd„ZRS(cGsB|jj}|j|Œ|jj|k r>|jd|_ndS(Ni(RRgRR(R!RR°((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÈ4s  cGs`|jdkr?|j|jj_|j|jj_d|_n|jd|_|j|ŒdS(Nii(RRRRXRmRRoR@(R!R((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRn:s  ((R=R>R?RÈRn(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÒ1s s8http://xml.python.org/entities/fragment-builder/internalsŠ %%s ]> &fragment-builder-internal;tFragmentBuildercBsPeZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( sñBuilder which constructs document fragments given XML source text and a context node. The context node is expected to provide information about the namespace declarations which are in scope at the start of the fragment. cCsM|jtkr$||_||_n|j|_||_tj||ƒdS(N(R³RûtoriginalDocumentRÇRŸRQR#(R!RÇRZ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#bs     cCstj|ƒd|_dS(N(RQRYR@tfragment(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRYks cCs|j|jƒƒS(sRParse a document fragment from a file object, returning the fragment node.(R–R‹(R!R�((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR”osc Csç||_|jƒ}|jj}d}|r€|jp?|jƒ}|jrdd|j|jf}q†|jr†d|j}q†nd}|jƒ}t |||f}y|j |dƒWn|j ƒ‚nX|j }|j ƒ|S(sMParse a document fragment from a string, returning the fragment node.RŠsPUBLIC "%s" "%s"s SYSTEM "%s"i( t_sourceRcR R—Ršt_getDeclarationsR©R¨t _getNSattrst_FRAGMENT_BUILDER_TEMPLATERŒRYR ( R!R•R‰R—tidentRœtnsattrsRfR ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR–ts,         cCs‡|jjj}d}|rƒxŠt|jjƒD]v}|jj|ƒ}|rY|d}nd||jf}|jr‘d||j|j f}q.d||j f}q.WxØt|j jƒD]Á}|j j|ƒ}|ræ|d}nd||jf}|jrd||j|j f}n5|j r=d||j f}nd ||j j f}|j rrd ||j f}n|d }q»Wn|S( s Re-create the internal subset from the DocumentType node. This is only needed if we don't already have the internalSubset as a string. RŠs s%ss%s SYSTEM "%s">s %s(RÇRŸR—RËR¤tlengthtitemtnodeNameR©R¨Rt firstChildR¯RÂ(R!R—RCRÍtnotationR((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR �s6      cCsdS(NRŠ((R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR´scCs±|tkr”|j}|j}|jj|ƒ}|j|_|jjƒ|_|j|_z|j|j dƒWd||_||_d|_ XdSt j |||||ƒSdS(Niiÿÿÿÿ( t$_FRAGMENT_BUILDER_INTERNAL_SYSTEM_IDRfRgRXtExternalEntityParserCreateR tcreateDocumentFragmentR RŒR R@RQR�(R!RÇRÁR¨R©t old_documentt old_cur_nodeR‰((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR�·s        N( R=R>RáR@R#RYR”R–R RR�(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR Ys    $ t NamespacescBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s7Mix-in class for builders; adds support for namespaces.cCs g|_dS(N(t_ns_ordered_prefixes(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt_initNamespacesÑscCstjddƒ}t|_|S(s'Create a new namespace-handling parser.tnamespace_separatorRE(RR[R^tnamespace_prefixes(R!R‰((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR\Ös cCs/tj||ƒ|jjr+|j|_ndS(s.Insert the namespace-handlers onto the parser.N(RQRbRStnamespace_declarationststart_namespace_decl_handlertStartNamespaceDeclHandler(R!R‰((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRbÜs cCs|jj||fƒdS(s/Push this namespace declaration on our storage.N(RR¾(R!RNRL((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#ãscCs…d|kr*t||ƒ\}}}}nt}|}d}t}tj||||ƒ}|j|_t|j |ƒ||_ |j rIx´|j D]©\}}|rÌtj t |d|ƒt |dƒ}ntj dt dtƒ}|jdj} || d<| d<|j} || d<| d<|j| dRáRR\RbR#RÈRn(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÎs     :tExpatBuilderNScBseZdZd„ZRS(s*Document builder that supports namespaces.cCstj|ƒ|jƒdS(N(RQRYR(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRY5s (R=R>RáRY(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR*2stFragmentBuilderNScBs eZdZd„Zd„ZRS(s*Fragment builder that supports namespaces.cCstj|ƒ|jƒdS(N(R RYR(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRY=s cCsÅd}|j}g}x©|rÀt|dƒr´x„|jjƒD]p\}}||kr[q=n|j|ƒ|r{d|}nd}|r�d|||f}q=d||f}q=Wn|j}qW|S(sNReturn string of namespace attributes from this element and ancestors.RŠt_ns_prefix_urisxmlns:R%s%s %s='%s's %s='%s'(RÇthasattrR,titemsR¾RÓ(R!tattrsRÇRÚRNRLtdeclname((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRAs"      (R=R>RáRYR(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR+:s R�cBseZdZRS(sEException raised to short-circuit parsing in InternalSubsetExtractor.(R=R>Rá(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR�_sR˜cBsSeZdZdZd„Zd„Zd„Zd„Zd„Z d„Z d„Z RS( sBXML processor which can rip out the internal document type subset.cCs|jS(s'Return the internal subset as a string.(Rœ(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR™hscCs,ytj||ƒWntk r'nXdS(N(RQR”R�(R!R�((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR”ls cCs,ytj||ƒWntk r'nXdS(N(RQR–R�(R!R•((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR–rs cCs|j|_|j|_dS(N(RjRkRÈRm(R!R‰((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRbxs cCsF|r9|jƒ}g|_|jj|_|j|_n tƒ‚dS(N(RcRœR¾tDefaultHandlerR¥R¦R�(R!RIR©R¨RªR‰((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRj|s   cCs@dj|jƒjddƒjddƒ}||_tƒ‚dS(NRŠs s s (tjoinRœtreplaceR�(R!RC((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR¥†s* cCs tƒ‚dS(N(R�(R!RIR/((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÈ‹sN( R=R>RáR@RœR™R”R–RbRjR¥RÈ(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR˜cs     cCsp|rtƒ}n tƒ}t|tƒr]t|dƒ}z|j|ƒ}Wd|jƒXn|j|ƒ}|S(s{Parse a document, returning the resulting Document node. 'file' may be either a file name or an open file object. trbN(R*RQt isinstancet StringTypestopenR”tclose(R�t namespacesRBtfptresult((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytparse�s  cCs(|rtƒ}n tƒ}|j|ƒS(sOParse a document from a string, returning the resulting Document node. (R*RQR–(R•R9RB((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR–¤s  cCsv|rt|ƒ}n t|ƒ}t|tƒrct|dƒ}z|j|ƒ}Wd|jƒXn|j|ƒ}|S(sìParse a fragment of a document, given the context from which it was originally extracted. context should be the parent of the node(s) which are in the fragment. 'file' may be either a file name or an open file object. R4N(R+R R5R6R7R”R8(R�RÇR9RBR:R;((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt parseFragment¯s cCs.|rt|ƒ}n t|ƒ}|j|ƒS(s¼Parse a fragment of a document from a string, given the context from which it was originally extracted. context should be the parent of the node(s) which are in the fragment. (R+R R–(R•RÇR9RB((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytparseFragmentStringÆs cCs!|jrt|ƒSt|ƒSdS(s,Create a builder based on an Options object.N(R9R*RQ(RZ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt makeBuilderÒs  N(6Rátxml.domRRRRRRt xml.parsersRtxml.dom.minidomRRtxml.dom.NodeFilterR txml.dom.minicompatR·R´RûtDOMBuilderFilterRÅR¡RÑRätgetDOMImplementationRdtTypeInfoR@R(tobjectRRDRPRQRåRURRÐRÒRRR RR*R+t ExceptionR�R˜R^R<R–R=R>R?(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyts`         3  ÿI:  ud%,   PK:©ç\›«Æ,æ‚æ‚dom/expatbuilder.pyonu„[µü¤ó ›V~gc@südZddlmZmZmZddlmZmZmZddlm Z ddl m Z m Z ddl mZddlTejZejZejZejjZejjZejjZejjZejƒZi ejedƒd 6ejed ƒd 6ejed ƒd 6ejedƒd6ejedƒd6ejedƒd6ejedƒd6ejedƒd6ejedƒd6Zdefd„ƒYZd„Zd„Z dfd„ƒYZ!eeefZ"d efd!„ƒYZ#d"efd#„ƒYZ$d$e$fd%„ƒYZ%d&e$fd'„ƒYZ&d(Z'd)e'Z(d*e!fd+„ƒYZ)d,fd-„ƒYZ*d.e*e!fd/„ƒYZ+d0e*e)fd1„ƒYZ,d2e-fd3„ƒYZ.d4e!fd5„ƒYZ/e0d6„Z1e0d7„Z2e0d8„Z3e0d9„Z4d:„Z5d;S(<s™Facility to use the Expat parser to load a minidom instance from a string or file. This avoids all the overhead of SAX and pulldom to gain performance. iÿÿÿÿ(t xmlbuildertminidomtNode(tEMPTY_NAMESPACEt EMPTY_PREFIXtXMLNS_NAMESPACE(texpat(t _append_childt_set_attribute_node(t NodeFilter(t*tcdatatCDATAt enumerationtENUMtentitytENTITYtentitiestENTITIEStidtIDtidreftIDREFtidrefstIDREFStnmtokentNMTOKENtnmtokenstNMTOKENSt ElementInfocBsbeZd Zd d„Zd„Zd„Zd„Zd„Zd„Z d „Z d „Z d „Z RS(t _attr_infot_modelttagNamecCs||_g|_||_dS(N(R RR(tselfR tmodel((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt__init__As  cCs|j|j|jfS(N(RRR (R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt __getstate__FscCs|\|_|_|_dS(N(RRR (R!tstate((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt __setstate__IscCs\xR|jD]G}|d|kr |d}|ddkrBtdSt|dSq q WtjS(Niiþÿÿÿit(R(Rt _typeinfo_mapRt_no_type(R!tanametinfott((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytgetAttributeTypeLs cCstjS(N(RR)(R!t namespaceURIt localName((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytgetAttributeTypeNSVscCs:|jr2|jd}|tjjtjjfkStSdS(Ni(RRR"t XML_CTYPE_ANYtXML_CTYPE_MIXEDtFalse(R!ttype((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytisElementContentYs    cCs(|jr |jdtjjkStSdS(Ni(RRR"tXML_CTYPE_EMPTYR3(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytisEmptyas cCs6x/|jD]$}|d|kr |ddkSq WtS(NiiþÿÿÿR(RR3(R!R*R+((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytisIdgscCs|j||fƒS(N(R8(R!teuritenametauriR*((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytisIdNSms(RRR N( t__name__t __module__t __slots__tNoneR#R$R&R-R0R5R7R8R<(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR>s       cCs|j||ƒS(N(t_intern_setdefault(tbuilderts((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt_internqscCs·|jdƒ}|j}t|ƒdkry|\}}}|||ƒ}d||f}|||ƒ}|||ƒ}n%|\}}t}|||ƒ}}|||ƒ|||fS(Nt is%s:%s(tsplitRAtlenR(RBtnametpartstinternturit localnametprefixtqname((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt_parse_ns_namets  t ExpatBuildercBs eZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(sPDocument builder that uses Expat to build a ParsedXML.DOM document instance.cCsw|dkrtjƒ}n||_|jjdk rNt|jjƒ|_nd|_t|_d|_ |j ƒdS(N( R@RtOptionst_optionstfiltertFilterVisibilityControllert_filterRt_finish_start_elementt_parsertreset(R!toptions((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#‰s     cCs tjƒS(sCreate a new parser object.(Rt ParserCreate(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt createParser—scCsh|jsa|jƒ|_|jjj|_t|j_t|j_t|j_|j |jƒn|jS(s7Return the parser object, creating a new one if needed.( RWR[RJt setdefaultRAtTruet buffer_texttordered_attributestspecified_attributestinstall(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt getParser›s    cCs@tjtddƒ|_|j|_|jj|_t|_dS(s6Free all data structures used during DOM construction.N( ttheDOMImplementationtcreateDocumentRR@tdocumenttcurNodet _elem_infoR3t_cdata(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRX¦s  cCså|j|_|j|_|j|_|j|_|jj rK|j |_ n|j |_ |jjrr|j|_n|jjr¥|j|_|j|_|j|_n |j|_|j|_|j|_|j|_|j|_ dS(s>Install the callbacks needed to build the DOM into the parser.N(!tstart_doctype_decl_handlertStartDoctypeDeclHandlertfirst_element_handlertStartElementHandlertend_element_handlertEndElementHandlert pi_handlertProcessingInstructionHandlerRRRtentity_decl_handlertEntityDeclHandlertnotation_decl_handlertNotationDeclHandlertcommentstcomment_handlertCommentHandlertcdata_sectionststart_cdata_section_handlertStartCdataSectionHandlertend_cdata_section_handlertEndCdataSectionHandlertcharacter_data_handler_cdatatCharacterDataHandlertcharacter_data_handlertexternal_entity_ref_handlertExternalEntityRefHandlertxml_decl_handlertXmlDeclHandlertelement_decl_handlertElementDeclHandlertattlist_decl_handlertAttlistDeclHandler(R!tparser((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRa®s$              cCs²|jƒ}t}ylxU|jdƒ}|s1Pn|j|dƒ|rc|jjrc|j|ƒnt}qW|jdtƒWntk r‘nX|j}|j ƒd|_ |S(sIParse a document from a file object, returning the document node.iiiti@N( RbR]treadtParseRetdocumentElementt _setup_subsetR3t ParseEscapeRXR@RW(R!tfileRˆt first_buffertbuffertdoc((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt parseFileÅs$      cCsa|jƒ}y!|j|tƒ|j|ƒWntk r@nX|j}|jƒd|_|S(s<Parse a document from a string, returning the document node.N( RbR‹R]R�RŽReRXR@RW(R!tstringRˆR’((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt parseStringÛs     cCsD|jjr@tƒ}|j|ƒ|jƒ}||jj_ndS(s/Load the internal subset if there might be one.N(RetdoctypetInternalSubsetExtractorR•t getSubsettinternalSubset(R!R‘t extractortsubset((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR�ès     cCsù|jjj|||ƒ}|j|_t|j|ƒ||j_|jrž|jj|ƒtkržd|j_|jj d=d}d|j _ d|j _ n|rõ|dk rËg|j_g|j_nd|j _d|j _|j|j _ndS(Niÿÿÿÿ(RetimplementationtcreateDocumentTypet ownerDocumentRR–RUt acceptNodet FILTER_REJECTR@t childNodesRWRrRtRt_seqt notationsRwRptend_doctype_decl_handlertEndDoctypeDeclHandler(R!t doctypeNametsystemIdtpublicIdthas_internal_subsetR–((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRiðs$   !       cCsO|jjr|j|j_n|j|j_|jp<|jsKt |_ ndS(N( RRRuRvRWRwRoRpRgRURt_finish_end_element(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR¤s  cCs]|jj||ƒ}t|j|ƒ|jrY|jj|ƒtkrY|jj|ƒndS(N(RetcreateProcessingInstructionRRfRURŸR t removeChild(R!ttargettdatatnode((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRo s!cCsû|jj}|jrd|jrF|djtkrF|dj|ƒdS|jj|ƒ}t |_nƒ|r³|djt kr³|d}|j |}|j }||d<|dt__doc__R@R#R[RbRXRaR“R•R�RiR¤RoR}RRqRsRvRyR{R€RkRÇRVRmRªRÖR„R†R‚(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRP…s:                       RTcBsÑeZdZdZd„Zd„Zd„Zi eje j 6ej e j 6ej e j6eje j6eje j6eje j6eje j6eje j6eje j6eje j6eje j6eje j 6Z!RS(soWrapper around a DOMBuilderFilter which implements the checks to make the whatToShow filter attribute work.RScCs ||_dS(N(RS(R!RS((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#ÕscCsu|j|j}|jj|@rm|jj|ƒ}|tkrGt‚n|tkritdt |ƒ‚n|St SdS(Ns)startContainer() returned illegal value: ( t_nodetype_maskR²RSt whatToShowRÎtFILTER_INTERRUPTRŽt_ALLOWED_FILTER_RETURNSt ValueErrortreprRÄ(R!R¯tmasktval((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÎØs   cCs°|j|j}|jj|@r¨|jj|ƒ}|tkrGt‚n|tkr‚|j}x|j D]}|j |ƒqgWt S|t kr¤t dt|ƒ‚n|StSdS(Ns%acceptNode() returned illegal value: (RáR²RSRâRŸRãRŽRÐRÒR¡t appendChildR RäRåRæRÄ(R!R¯RçRètparentRÂ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRŸås     (RS("R=R>RàR?R#RÎRŸR t SHOW_ELEMENTRt ELEMENT_NODEtSHOW_ATTRIBUTEtATTRIBUTE_NODEt SHOW_TEXTR¶tSHOW_CDATA_SECTIONR³tSHOW_ENTITY_REFERENCEtENTITY_REFERENCE_NODEt SHOW_ENTITYt ENTITY_NODEtSHOW_PROCESSING_INSTRUCTIONtPROCESSING_INSTRUCTION_NODEt SHOW_COMMENTt COMMENT_NODEt SHOW_DOCUMENTt DOCUMENT_NODEtSHOW_DOCUMENT_TYPEtDOCUMENT_TYPE_NODEtSHOW_DOCUMENT_FRAGMENTtDOCUMENT_FRAGMENT_NODEt SHOW_NOTATIONt NOTATION_NODERá(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRTÏs$             t FilterCrutchcBseZdZd„ZRS(t_buildert_levelt _old_startt_old_endcCsOd|_||_|j}|j|_|j|_|j|_|j|_dS(Ni( RRRWRlRRnRRÇRm(R!RBRˆ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR# s      (RRRR(R=R>R?R#(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR sRÏcBs)eZdZd„Zd„Zd„ZRS(cCs>tj||ƒ|j}xdD]}t||dƒq WdS(NRpRwR~RzR|R�(RpRwR~RzR|R�(RR#RWtsetattrR@(R!RBRˆRH((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#s  cGs|jd|_dS(Ni(R(R!targs((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÇ$scGsZ|jdkrF|jj}|jj|ƒ|j|_|j|_n|jd|_dS(Nii(RRRWRaRRlRRn(R!RRˆ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRm's   ((R=R>R?R#RÇRm(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÏs RÑcBs eZdZd„Zd„ZRS(cGsB|jj}|j|Œ|jj|k r>|jd|_ndS(Ni(RRfRR(R!RR¯((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÇ4s  cGs`|jdkr?|j|jj_|j|jj_d|_n|jd|_|j|ŒdS(Nii(RRRRWRlRRnR@(R!R((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRm:s  ((R=R>R?RÇRm(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÑ1s s8http://xml.python.org/entities/fragment-builder/internalsŠ %%s ]> &fragment-builder-internal;tFragmentBuildercBsPeZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( sñBuilder which constructs document fragments given XML source text and a context node. The context node is expected to provide information about the namespace declarations which are in scope at the start of the fragment. cCsM|jtkr$||_||_n|j|_||_tj||ƒdS(N(R²RútoriginalDocumentRÆRžRPR#(R!RÆRY((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR#bs     cCstj|ƒd|_dS(N(RPRXR@tfragment(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRXks cCs|j|jƒƒS(sRParse a document fragment from a file object, returning the fragment node.(R•RŠ(R!R�((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR“osc Csç||_|jƒ}|jj}d}|r€|jp?|jƒ}|jrdd|j|jf}q†|jr†d|j}q†nd}|jƒ}t |||f}y|j |dƒWn|j ƒ‚nX|j }|j ƒ|S(sMParse a document fragment from a string, returning the fragment node.R‰sPUBLIC "%s" "%s"s SYSTEM "%s"i( t_sourceRbR R–R™t_getDeclarationsR¨R§t _getNSattrst_FRAGMENT_BUILDER_TEMPLATER‹RXR ( R!R”RˆR–tidentR›tnsattrsReR ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR•ts,         cCs‡|jjj}d}|rƒxŠt|jjƒD]v}|jj|ƒ}|rY|d}nd||jf}|jr‘d||j|j f}q.d||j f}q.WxØt|j jƒD]Á}|j j|ƒ}|ræ|d}nd||jf}|jrd||j|j f}n5|j r=d||j f}nd ||j j f}|j rrd ||j f}n|d }q»Wn|S( s Re-create the internal subset from the DocumentType node. This is only needed if we don't already have the internalSubset as a string. R‰s s%ss%s SYSTEM "%s">s %s(RÆRžR–RÊR£tlengthtitemtnodeNameR¨R§Rt firstChildR®RÁ(R!R–RCRÌtnotationR((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR �s6      cCsdS(NR‰((R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR ´scCs±|tkr”|j}|j}|jj|ƒ}|j|_|jjƒ|_|j|_z|j|j dƒWd||_||_d|_ XdSt j |||||ƒSdS(Niiÿÿÿÿ( t$_FRAGMENT_BUILDER_INTERNAL_SYSTEM_IDReRfRWtExternalEntityParserCreateR tcreateDocumentFragmentR R‹R R@RPR€(R!RÆRÀR§R¨t old_documentt old_cur_nodeRˆ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR€·s        N( R=R>RàR@R#RXR“R•R R R€(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRYs    $ t NamespacescBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(s7Mix-in class for builders; adds support for namespaces.cCs g|_dS(N(t_ns_ordered_prefixes(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt_initNamespacesÑscCstjddƒ}t|_|S(s'Create a new namespace-handling parser.tnamespace_separatorRE(RRZR]tnamespace_prefixes(R!Rˆ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR[Ös cCs/tj||ƒ|jjr+|j|_ndS(s.Insert the namespace-handlers onto the parser.N(RPRaRRtnamespace_declarationststart_namespace_decl_handlertStartNamespaceDeclHandler(R!Rˆ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRaÜs cCs|jj||fƒdS(s/Push this namespace declaration on our storage.N(RR½(R!RMRK((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR"ãscCs…d|kr*t||ƒ\}}}}nt}|}d}t}tj||||ƒ}|j|_t|j |ƒ||_ |j rIx´|j D]©\}}|rÌtj t |d|ƒt |dƒ}ntj dt dtƒ}|jdj} || d<| d<|j} || d<| d<|j| dRàRR[RaR"RÇ(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÎs     4tExpatBuilderNScBseZdZd„ZRS(s*Document builder that supports namespaces.cCstj|ƒ|jƒdS(N(RPRXR(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRX5s (R=R>RàRX(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR)2stFragmentBuilderNScBs eZdZd„Zd„ZRS(s*Fragment builder that supports namespaces.cCstj|ƒ|jƒdS(N(RRXR(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRX=s cCsÅd}|j}g}x©|rÀt|dƒr´x„|jjƒD]p\}}||kr[q=n|j|ƒ|r{d|}nd}|r�d|||f}q=d||f}q=Wn|j}qW|S(sNReturn string of namespace attributes from this element and ancestors.R‰t_ns_prefix_urisxmlns:R$s%s %s='%s's %s='%s'(RÆthasattrR+titemsR½RÒ(R!tattrsRÆRÙRMRKtdeclname((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR As"      (R=R>RàRXR (((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR*:s RŽcBseZdZRS(sEException raised to short-circuit parsing in InternalSubsetExtractor.(R=R>Rà(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRŽ_sR—cBsSeZdZdZd„Zd„Zd„Zd„Zd„Z d„Z d„Z RS( sBXML processor which can rip out the internal document type subset.cCs|jS(s'Return the internal subset as a string.(R›(R!((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR˜hscCs,ytj||ƒWntk r'nXdS(N(RPR“RŽ(R!R�((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR“ls cCs,ytj||ƒWntk r'nXdS(N(RPR•RŽ(R!R”((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR•rs cCs|j|_|j|_dS(N(RiRjRÇRl(R!Rˆ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRaxs cCsF|r9|jƒ}g|_|jj|_|j|_n tƒ‚dS(N(RbR›R½tDefaultHandlerR¤R¥RŽ(R!RHR¨R§R©Rˆ((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRi|s   cCs@dj|jƒjddƒjddƒ}||_tƒ‚dS(NR‰s s s (tjoinR›treplaceRŽ(R!RC((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR¤†s* cCs tƒ‚dS(N(RŽ(R!RHR.((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyRÇ‹sN( R=R>RàR@R›R˜R“R•RaRiR¤RÇ(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR—cs     cCsp|rtƒ}n tƒ}t|tƒr]t|dƒ}z|j|ƒ}Wd|jƒXn|j|ƒ}|S(s{Parse a document, returning the resulting Document node. 'file' may be either a file name or an open file object. trbN(R)RPt isinstancet StringTypestopenR“tclose(R�t namespacesRBtfptresult((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytparse�s  cCs(|rtƒ}n tƒ}|j|ƒS(sOParse a document from a string, returning the resulting Document node. (R)RPR•(R”R8RB((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyR•¤s  cCsv|rt|ƒ}n t|ƒ}t|tƒrct|dƒ}z|j|ƒ}Wd|jƒXn|j|ƒ}|S(sìParse a fragment of a document, given the context from which it was originally extracted. context should be the parent of the node(s) which are in the fragment. 'file' may be either a file name or an open file object. R3N(R*RR4R5R6R“R7(R�RÆR8RBR9R:((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt parseFragment¯s cCs.|rt|ƒ}n t|ƒ}|j|ƒS(s¼Parse a fragment of a document from a string, given the context from which it was originally extracted. context should be the parent of the node(s) which are in the fragment. (R*RR•(R”RÆR8RB((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pytparseFragmentStringÆs cCs!|jrt|ƒSt|ƒSdS(s,Create a builder based on an Options object.N(R8R)RP(RY((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyt makeBuilderÒs  N(6Ràtxml.domRRRRRRt xml.parsersRtxml.dom.minidomRRtxml.dom.NodeFilterR txml.dom.minicompatR¶R³RútDOMBuilderFilterRÄR RÐRãtgetDOMImplementationRctTypeInfoR@R(tobjectRRDRORPRäRTRRÏRÑRRRRR)R*t ExceptionRŽR—R]R;R•R<R=R>(((s9/opt/alt/python27/lib64/python2.7/xml/dom/expatbuilder.pyts`         3  ÿI:  ud%,   PK:©ç\©);˜  dom/minicompat.pynu„[µü¤"""Python version compatibility support for minidom.""" # This module should only be imported using "import *". # # The following names are defined: # # NodeList -- lightest possible NodeList implementation # # EmptyNodeList -- lightest possible NodeList that is guaranteed to # remain empty (immutable) # # StringTypes -- tuple of defined string types # # defproperty -- function used in conjunction with GetattrMagic; # using these together is needed to make them work # as efficiently as possible in both Python 2.2+ # and older versions. For example: # # class MyClass(GetattrMagic): # def _get_myattr(self): # return something # # defproperty(MyClass, "myattr", # "return some value") # # For Python 2.2 and newer, this will construct a # property object on the class, which avoids # needing to override __getattr__(). It will only # work for read-only attributes. # # For older versions of Python, inheriting from # GetattrMagic will use the traditional # __getattr__() hackery to achieve the same effect, # but less efficiently. # # defproperty() should be used for each version of # the relevant _get_() function. __all__ = ["NodeList", "EmptyNodeList", "StringTypes", "defproperty"] import xml.dom try: unicode except NameError: StringTypes = type(''), else: StringTypes = type(''), type(unicode('')) class NodeList(list): __slots__ = () def item(self, index): if 0 <= index < len(self): return self[index] def _get_length(self): return len(self) def _set_length(self, value): raise xml.dom.NoModificationAllowedErr( "attempt to modify read-only attribute 'length'") length = property(_get_length, _set_length, doc="The number of nodes in the NodeList.") # For backward compatibility def __setstate__(self, state): if state is None: state = [] self[:] = state class EmptyNodeList(tuple): __slots__ = () def __add__(self, other): NL = NodeList() NL.extend(other) return NL def __radd__(self, other): NL = NodeList() NL.extend(other) return NL def item(self, index): return None def _get_length(self): return 0 def _set_length(self, value): raise xml.dom.NoModificationAllowedErr( "attempt to modify read-only attribute 'length'") length = property(_get_length, _set_length, doc="The number of nodes in the NodeList.") def defproperty(klass, name, doc): get = getattr(klass, ("_get_" + name)).im_func def set(self, value, name=name): raise xml.dom.NoModificationAllowedErr( "attempt to modify read-only attribute " + repr(name)) assert not hasattr(klass, "_set_" + name), \ "expected not to find _set_" + name prop = property(get, set, doc=doc) setattr(klass, name, prop) PK:©ç\áz#dom/minicompat.pycnu„[µü¤ó ›V~gc@s¦dZddddgZddlZyeWn ek rNedƒfZnXedƒeedƒƒfZdefd„ƒYZ de fd „ƒYZ d „Z dS( s1Python version compatibility support for minidom.tNodeListt EmptyNodeListt StringTypest defpropertyiÿÿÿÿNtcBsGeZdZd„Zd„Zd„ZeeeddƒZd„ZRS(cCs.d|kot|ƒknr*||SdS(Ni(tlen(tselftindex((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pytitem6s"cCs t|ƒS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt _get_length:scCstjjdƒ‚dS(Ns.attempt to modify read-only attribute 'length'(txmltdomtNoModificationAllowedErr(Rtvalue((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt _set_length=s tdocs$The number of nodes in the NodeList.cCs |dkrg}n||(dS(N(tNone(Rtstate((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt __setstate__Es  (( t__name__t __module__t __slots__RR RtpropertytlengthR(((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyR3s     cBsPeZdZd„Zd„Zd„Zd„Zd„ZeeeddƒZ RS(cCstƒ}|j|ƒ|S(N(Rtextend(RtothertNL((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt__add__Ns  cCstƒ}|j|ƒ|S(N(RR(RRR((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt__radd__Ss  cCsdS(N(R(RR((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyRXscCsdS(Ni((R((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyR [scCstjjdƒ‚dS(Ns.attempt to modify read-only attribute 'length'(R R R (RR ((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyR^s Rs$The number of nodes in the NodeList.(( RRRRRRR RRR(((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyRKs      cCsot|d|ƒj}|d„}t|d|ƒ sFtd|ƒ‚t||d|ƒ}t|||ƒdS(Nt_get_cSs tjjdt|ƒƒ‚dS(Ns&attempt to modify read-only attribute (R R R trepr(RR tname((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pytseths t_set_sexpected not to find _set_R(tgetattrtim_functhasattrtAssertionErrorRtsetattr(tklassRRtgetR tprop((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyRfs   ( t__doc__t__all__txml.domR tunicodet NameErrorttypeRtlistRttupleRR(((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyts&  PK:©ç\Š?,d¬ ¬ dom/minicompat.pyonu„[µü¤ó ›V~gc@s¦dZddddgZddlZyeWn ek rNedƒfZnXedƒeedƒƒfZdefd„ƒYZ de fd „ƒYZ d „Z dS( s1Python version compatibility support for minidom.tNodeListt EmptyNodeListt StringTypest defpropertyiÿÿÿÿNtcBsGeZdZd„Zd„Zd„ZeeeddƒZd„ZRS(cCs.d|kot|ƒknr*||SdS(Ni(tlen(tselftindex((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pytitem6s"cCs t|ƒS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt _get_length:scCstjjdƒ‚dS(Ns.attempt to modify read-only attribute 'length'(txmltdomtNoModificationAllowedErr(Rtvalue((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt _set_length=s tdocs$The number of nodes in the NodeList.cCs |dkrg}n||(dS(N(tNone(Rtstate((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt __setstate__Es  (( t__name__t __module__t __slots__RR RtpropertytlengthR(((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyR3s     cBsPeZdZd„Zd„Zd„Zd„Zd„ZeeeddƒZ RS(cCstƒ}|j|ƒ|S(N(Rtextend(RtothertNL((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt__add__Ns  cCstƒ}|j|ƒ|S(N(RR(RRR((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyt__radd__Ss  cCsdS(N(R(RR((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyRXscCsdS(Ni((R((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyR [scCstjjdƒ‚dS(Ns.attempt to modify read-only attribute 'length'(R R R (RR ((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyR^s Rs$The number of nodes in the NodeList.(( RRRRRRR RRR(((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyRKs      cCsKt|d|ƒj}|d„}t||d|ƒ}t|||ƒdS(Nt_get_cSs tjjdt|ƒƒ‚dS(Ns&attempt to modify read-only attribute (R R R trepr(RR tname((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pytseths R(tgetattrtim_funcRtsetattr(tklassRRtgetR tprop((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyRfs ( t__doc__t__all__txml.domR tunicodet NameErrorttypeRtlistRttupleRR(((s7/opt/alt/python27/lib64/python2.7/xml/dom/minicompat.pyts&  PK:©ç\‹dfããdom/minidom.pynu„[µü¤"""Simple implementation of the Level 1 DOM. Namespaces and other minor Level 2 features are also supported. parse("foo.xml") parseString("") Todo: ===== * convenience methods for getting elements and text. * more testing * bring some of the writer and linearizer code into conformance with this interface * SAX 2 namespaces """ import xml.dom from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, domreg from xml.dom.minicompat import * from xml.dom.xmlbuilder import DOMImplementationLS, DocumentLS # This is used by the ID-cache invalidation checks; the list isn't # actually complete, since the nodes being checked will never be the # DOCUMENT_NODE or DOCUMENT_FRAGMENT_NODE. (The node being checked is # the node being added or removed, not the node being modified.) # _nodeTypes_with_children = (xml.dom.Node.ELEMENT_NODE, xml.dom.Node.ENTITY_REFERENCE_NODE) class Node(xml.dom.Node): namespaceURI = None # this is non-null only for elements and attributes parentNode = None ownerDocument = None nextSibling = None previousSibling = None prefix = EMPTY_PREFIX # non-null only for NS elements and attributes def __nonzero__(self): return True def toxml(self, encoding = None): return self.toprettyxml("", "", encoding) def toprettyxml(self, indent="\t", newl="\n", encoding = None): # indent = the indentation string to prepend, per level # newl = the newline string to append writer = _get_StringIO() if encoding is not None: import codecs # Can't use codecs.getwriter to preserve 2.0 compatibility writer = codecs.lookup(encoding)[3](writer) if self.nodeType == Node.DOCUMENT_NODE: # Can pass encoding only to document, to put it into XML header self.writexml(writer, "", indent, newl, encoding) else: self.writexml(writer, "", indent, newl) return writer.getvalue() def hasChildNodes(self): if self.childNodes: return True else: return False def _get_childNodes(self): return self.childNodes def _get_firstChild(self): if self.childNodes: return self.childNodes[0] def _get_lastChild(self): if self.childNodes: return self.childNodes[-1] def insertBefore(self, newChild, refChild): if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE: for c in tuple(newChild.childNodes): self.insertBefore(c, refChild) ### The DOM does not clearly specify what to return in this case return newChild if newChild.nodeType not in self._child_node_types: raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(newChild), repr(self))) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) if refChild is None: self.appendChild(newChild) else: try: index = self.childNodes.index(refChild) except ValueError: raise xml.dom.NotFoundErr() if newChild.nodeType in _nodeTypes_with_children: _clear_id_cache(self) self.childNodes.insert(index, newChild) newChild.nextSibling = refChild refChild.previousSibling = newChild if index: node = self.childNodes[index-1] node.nextSibling = newChild newChild.previousSibling = node else: newChild.previousSibling = None newChild.parentNode = self return newChild def appendChild(self, node): if node.nodeType == self.DOCUMENT_FRAGMENT_NODE: for c in tuple(node.childNodes): self.appendChild(c) ### The DOM does not clearly specify what to return in this case return node if node.nodeType not in self._child_node_types: raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(node), repr(self))) elif node.nodeType in _nodeTypes_with_children: _clear_id_cache(self) if node.parentNode is not None: node.parentNode.removeChild(node) _append_child(self, node) node.nextSibling = None return node def replaceChild(self, newChild, oldChild): if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE: refChild = oldChild.nextSibling self.removeChild(oldChild) return self.insertBefore(newChild, refChild) if newChild.nodeType not in self._child_node_types: raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(newChild), repr(self))) if newChild is oldChild: return if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) try: index = self.childNodes.index(oldChild) except ValueError: raise xml.dom.NotFoundErr() self.childNodes[index] = newChild newChild.parentNode = self oldChild.parentNode = None if (newChild.nodeType in _nodeTypes_with_children or oldChild.nodeType in _nodeTypes_with_children): _clear_id_cache(self) newChild.nextSibling = oldChild.nextSibling newChild.previousSibling = oldChild.previousSibling oldChild.nextSibling = None oldChild.previousSibling = None if newChild.previousSibling: newChild.previousSibling.nextSibling = newChild if newChild.nextSibling: newChild.nextSibling.previousSibling = newChild return oldChild def removeChild(self, oldChild): try: self.childNodes.remove(oldChild) except ValueError: raise xml.dom.NotFoundErr() if oldChild.nextSibling is not None: oldChild.nextSibling.previousSibling = oldChild.previousSibling if oldChild.previousSibling is not None: oldChild.previousSibling.nextSibling = oldChild.nextSibling oldChild.nextSibling = oldChild.previousSibling = None if oldChild.nodeType in _nodeTypes_with_children: _clear_id_cache(self) oldChild.parentNode = None return oldChild def normalize(self): L = [] for child in self.childNodes: if child.nodeType == Node.TEXT_NODE: if not child.data: # empty text node; discard if L: L[-1].nextSibling = child.nextSibling if child.nextSibling: child.nextSibling.previousSibling = child.previousSibling child.unlink() elif L and L[-1].nodeType == child.nodeType: # collapse text node node = L[-1] node.data = node.data + child.data node.nextSibling = child.nextSibling if child.nextSibling: child.nextSibling.previousSibling = node child.unlink() else: L.append(child) else: L.append(child) if child.nodeType == Node.ELEMENT_NODE: child.normalize() self.childNodes[:] = L def cloneNode(self, deep): return _clone_node(self, deep, self.ownerDocument or self) def isSupported(self, feature, version): return self.ownerDocument.implementation.hasFeature(feature, version) def _get_localName(self): # Overridden in Element and Attr where localName can be Non-Null return None # Node interfaces from Level 3 (WD 9 April 2002) def isSameNode(self, other): return self is other def getInterface(self, feature): if self.isSupported(feature, None): return self else: return None # The "user data" functions use a dictionary that is only present # if some user data has been set, so be careful not to assume it # exists. def getUserData(self, key): try: return self._user_data[key][0] except (AttributeError, KeyError): return None def setUserData(self, key, data, handler): old = None try: d = self._user_data except AttributeError: d = {} self._user_data = d if key in d: old = d[key][0] if data is None: # ignore handlers passed for None handler = None if old is not None: del d[key] else: d[key] = (data, handler) return old def _call_user_data_handler(self, operation, src, dst): if hasattr(self, "_user_data"): for key, (data, handler) in self._user_data.items(): if handler is not None: handler.handle(operation, key, data, src, dst) # minidom-specific API: def unlink(self): self.parentNode = self.ownerDocument = None if self.childNodes: for child in self.childNodes: child.unlink() self.childNodes = NodeList() self.previousSibling = None self.nextSibling = None defproperty(Node, "firstChild", doc="First child node, or None.") defproperty(Node, "lastChild", doc="Last child node, or None.") defproperty(Node, "localName", doc="Namespace-local name of this node.") def _append_child(self, node): # fast path with less checks; usable by DOM builders if careful childNodes = self.childNodes if childNodes: last = childNodes[-1] node.__dict__["previousSibling"] = last last.__dict__["nextSibling"] = node childNodes.append(node) node.__dict__["parentNode"] = self def _in_document(node): # return True iff node is part of a document tree while node is not None: if node.nodeType == Node.DOCUMENT_NODE: return True node = node.parentNode return False def _write_data(writer, data): "Writes datachars to writer." if data: data = data.replace("&", "&").replace("<", "<"). \ replace("\"", """).replace(">", ">") writer.write(data) def _get_elements_by_tagName_helper(parent, name, rc): for node in parent.childNodes: if node.nodeType == Node.ELEMENT_NODE and \ (name == "*" or node.tagName == name): rc.append(node) _get_elements_by_tagName_helper(node, name, rc) return rc def _get_elements_by_tagName_ns_helper(parent, nsURI, localName, rc): for node in parent.childNodes: if node.nodeType == Node.ELEMENT_NODE: if ((localName == "*" or node.localName == localName) and (nsURI == "*" or node.namespaceURI == nsURI)): rc.append(node) _get_elements_by_tagName_ns_helper(node, nsURI, localName, rc) return rc class DocumentFragment(Node): nodeType = Node.DOCUMENT_FRAGMENT_NODE nodeName = "#document-fragment" nodeValue = None attributes = None parentNode = None _child_node_types = (Node.ELEMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.NOTATION_NODE) def __init__(self): self.childNodes = NodeList() class Attr(Node): nodeType = Node.ATTRIBUTE_NODE attributes = None ownerElement = None specified = False _is_id = False _child_node_types = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) def __init__(self, qName, namespaceURI=EMPTY_NAMESPACE, localName=None, prefix=None): # skip setattr for performance d = self.__dict__ d["nodeName"] = d["name"] = qName d["namespaceURI"] = namespaceURI d["prefix"] = prefix d['childNodes'] = NodeList() # Add the single child node that represents the value of the attr self.childNodes.append(Text()) # nodeValue and value are set elsewhere def _get_localName(self): return self.nodeName.split(":", 1)[-1] def _get_specified(self): return self.specified def __setattr__(self, name, value): d = self.__dict__ if name in ("value", "nodeValue"): d["value"] = d["nodeValue"] = value d2 = self.childNodes[0].__dict__ d2["data"] = d2["nodeValue"] = value if self.ownerElement is not None: _clear_id_cache(self.ownerElement) elif name in ("name", "nodeName"): d["name"] = d["nodeName"] = value if self.ownerElement is not None: _clear_id_cache(self.ownerElement) else: d[name] = value def _set_prefix(self, prefix): nsuri = self.namespaceURI if prefix == "xmlns": if nsuri and nsuri != XMLNS_NAMESPACE: raise xml.dom.NamespaceErr( "illegal use of 'xmlns' prefix for the wrong namespace") d = self.__dict__ d['prefix'] = prefix if prefix is None: newName = self.localName else: newName = "%s:%s" % (prefix, self.localName) if self.ownerElement: _clear_id_cache(self.ownerElement) d['nodeName'] = d['name'] = newName def _set_value(self, value): d = self.__dict__ d['value'] = d['nodeValue'] = value if self.ownerElement: _clear_id_cache(self.ownerElement) self.childNodes[0].data = value def unlink(self): # This implementation does not call the base implementation # since most of that is not needed, and the expense of the # method call is not warranted. We duplicate the removal of # children, but that's all we needed from the base class. elem = self.ownerElement if elem is not None: del elem._attrs[self.nodeName] del elem._attrsNS[(self.namespaceURI, self.localName)] if self._is_id: self._is_id = False elem._magic_id_nodes -= 1 self.ownerDocument._magic_id_count -= 1 for child in self.childNodes: child.unlink() del self.childNodes[:] def _get_isId(self): if self._is_id: return True doc = self.ownerDocument elem = self.ownerElement if doc is None or elem is None: return False info = doc._get_elem_info(elem) if info is None: return False if self.namespaceURI: return info.isIdNS(self.namespaceURI, self.localName) else: return info.isId(self.nodeName) def _get_schemaType(self): doc = self.ownerDocument elem = self.ownerElement if doc is None or elem is None: return _no_type info = doc._get_elem_info(elem) if info is None: return _no_type if self.namespaceURI: return info.getAttributeTypeNS(self.namespaceURI, self.localName) else: return info.getAttributeType(self.nodeName) defproperty(Attr, "isId", doc="True if this attribute is an ID.") defproperty(Attr, "localName", doc="Namespace-local name of this attribute.") defproperty(Attr, "schemaType", doc="Schema type for this attribute.") class NamedNodeMap(object): """The attribute list is a transient interface to the underlying dictionaries. Mutations here will change the underlying element's dictionary. Ordering is imposed artificially and does not reflect the order of attributes as found in an input document. """ __slots__ = ('_attrs', '_attrsNS', '_ownerElement') def __init__(self, attrs, attrsNS, ownerElement): self._attrs = attrs self._attrsNS = attrsNS self._ownerElement = ownerElement def _get_length(self): return len(self._attrs) def item(self, index): try: return self[self._attrs.keys()[index]] except IndexError: return None def items(self): L = [] for node in self._attrs.values(): L.append((node.nodeName, node.value)) return L def itemsNS(self): L = [] for node in self._attrs.values(): L.append(((node.namespaceURI, node.localName), node.value)) return L def has_key(self, key): if isinstance(key, StringTypes): return key in self._attrs else: return key in self._attrsNS def keys(self): return self._attrs.keys() def keysNS(self): return self._attrsNS.keys() def values(self): return self._attrs.values() def get(self, name, value=None): return self._attrs.get(name, value) __len__ = _get_length __hash__ = None # Mutable type can't be correctly hashed def __cmp__(self, other): if self._attrs is getattr(other, "_attrs", None): return 0 else: return cmp(id(self), id(other)) def __getitem__(self, attname_or_tuple): if isinstance(attname_or_tuple, tuple): return self._attrsNS[attname_or_tuple] else: return self._attrs[attname_or_tuple] # same as set def __setitem__(self, attname, value): if isinstance(value, StringTypes): try: node = self._attrs[attname] except KeyError: node = Attr(attname) node.ownerDocument = self._ownerElement.ownerDocument self.setNamedItem(node) node.value = value else: if not isinstance(value, Attr): raise TypeError, "value must be a string or Attr object" node = value self.setNamedItem(node) def getNamedItem(self, name): try: return self._attrs[name] except KeyError: return None def getNamedItemNS(self, namespaceURI, localName): try: return self._attrsNS[(namespaceURI, localName)] except KeyError: return None def removeNamedItem(self, name): n = self.getNamedItem(name) if n is not None: _clear_id_cache(self._ownerElement) del self._attrs[n.nodeName] del self._attrsNS[(n.namespaceURI, n.localName)] if 'ownerElement' in n.__dict__: n.__dict__['ownerElement'] = None return n else: raise xml.dom.NotFoundErr() def removeNamedItemNS(self, namespaceURI, localName): n = self.getNamedItemNS(namespaceURI, localName) if n is not None: _clear_id_cache(self._ownerElement) del self._attrsNS[(n.namespaceURI, n.localName)] del self._attrs[n.nodeName] if 'ownerElement' in n.__dict__: n.__dict__['ownerElement'] = None return n else: raise xml.dom.NotFoundErr() def setNamedItem(self, node): if not isinstance(node, Attr): raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(node), repr(self))) old = self._attrs.get(node.name) if old: old.unlink() self._attrs[node.name] = node self._attrsNS[(node.namespaceURI, node.localName)] = node node.ownerElement = self._ownerElement _clear_id_cache(node.ownerElement) return old def setNamedItemNS(self, node): return self.setNamedItem(node) def __delitem__(self, attname_or_tuple): node = self[attname_or_tuple] _clear_id_cache(node.ownerElement) node.unlink() def __getstate__(self): return self._attrs, self._attrsNS, self._ownerElement def __setstate__(self, state): self._attrs, self._attrsNS, self._ownerElement = state defproperty(NamedNodeMap, "length", doc="Number of nodes in the NamedNodeMap.") AttributeList = NamedNodeMap class TypeInfo(object): __slots__ = 'namespace', 'name' def __init__(self, namespace, name): self.namespace = namespace self.name = name def __repr__(self): if self.namespace: return "" % (self.name, self.namespace) else: return "" % self.name def _get_name(self): return self.name def _get_namespace(self): return self.namespace _no_type = TypeInfo(None, None) class Element(Node): nodeType = Node.ELEMENT_NODE nodeValue = None schemaType = _no_type _magic_id_nodes = 0 _child_node_types = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) def __init__(self, tagName, namespaceURI=EMPTY_NAMESPACE, prefix=None, localName=None): self.tagName = self.nodeName = tagName self.prefix = prefix self.namespaceURI = namespaceURI self.childNodes = NodeList() self._attrs = {} # attributes are double-indexed: self._attrsNS = {} # tagName -> Attribute # URI,localName -> Attribute # in the future: consider lazy generation # of attribute objects this is too tricky # for now because of headaches with # namespaces. def _get_localName(self): return self.tagName.split(":", 1)[-1] def _get_tagName(self): return self.tagName def unlink(self): for attr in self._attrs.values(): attr.unlink() self._attrs = None self._attrsNS = None Node.unlink(self) def getAttribute(self, attname): try: return self._attrs[attname].value except KeyError: return "" def getAttributeNS(self, namespaceURI, localName): try: return self._attrsNS[(namespaceURI, localName)].value except KeyError: return "" def setAttribute(self, attname, value): attr = self.getAttributeNode(attname) if attr is None: attr = Attr(attname) # for performance d = attr.__dict__ d["value"] = d["nodeValue"] = value d["ownerDocument"] = self.ownerDocument self.setAttributeNode(attr) elif value != attr.value: d = attr.__dict__ d["value"] = d["nodeValue"] = value if attr.isId: _clear_id_cache(self) def setAttributeNS(self, namespaceURI, qualifiedName, value): prefix, localname = _nssplit(qualifiedName) attr = self.getAttributeNodeNS(namespaceURI, localname) if attr is None: # for performance attr = Attr(qualifiedName, namespaceURI, localname, prefix) d = attr.__dict__ d["prefix"] = prefix d["nodeName"] = qualifiedName d["value"] = d["nodeValue"] = value d["ownerDocument"] = self.ownerDocument self.setAttributeNode(attr) else: d = attr.__dict__ if value != attr.value: d["value"] = d["nodeValue"] = value if attr.isId: _clear_id_cache(self) if attr.prefix != prefix: d["prefix"] = prefix d["nodeName"] = qualifiedName def getAttributeNode(self, attrname): return self._attrs.get(attrname) def getAttributeNodeNS(self, namespaceURI, localName): return self._attrsNS.get((namespaceURI, localName)) def setAttributeNode(self, attr): if attr.ownerElement not in (None, self): raise xml.dom.InuseAttributeErr("attribute node already owned") old1 = self._attrs.get(attr.name, None) if old1 is not None: self.removeAttributeNode(old1) old2 = self._attrsNS.get((attr.namespaceURI, attr.localName), None) if old2 is not None and old2 is not old1: self.removeAttributeNode(old2) _set_attribute_node(self, attr) if old1 is not attr: # It might have already been part of this node, in which case # it doesn't represent a change, and should not be returned. return old1 if old2 is not attr: return old2 setAttributeNodeNS = setAttributeNode def removeAttribute(self, name): try: attr = self._attrs[name] except KeyError: raise xml.dom.NotFoundErr() self.removeAttributeNode(attr) def removeAttributeNS(self, namespaceURI, localName): try: attr = self._attrsNS[(namespaceURI, localName)] except KeyError: raise xml.dom.NotFoundErr() self.removeAttributeNode(attr) def removeAttributeNode(self, node): if node is None: raise xml.dom.NotFoundErr() try: self._attrs[node.name] except KeyError: raise xml.dom.NotFoundErr() _clear_id_cache(self) node.unlink() # Restore this since the node is still useful and otherwise # unlinked node.ownerDocument = self.ownerDocument removeAttributeNodeNS = removeAttributeNode def hasAttribute(self, name): return name in self._attrs def hasAttributeNS(self, namespaceURI, localName): return (namespaceURI, localName) in self._attrsNS def getElementsByTagName(self, name): return _get_elements_by_tagName_helper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName): return _get_elements_by_tagName_ns_helper( self, namespaceURI, localName, NodeList()) def __repr__(self): return "" % (self.tagName, id(self)) def writexml(self, writer, indent="", addindent="", newl=""): # indent = current indentation # addindent = indentation to add to higher levels # newl = newline string writer.write(indent+"<" + self.tagName) attrs = self._get_attributes() a_names = attrs.keys() a_names.sort() for a_name in a_names: writer.write(" %s=\"" % a_name) _write_data(writer, attrs[a_name].value) writer.write("\"") if self.childNodes: writer.write(">") if (len(self.childNodes) == 1 and self.childNodes[0].nodeType == Node.TEXT_NODE): self.childNodes[0].writexml(writer, '', '', '') else: writer.write(newl) for node in self.childNodes: node.writexml(writer, indent+addindent, addindent, newl) writer.write(indent) writer.write("%s" % (self.tagName, newl)) else: writer.write("/>%s"%(newl)) def _get_attributes(self): return NamedNodeMap(self._attrs, self._attrsNS, self) def hasAttributes(self): if self._attrs: return True else: return False # DOM Level 3 attributes, based on the 22 Oct 2002 draft def setIdAttribute(self, name): idAttr = self.getAttributeNode(name) self.setIdAttributeNode(idAttr) def setIdAttributeNS(self, namespaceURI, localName): idAttr = self.getAttributeNodeNS(namespaceURI, localName) self.setIdAttributeNode(idAttr) def setIdAttributeNode(self, idAttr): if idAttr is None or not self.isSameNode(idAttr.ownerElement): raise xml.dom.NotFoundErr() if _get_containing_entref(self) is not None: raise xml.dom.NoModificationAllowedErr() if not idAttr._is_id: idAttr.__dict__['_is_id'] = True self._magic_id_nodes += 1 self.ownerDocument._magic_id_count += 1 _clear_id_cache(self) defproperty(Element, "attributes", doc="NamedNodeMap of attributes on the element.") defproperty(Element, "localName", doc="Namespace-local name of this element.") def _set_attribute_node(element, attr): _clear_id_cache(element) element._attrs[attr.name] = attr element._attrsNS[(attr.namespaceURI, attr.localName)] = attr # This creates a circular reference, but Element.unlink() # breaks the cycle since the references to the attribute # dictionaries are tossed. attr.__dict__['ownerElement'] = element class Childless: """Mixin that makes childless-ness easy to implement and avoids the complexity of the Node methods that deal with children. """ attributes = None childNodes = EmptyNodeList() firstChild = None lastChild = None def _get_firstChild(self): return None def _get_lastChild(self): return None def appendChild(self, node): raise xml.dom.HierarchyRequestErr( self.nodeName + " nodes cannot have children") def hasChildNodes(self): return False def insertBefore(self, newChild, refChild): raise xml.dom.HierarchyRequestErr( self.nodeName + " nodes do not have children") def removeChild(self, oldChild): raise xml.dom.NotFoundErr( self.nodeName + " nodes do not have children") def normalize(self): # For childless nodes, normalize() has nothing to do. pass def replaceChild(self, newChild, oldChild): raise xml.dom.HierarchyRequestErr( self.nodeName + " nodes do not have children") class ProcessingInstruction(Childless, Node): nodeType = Node.PROCESSING_INSTRUCTION_NODE def __init__(self, target, data): self.target = self.nodeName = target self.data = self.nodeValue = data def _get_data(self): return self.data def _set_data(self, value): d = self.__dict__ d['data'] = d['nodeValue'] = value def _get_target(self): return self.target def _set_target(self, value): d = self.__dict__ d['target'] = d['nodeName'] = value def __setattr__(self, name, value): if name == "data" or name == "nodeValue": self.__dict__['data'] = self.__dict__['nodeValue'] = value elif name == "target" or name == "nodeName": self.__dict__['target'] = self.__dict__['nodeName'] = value else: self.__dict__[name] = value def writexml(self, writer, indent="", addindent="", newl=""): writer.write("%s%s" % (indent,self.target, self.data, newl)) class CharacterData(Childless, Node): def _get_length(self): return len(self.data) __len__ = _get_length def _get_data(self): return self.__dict__['data'] def _set_data(self, data): d = self.__dict__ d['data'] = d['nodeValue'] = data _get_nodeValue = _get_data _set_nodeValue = _set_data def __setattr__(self, name, value): if name == "data" or name == "nodeValue": self.__dict__['data'] = self.__dict__['nodeValue'] = value else: self.__dict__[name] = value def __repr__(self): data = self.data if len(data) > 10: dotdotdot = "..." else: dotdotdot = "" return '' % ( self.__class__.__name__, data[0:10], dotdotdot) def substringData(self, offset, count): if offset < 0: raise xml.dom.IndexSizeErr("offset cannot be negative") if offset >= len(self.data): raise xml.dom.IndexSizeErr("offset cannot be beyond end of data") if count < 0: raise xml.dom.IndexSizeErr("count cannot be negative") return self.data[offset:offset+count] def appendData(self, arg): self.data = self.data + arg def insertData(self, offset, arg): if offset < 0: raise xml.dom.IndexSizeErr("offset cannot be negative") if offset >= len(self.data): raise xml.dom.IndexSizeErr("offset cannot be beyond end of data") if arg: self.data = "%s%s%s" % ( self.data[:offset], arg, self.data[offset:]) def deleteData(self, offset, count): if offset < 0: raise xml.dom.IndexSizeErr("offset cannot be negative") if offset >= len(self.data): raise xml.dom.IndexSizeErr("offset cannot be beyond end of data") if count < 0: raise xml.dom.IndexSizeErr("count cannot be negative") if count: self.data = self.data[:offset] + self.data[offset+count:] def replaceData(self, offset, count, arg): if offset < 0: raise xml.dom.IndexSizeErr("offset cannot be negative") if offset >= len(self.data): raise xml.dom.IndexSizeErr("offset cannot be beyond end of data") if count < 0: raise xml.dom.IndexSizeErr("count cannot be negative") if count: self.data = "%s%s%s" % ( self.data[:offset], arg, self.data[offset+count:]) defproperty(CharacterData, "length", doc="Length of the string data.") class Text(CharacterData): # Make sure we don't add an instance __dict__ if we don't already # have one, at least when that's possible: # XXX this does not work, CharacterData is an old-style class # __slots__ = () nodeType = Node.TEXT_NODE nodeName = "#text" attributes = None def splitText(self, offset): if offset < 0 or offset > len(self.data): raise xml.dom.IndexSizeErr("illegal offset value") newText = self.__class__() newText.data = self.data[offset:] newText.ownerDocument = self.ownerDocument next = self.nextSibling if self.parentNode and self in self.parentNode.childNodes: if next is None: self.parentNode.appendChild(newText) else: self.parentNode.insertBefore(newText, next) self.data = self.data[:offset] return newText def writexml(self, writer, indent="", addindent="", newl=""): _write_data(writer, "%s%s%s" % (indent, self.data, newl)) # DOM Level 3 (WD 9 April 2002) def _get_wholeText(self): L = [self.data] n = self.previousSibling while n is not None: if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): L.insert(0, n.data) n = n.previousSibling else: break n = self.nextSibling while n is not None: if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): L.append(n.data) n = n.nextSibling else: break return ''.join(L) def replaceWholeText(self, content): # XXX This needs to be seriously changed if minidom ever # supports EntityReference nodes. parent = self.parentNode n = self.previousSibling while n is not None: if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): next = n.previousSibling parent.removeChild(n) n = next else: break n = self.nextSibling if not content: parent.removeChild(self) while n is not None: if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): next = n.nextSibling parent.removeChild(n) n = next else: break if content: d = self.__dict__ d['data'] = content d['nodeValue'] = content return self else: return None def _get_isWhitespaceInElementContent(self): if self.data.strip(): return False elem = _get_containing_element(self) if elem is None: return False info = self.ownerDocument._get_elem_info(elem) if info is None: return False else: return info.isElementContent() defproperty(Text, "isWhitespaceInElementContent", doc="True iff this text node contains only whitespace" " and is in element content.") defproperty(Text, "wholeText", doc="The text of all logically-adjacent text nodes.") def _get_containing_element(node): c = node.parentNode while c is not None: if c.nodeType == Node.ELEMENT_NODE: return c c = c.parentNode return None def _get_containing_entref(node): c = node.parentNode while c is not None: if c.nodeType == Node.ENTITY_REFERENCE_NODE: return c c = c.parentNode return None class Comment(Childless, CharacterData): nodeType = Node.COMMENT_NODE nodeName = "#comment" def __init__(self, data): self.data = self.nodeValue = data def writexml(self, writer, indent="", addindent="", newl=""): if "--" in self.data: raise ValueError("'--' is not allowed in a comment node") writer.write("%s%s" % (indent, self.data, newl)) class CDATASection(Text): # Make sure we don't add an instance __dict__ if we don't already # have one, at least when that's possible: # XXX this does not work, Text is an old-style class # __slots__ = () nodeType = Node.CDATA_SECTION_NODE nodeName = "#cdata-section" def writexml(self, writer, indent="", addindent="", newl=""): if self.data.find("]]>") >= 0: raise ValueError("']]>' not allowed in a CDATA section") writer.write("" % self.data) class ReadOnlySequentialNamedNodeMap(object): __slots__ = '_seq', def __init__(self, seq=()): # seq should be a list or tuple self._seq = seq def __len__(self): return len(self._seq) def _get_length(self): return len(self._seq) def getNamedItem(self, name): for n in self._seq: if n.nodeName == name: return n def getNamedItemNS(self, namespaceURI, localName): for n in self._seq: if n.namespaceURI == namespaceURI and n.localName == localName: return n def __getitem__(self, name_or_tuple): if isinstance(name_or_tuple, tuple): node = self.getNamedItemNS(*name_or_tuple) else: node = self.getNamedItem(name_or_tuple) if node is None: raise KeyError, name_or_tuple return node def item(self, index): if index < 0: return None try: return self._seq[index] except IndexError: return None def removeNamedItem(self, name): raise xml.dom.NoModificationAllowedErr( "NamedNodeMap instance is read-only") def removeNamedItemNS(self, namespaceURI, localName): raise xml.dom.NoModificationAllowedErr( "NamedNodeMap instance is read-only") def setNamedItem(self, node): raise xml.dom.NoModificationAllowedErr( "NamedNodeMap instance is read-only") def setNamedItemNS(self, node): raise xml.dom.NoModificationAllowedErr( "NamedNodeMap instance is read-only") def __getstate__(self): return [self._seq] def __setstate__(self, state): self._seq = state[0] defproperty(ReadOnlySequentialNamedNodeMap, "length", doc="Number of entries in the NamedNodeMap.") class Identified: """Mix-in class that supports the publicId and systemId attributes.""" # XXX this does not work, this is an old-style class # __slots__ = 'publicId', 'systemId' def _identified_mixin_init(self, publicId, systemId): self.publicId = publicId self.systemId = systemId def _get_publicId(self): return self.publicId def _get_systemId(self): return self.systemId class DocumentType(Identified, Childless, Node): nodeType = Node.DOCUMENT_TYPE_NODE nodeValue = None name = None publicId = None systemId = None internalSubset = None def __init__(self, qualifiedName): self.entities = ReadOnlySequentialNamedNodeMap() self.notations = ReadOnlySequentialNamedNodeMap() if qualifiedName: prefix, localname = _nssplit(qualifiedName) self.name = localname self.nodeName = self.name def _get_internalSubset(self): return self.internalSubset def cloneNode(self, deep): if self.ownerDocument is None: # it's ok clone = DocumentType(None) clone.name = self.name clone.nodeName = self.name operation = xml.dom.UserDataHandler.NODE_CLONED if deep: clone.entities._seq = [] clone.notations._seq = [] for n in self.notations._seq: notation = Notation(n.nodeName, n.publicId, n.systemId) clone.notations._seq.append(notation) n._call_user_data_handler(operation, n, notation) for e in self.entities._seq: entity = Entity(e.nodeName, e.publicId, e.systemId, e.notationName) entity.actualEncoding = e.actualEncoding entity.encoding = e.encoding entity.version = e.version clone.entities._seq.append(entity) e._call_user_data_handler(operation, e, entity) self._call_user_data_handler(operation, self, clone) return clone else: return None def writexml(self, writer, indent="", addindent="", newl=""): writer.write(""+newl) class Entity(Identified, Node): attributes = None nodeType = Node.ENTITY_NODE nodeValue = None actualEncoding = None encoding = None version = None def __init__(self, name, publicId, systemId, notation): self.nodeName = name self.notationName = notation self.childNodes = NodeList() self._identified_mixin_init(publicId, systemId) def _get_actualEncoding(self): return self.actualEncoding def _get_encoding(self): return self.encoding def _get_version(self): return self.version def appendChild(self, newChild): raise xml.dom.HierarchyRequestErr( "cannot append children to an entity node") def insertBefore(self, newChild, refChild): raise xml.dom.HierarchyRequestErr( "cannot insert children below an entity node") def removeChild(self, oldChild): raise xml.dom.HierarchyRequestErr( "cannot remove children from an entity node") def replaceChild(self, newChild, oldChild): raise xml.dom.HierarchyRequestErr( "cannot replace children of an entity node") class Notation(Identified, Childless, Node): nodeType = Node.NOTATION_NODE nodeValue = None def __init__(self, name, publicId, systemId): self.nodeName = name self._identified_mixin_init(publicId, systemId) class DOMImplementation(DOMImplementationLS): _features = [("core", "1.0"), ("core", "2.0"), ("core", None), ("xml", "1.0"), ("xml", "2.0"), ("xml", None), ("ls-load", "3.0"), ("ls-load", None), ] def hasFeature(self, feature, version): if version == "": version = None return (feature.lower(), version) in self._features def createDocument(self, namespaceURI, qualifiedName, doctype): if doctype and doctype.parentNode is not None: raise xml.dom.WrongDocumentErr( "doctype object owned by another DOM tree") doc = self._create_document() add_root_element = not (namespaceURI is None and qualifiedName is None and doctype is None) if not qualifiedName and add_root_element: # The spec is unclear what to raise here; SyntaxErr # would be the other obvious candidate. Since Xerces raises # InvalidCharacterErr, and since SyntaxErr is not listed # for createDocument, that seems to be the better choice. # XXX: need to check for illegal characters here and in # createElement. # DOM Level III clears this up when talking about the return value # of this function. If namespaceURI, qName and DocType are # Null the document is returned without a document element # Otherwise if doctype or namespaceURI are not None # Then we go back to the above problem raise xml.dom.InvalidCharacterErr("Element with no name") if add_root_element: prefix, localname = _nssplit(qualifiedName) if prefix == "xml" \ and namespaceURI != "http://www.w3.org/XML/1998/namespace": raise xml.dom.NamespaceErr("illegal use of 'xml' prefix") if prefix and not namespaceURI: raise xml.dom.NamespaceErr( "illegal use of prefix without namespaces") element = doc.createElementNS(namespaceURI, qualifiedName) if doctype: doc.appendChild(doctype) doc.appendChild(element) if doctype: doctype.parentNode = doctype.ownerDocument = doc doc.doctype = doctype doc.implementation = self return doc def createDocumentType(self, qualifiedName, publicId, systemId): doctype = DocumentType(qualifiedName) doctype.publicId = publicId doctype.systemId = systemId return doctype # DOM Level 3 (WD 9 April 2002) def getInterface(self, feature): if self.hasFeature(feature, None): return self else: return None # internal def _create_document(self): return Document() class ElementInfo(object): """Object that represents content-model information for an element. This implementation is not expected to be used in practice; DOM builders should provide implementations which do the right thing using information available to it. """ __slots__ = 'tagName', def __init__(self, name): self.tagName = name def getAttributeType(self, aname): return _no_type def getAttributeTypeNS(self, namespaceURI, localName): return _no_type def isElementContent(self): return False def isEmpty(self): """Returns true iff this element is declared to have an EMPTY content model.""" return False def isId(self, aname): """Returns true iff the named attribute is a DTD-style ID.""" return False def isIdNS(self, namespaceURI, localName): """Returns true iff the identified attribute is a DTD-style ID.""" return False def __getstate__(self): return self.tagName def __setstate__(self, state): self.tagName = state def _clear_id_cache(node): if node.nodeType == Node.DOCUMENT_NODE: node._id_cache.clear() node._id_search_stack = None elif _in_document(node): node.ownerDocument._id_cache.clear() node.ownerDocument._id_search_stack= None class Document(Node, DocumentLS): _child_node_types = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.DOCUMENT_TYPE_NODE) nodeType = Node.DOCUMENT_NODE nodeName = "#document" nodeValue = None attributes = None doctype = None parentNode = None previousSibling = nextSibling = None implementation = DOMImplementation() # Document attributes from Level 3 (WD 9 April 2002) actualEncoding = None encoding = None standalone = None version = None strictErrorChecking = False errorHandler = None documentURI = None _magic_id_count = 0 def __init__(self): self.childNodes = NodeList() # mapping of (namespaceURI, localName) -> ElementInfo # and tagName -> ElementInfo self._elem_info = {} self._id_cache = {} self._id_search_stack = None def _get_elem_info(self, element): if element.namespaceURI: key = element.namespaceURI, element.localName else: key = element.tagName return self._elem_info.get(key) def _get_actualEncoding(self): return self.actualEncoding def _get_doctype(self): return self.doctype def _get_documentURI(self): return self.documentURI def _get_encoding(self): return self.encoding def _get_errorHandler(self): return self.errorHandler def _get_standalone(self): return self.standalone def _get_strictErrorChecking(self): return self.strictErrorChecking def _get_version(self): return self.version def appendChild(self, node): if node.nodeType not in self._child_node_types: raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(node), repr(self))) if node.parentNode is not None: # This needs to be done before the next test since this # may *be* the document element, in which case it should # end up re-ordered to the end. node.parentNode.removeChild(node) if node.nodeType == Node.ELEMENT_NODE \ and self._get_documentElement(): raise xml.dom.HierarchyRequestErr( "two document elements disallowed") return Node.appendChild(self, node) def removeChild(self, oldChild): try: self.childNodes.remove(oldChild) except ValueError: raise xml.dom.NotFoundErr() oldChild.nextSibling = oldChild.previousSibling = None oldChild.parentNode = None if self.documentElement is oldChild: self.documentElement = None return oldChild def _get_documentElement(self): for node in self.childNodes: if node.nodeType == Node.ELEMENT_NODE: return node def unlink(self): if self.doctype is not None: self.doctype.unlink() self.doctype = None Node.unlink(self) def cloneNode(self, deep): if not deep: return None clone = self.implementation.createDocument(None, None, None) clone.encoding = self.encoding clone.standalone = self.standalone clone.version = self.version for n in self.childNodes: childclone = _clone_node(n, deep, clone) assert childclone.ownerDocument.isSameNode(clone) clone.childNodes.append(childclone) if childclone.nodeType == Node.DOCUMENT_NODE: assert clone.documentElement is None elif childclone.nodeType == Node.DOCUMENT_TYPE_NODE: assert clone.doctype is None clone.doctype = childclone childclone.parentNode = clone self._call_user_data_handler(xml.dom.UserDataHandler.NODE_CLONED, self, clone) return clone def createDocumentFragment(self): d = DocumentFragment() d.ownerDocument = self return d def createElement(self, tagName): e = Element(tagName) e.ownerDocument = self return e def createTextNode(self, data): if not isinstance(data, StringTypes): raise TypeError, "node contents must be a string" t = Text() t.data = data t.ownerDocument = self return t def createCDATASection(self, data): if not isinstance(data, StringTypes): raise TypeError, "node contents must be a string" c = CDATASection() c.data = data c.ownerDocument = self return c def createComment(self, data): c = Comment(data) c.ownerDocument = self return c def createProcessingInstruction(self, target, data): p = ProcessingInstruction(target, data) p.ownerDocument = self return p def createAttribute(self, qName): a = Attr(qName) a.ownerDocument = self a.value = "" return a def createElementNS(self, namespaceURI, qualifiedName): prefix, localName = _nssplit(qualifiedName) e = Element(qualifiedName, namespaceURI, prefix) e.ownerDocument = self return e def createAttributeNS(self, namespaceURI, qualifiedName): prefix, localName = _nssplit(qualifiedName) a = Attr(qualifiedName, namespaceURI, localName, prefix) a.ownerDocument = self a.value = "" return a # A couple of implementation-specific helpers to create node types # not supported by the W3C DOM specs: def _create_entity(self, name, publicId, systemId, notationName): e = Entity(name, publicId, systemId, notationName) e.ownerDocument = self return e def _create_notation(self, name, publicId, systemId): n = Notation(name, publicId, systemId) n.ownerDocument = self return n def getElementById(self, id): if id in self._id_cache: return self._id_cache[id] if not (self._elem_info or self._magic_id_count): return None stack = self._id_search_stack if stack is None: # we never searched before, or the cache has been cleared stack = [self.documentElement] self._id_search_stack = stack elif not stack: # Previous search was completed and cache is still valid; # no matching node. return None result = None while stack: node = stack.pop() # add child elements to stack for continued searching stack.extend([child for child in node.childNodes if child.nodeType in _nodeTypes_with_children]) # check this node info = self._get_elem_info(node) if info: # We have to process all ID attributes before # returning in order to get all the attributes set to # be IDs using Element.setIdAttribute*(). for attr in node.attributes.values(): if attr.namespaceURI: if info.isIdNS(attr.namespaceURI, attr.localName): self._id_cache[attr.value] = node if attr.value == id: result = node elif not node._magic_id_nodes: break elif info.isId(attr.name): self._id_cache[attr.value] = node if attr.value == id: result = node elif not node._magic_id_nodes: break elif attr._is_id: self._id_cache[attr.value] = node if attr.value == id: result = node elif node._magic_id_nodes == 1: break elif node._magic_id_nodes: for attr in node.attributes.values(): if attr._is_id: self._id_cache[attr.value] = node if attr.value == id: result = node if result is not None: break return result def getElementsByTagName(self, name): return _get_elements_by_tagName_helper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName): return _get_elements_by_tagName_ns_helper( self, namespaceURI, localName, NodeList()) def isSupported(self, feature, version): return self.implementation.hasFeature(feature, version) def importNode(self, node, deep): if node.nodeType == Node.DOCUMENT_NODE: raise xml.dom.NotSupportedErr("cannot import document nodes") elif node.nodeType == Node.DOCUMENT_TYPE_NODE: raise xml.dom.NotSupportedErr("cannot import document type nodes") return _clone_node(node, deep, self) def writexml(self, writer, indent="", addindent="", newl="", encoding = None): if encoding is None: writer.write(''+newl) else: writer.write('%s' % (encoding, newl)) for node in self.childNodes: node.writexml(writer, indent, addindent, newl) # DOM Level 3 (WD 9 April 2002) def renameNode(self, n, namespaceURI, name): if n.ownerDocument is not self: raise xml.dom.WrongDocumentErr( "cannot rename nodes from other documents;\n" "expected %s,\nfound %s" % (self, n.ownerDocument)) if n.nodeType not in (Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE): raise xml.dom.NotSupportedErr( "renameNode() only applies to element and attribute nodes") if namespaceURI != EMPTY_NAMESPACE: if ':' in name: prefix, localName = name.split(':', 1) if ( prefix == "xmlns" and namespaceURI != xml.dom.XMLNS_NAMESPACE): raise xml.dom.NamespaceErr( "illegal use of 'xmlns' prefix") else: if ( name == "xmlns" and namespaceURI != xml.dom.XMLNS_NAMESPACE and n.nodeType == Node.ATTRIBUTE_NODE): raise xml.dom.NamespaceErr( "illegal use of the 'xmlns' attribute") prefix = None localName = name else: prefix = None localName = None if n.nodeType == Node.ATTRIBUTE_NODE: element = n.ownerElement if element is not None: is_id = n._is_id element.removeAttributeNode(n) else: element = None # avoid __setattr__ d = n.__dict__ d['prefix'] = prefix d['localName'] = localName d['namespaceURI'] = namespaceURI d['nodeName'] = name if n.nodeType == Node.ELEMENT_NODE: d['tagName'] = name else: # attribute node d['name'] = name if element is not None: element.setAttributeNode(n) if is_id: element.setIdAttributeNode(n) # It's not clear from a semantic perspective whether we should # call the user data handlers for the NODE_RENAMED event since # we're re-using the existing node. The draft spec has been # interpreted as meaning "no, don't call the handler unless a # new node is created." return n defproperty(Document, "documentElement", doc="Top-level element of this document.") def _clone_node(node, deep, newOwnerDocument): """ Clone a node and give it the new owner document. Called by Node.cloneNode and Document.importNode """ if node.ownerDocument.isSameNode(newOwnerDocument): operation = xml.dom.UserDataHandler.NODE_CLONED else: operation = xml.dom.UserDataHandler.NODE_IMPORTED if node.nodeType == Node.ELEMENT_NODE: clone = newOwnerDocument.createElementNS(node.namespaceURI, node.nodeName) for attr in node.attributes.values(): clone.setAttributeNS(attr.namespaceURI, attr.nodeName, attr.value) a = clone.getAttributeNodeNS(attr.namespaceURI, attr.localName) a.specified = attr.specified if deep: for child in node.childNodes: c = _clone_node(child, deep, newOwnerDocument) clone.appendChild(c) elif node.nodeType == Node.DOCUMENT_FRAGMENT_NODE: clone = newOwnerDocument.createDocumentFragment() if deep: for child in node.childNodes: c = _clone_node(child, deep, newOwnerDocument) clone.appendChild(c) elif node.nodeType == Node.TEXT_NODE: clone = newOwnerDocument.createTextNode(node.data) elif node.nodeType == Node.CDATA_SECTION_NODE: clone = newOwnerDocument.createCDATASection(node.data) elif node.nodeType == Node.PROCESSING_INSTRUCTION_NODE: clone = newOwnerDocument.createProcessingInstruction(node.target, node.data) elif node.nodeType == Node.COMMENT_NODE: clone = newOwnerDocument.createComment(node.data) elif node.nodeType == Node.ATTRIBUTE_NODE: clone = newOwnerDocument.createAttributeNS(node.namespaceURI, node.nodeName) clone.specified = True clone.value = node.value elif node.nodeType == Node.DOCUMENT_TYPE_NODE: assert node.ownerDocument is not newOwnerDocument operation = xml.dom.UserDataHandler.NODE_IMPORTED clone = newOwnerDocument.implementation.createDocumentType( node.name, node.publicId, node.systemId) clone.ownerDocument = newOwnerDocument if deep: clone.entities._seq = [] clone.notations._seq = [] for n in node.notations._seq: notation = Notation(n.nodeName, n.publicId, n.systemId) notation.ownerDocument = newOwnerDocument clone.notations._seq.append(notation) if hasattr(n, '_call_user_data_handler'): n._call_user_data_handler(operation, n, notation) for e in node.entities._seq: entity = Entity(e.nodeName, e.publicId, e.systemId, e.notationName) entity.actualEncoding = e.actualEncoding entity.encoding = e.encoding entity.version = e.version entity.ownerDocument = newOwnerDocument clone.entities._seq.append(entity) if hasattr(e, '_call_user_data_handler'): e._call_user_data_handler(operation, e, entity) else: # Note the cloning of Document and DocumentType nodes is # implementation specific. minidom handles those cases # directly in the cloneNode() methods. raise xml.dom.NotSupportedErr("Cannot clone node %s" % repr(node)) # Check for _call_user_data_handler() since this could conceivably # used with other DOM implementations (one of the FourThought # DOMs, perhaps?). if hasattr(node, '_call_user_data_handler'): node._call_user_data_handler(operation, node, clone) return clone def _nssplit(qualifiedName): fields = qualifiedName.split(':', 1) if len(fields) == 2: return fields else: return (None, fields[0]) def _get_StringIO(): # we can't use cStringIO since it doesn't support Unicode strings from StringIO import StringIO return StringIO() def _do_pulldom_parse(func, args, kwargs): events = func(*args, **kwargs) toktype, rootNode = events.getEvent() events.expandNode(rootNode) events.clear() return rootNode def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize: from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize}) def parseString(string, parser=None): """Parse a file into a DOM from a string.""" if parser is None: from xml.dom import expatbuilder return expatbuilder.parseString(string) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parseString, (string,), {'parser': parser}) def getDOMImplementation(features=None): if features: if isinstance(features, StringTypes): features = domreg._parse_feature_string(features) for f, v in features: if not Document.implementation.hasFeature(f, v): return None return Document.implementation PK:©ç\tÕm3Ù Ù dom/minidom.pycnu„[µü¤ó ›V~gc@sdZddlZddlmZmZmZmZddlTddlm Z m Z ej j j ej j jfZdej j fd„ƒYZ ee dd d ƒee d d d ƒee d d dƒd„Zd„Zd„Zd„Zd„Zde fd„ƒYZde fd„ƒYZeedd dƒeed d dƒeedd dƒdefd„ƒYZeedd d ƒeZd!efd"„ƒYZeeeƒZd#e fd$„ƒYZeed%d d&ƒeed d d'ƒd(„Zd)fd*„ƒYZ d+e e fd,„ƒYZ!d-e e fd.„ƒYZ"ee"dd d/ƒd0e"fd1„ƒYZ#ee#d2d d3ƒee#d4d d5ƒd6„Z$d7„Z%d8e e"fd9„ƒYZ&d:e#fd;„ƒYZ'd<efd=„ƒYZ(ee(dd d>ƒd?fd@„ƒYZ)dAe)e e fdB„ƒYZ*dCe)e fdD„ƒYZ+dEe)e e fdF„ƒYZ,dGe fdH„ƒYZ-dIefdJ„ƒYZ.dK„Z/dLe e fdM„ƒYZ0ee0dNd dOƒdP„Z1dQ„Z2dR„Z3dS„Z4eedT„Z5edU„Z6edV„Z7dS(WscSimple implementation of the Level 1 DOM. Namespaces and other minor Level 2 features are also supported. parse("foo.xml") parseString("") Todo: ===== * convenience methods for getting elements and text. * more testing * bring some of the writer and linearizer code into conformance with this interface * SAX 2 namespaces iÿÿÿÿN(tEMPTY_NAMESPACEt EMPTY_PREFIXtXMLNS_NAMESPACEtdomreg(t*(tDOMImplementationLSt DocumentLStNodecBsõeZdZdZdZdZdZeZ d„Z dd„Z dddd„Z d„Z d„Zd„Zd„Zd „Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cCstS(N(tTrue(tself((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt __nonzero__*scCs|jdd|ƒS(Nt(t toprettyxml(R tencoding((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyttoxml-ss s cCs‹tƒ}|dk r=ddl}|j|ƒd|ƒ}n|jtjkrk|j|d|||ƒn|j|d||ƒ|jƒS(NiÿÿÿÿiR ( t _get_StringIOtNonetcodecstlookuptnodeTypeRt DOCUMENT_NODEtwritexmltgetvalue(R tindenttnewlR twriterR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR 0s   cCs|jr tStSdS(N(t childNodesRtFalse(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt hasChildNodes?s cCs|jS(N(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_childNodesEscCs|jr|jdSdS(Ni(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_firstChildHs cCs|jr|jdSdS(Niÿÿÿÿ(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_lastChildLs cCsw|j|jkr@x't|jƒD]}|j||ƒq"W|S|j|jkr}tjjdt |ƒt |ƒfƒ‚n|j dk rŸ|j j |ƒn|dkr»|j |ƒn¸y|jj|ƒ}Wn tk rótjjƒ‚nX|jtkrt|ƒn|jj||ƒ||_||_|ra|j|d}||_||_n d|_||_ |S(Ns%s cannot be child of %si(RtDOCUMENT_FRAGMENT_NODEttupleRt insertBeforet_child_node_typestxmltdomtHierarchyRequestErrtreprt parentNodeRt removeChildt appendChildtindext ValueErrort NotFoundErrt_nodeTypes_with_childrent_clear_id_cachetinsertt nextSiblingtpreviousSibling(R tnewChildtrefChildtcR+tnode((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR"Ps6 "         cCsÒ|j|jkr=x$t|jƒD]}|j|ƒq"W|S|j|jkrztjjdt |ƒt |ƒfƒ‚n|jt kr–t |ƒn|j dk r¸|j j|ƒnt||ƒd|_|S(Ns%s cannot be child of %s(RR R!RR*R#R$R%R&R'R.R/R(RR)t _append_childR1(R R6R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR*ps "   cCsˆ|j|jkr8|j}|j|ƒ|j||ƒS|j|jkrutjjdt |ƒt |ƒfƒ‚n||kr…dS|j dk r§|j j|ƒny|j j |ƒ}Wn tk rßtjjƒ‚nX||j |<||_ d|_ |jtks|jtkr*t|ƒn|j|_|j|_d|_d|_|jrl||j_n|jr„||j_n|S(Ns%s cannot be child of %s(RR R1R)R"R#R$R%R&R'R(RRR+R,R-R.R/R2(R R3toldChildR4R+((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt replaceChild�s<   "            cCs²y|jj|ƒWn tk r6tjjƒ‚nX|jdk rX|j|j_n|jdk ry|j|j_nd|_|_|j t kr¥t |ƒnd|_ |S(N( RtremoveR,R$R%R-R1RR2RR.R/R((R R8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR)¡s   cCs*g}x|jD]}|jtjkrì|jsr|rJ|j|d_n|jre|j|j_n|jƒq|rÜ|dj|jkrÜ|d}|j|j|_|j|_|jrÏ||j_n|jƒq|j|ƒq|j|ƒ|jtj kr|j ƒqqW||j(dS(Niÿÿÿÿ( RRRt TEXT_NODEtdataR1R2tunlinktappendt ELEMENT_NODEt normalize(R tLtchildR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR@±s*        cCst|||jp|ƒS(N(t _clone_nodet ownerDocument(R tdeep((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt cloneNodeÌscCs|jjj||ƒS(N(RDtimplementationt hasFeature(R tfeaturetversion((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt isSupportedÏscCsdS(N(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_localNameÒscCs ||kS(N((R tother((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt isSameNodeØscCs|j|dƒr|SdSdS(N(RKR(R RI((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt getInterfaceÛscCs2y|j|dSWnttfk r-dSXdS(Ni(t _user_datatAttributeErrortKeyErrorR(R tkey((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt getUserDataåscCs’d}y |j}Wn tk r5i}||_nX||krS||d}n|dkr~d}|dk rŽ||=qŽn||f||<|S(Ni(RRPRQ(R RSR<thandlertoldtd((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt setUserDataës       cCsdt|dƒr`xN|jjƒD]:\}\}}|dk r|j|||||ƒqqWndS(NRP(thasattrRPtitemsRthandle(R t operationtsrctdstRSR<RU((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_call_user_data_handlerýs" cCs\d|_|_|jrFx|jD]}|jƒq#Wtƒ|_nd|_d|_dS(N(RR(RDRR=tNodeListR2R1(R RB((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR=s  N(t__name__t __module__Rt namespaceURIR(RDR1R2RtprefixR RR RRRRR"R*R9R)R@RFRKRLRNRORTRXR_R=(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR!s6                t firstChildtdocsFirst child node, or None.t lastChildsLast child node, or None.t localNames"Namespace-local name of this node.cCsT|j}|r6|d}||jd<||jd(R R6Rtlast((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR7s    cCs6x/|dk r1|jtjkr%tS|j}qWtS(N(RRRRRR(R(R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _in_documents  cCsP|rL|jddƒjddƒjddƒjddƒ}|j|ƒnd S( sWrites datachars to writer.t&s&ts>N(treplacetwrite(RR<((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _write_data%scCsex^|jD]S}|jtjkrM|dks=|j|krM|j|ƒnt|||ƒq W|S(NR(RRRR?ttagNameR>t_get_elements_by_tagName_helper(tparenttnametrcR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRs,s cCs†x|jD]t}|jtjkr |dks=|j|krh|dksX|j|krh|j|ƒnt||||ƒq q W|S(NR(RRRR?RhRcR>t"_get_elements_by_tagName_ns_helper(RttnsURIRhRvR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRw4stDocumentFragmentcBsbeZejZdZdZdZdZ ej ej ej ej ejejejfZd„ZRS(s#document-fragmentcCstƒ|_dS(N(R`R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt__init__KsN(RaRbRR RtnodeNameRt nodeValuet attributesR(R?R;tCDATA_SECTION_NODEtENTITY_REFERENCE_NODEtPROCESSING_INSTRUCTION_NODEt COMMENT_NODEt NOTATION_NODER#Rz(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRy=s  tAttrcBs•eZejZd Zd ZeZ eZ ej ej fZ ed d d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS( cCsS|j}||d<|d<||d<||dtText(R tqNameRcRhRdRW((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRzXs     cCs|jjddƒdS(Nt:iiÿÿÿÿ(R{tsplit(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRLfscCs|jS(N(t specified(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_specifiediscCs¹|j}|dkrk||d<|d<|jdj}||d<|d<|jdk rµt|jƒqµnJ|dkr«||d<|d<|jdk rµt|jƒqµn |||R{RŠ(R RAR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRZßscCsFg}x9|jjƒD](}|j|j|jf|jfƒqW|S(N(R”R®R>RcRhRŠ(R RAR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytitemsNSås&cCs-t|tƒr||jkS||jkSdS(N(t isinstancet StringTypesR”R•(R RS((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pythas_keyës cCs |jjƒS(N(R”R«(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR«ñscCs |jjƒS(N(R•R«(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytkeysNSôscCs |jjƒS(N(R”R®(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR®÷scCs|jj||ƒS(N(R”tget(R RuRŠ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR´úscCs<|jt|ddƒkrdStt|ƒt|ƒƒSdS(NR”i(R”tgetattrRtcmptid(R RM((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt__cmp__scCs)t|tƒr|j|S|j|SdS(N(R°R!R•R”(R tattname_or_tuple((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt __getitem__s cCsšt|tƒrhy|j|}Wn9tk r[t|ƒ}|jj|_|j|ƒnX||_n.t|tƒsƒt d‚n|}|j|ƒdS(Ns%value must be a string or Attr object( R°R±R”RRRƒR¦RDt setNamedItemRŠt TypeError(R tattnameRŠR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt __setitem__ s    cCs(y|j|SWntk r#dSXdS(N(R”RRR(R Ru((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt getNamedItems cCs.y|j||fSWntk r)dSXdS(N(R•RRR(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytgetNamedItemNS"s cCs�|j|ƒ}|dk rnt|jƒ|j|j=|j|j|jf=d|j krjd|j ds (RÏRu(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt__repr__hs cCs|jS(N(Ru(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_namenscCs|jS(N(RÏ(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_namespaceqs(RÏRu(RaRbRÊRzRÐRÑRÒ(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÎas    tElementcBsLeZejZdZeZdZ ejej ej ej ej ejfZeddd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd „Zd „Zd „ZeZd „Zd „Zd„ZeZ d„Z!d„Z"d„Z#d„Z$d„Z%dddd„Z&d„Z'd„Z(d„Z)d„Z*d„Z+RS(icCsD||_|_||_||_tƒ|_i|_i|_dS(N(RrR{RdRcR`RR”R•(R RrRcRdRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRz„s     cCs|jjddƒdS(NR†iiÿÿÿÿ(RrR‡(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRL“scCs|jS(N(Rr(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_tagName–scCsGx!|jjƒD]}|jƒqWd|_d|_tj|ƒdS(N(R”R®R=RR•R(R tattr((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR=™s   cCs+y|j|jSWntk r&dSXdS(NR (R”RŠRR(R R½((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt getAttribute s cCs1y|j||fjSWntk r,dSXdS(NR (R•RŠRR(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytgetAttributeNS¦s cCs¦|j|ƒ}|dkr_t|ƒ}|j}||d<|d<|j|d<|j|ƒnC||jkr¢|j}||d<|d<|jr¢t|ƒq¢ndS(NRŠR|RD( tgetAttributeNodeRRƒRiRDtsetAttributeNodeRŠRœR/(R R½RŠRÕRW((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt setAttribute¬s      cCsþt|ƒ\}}|j||ƒ}|dkr‘t||||ƒ}|j}||d<||d<||d<|d<|j|d<|j|ƒni|j}||jkrÔ||d<|d<|jrÔt |ƒqÔn|j |krú||d<||d(RrR·(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÐsR c Cs[|j|d|jƒ|jƒ}|jƒ}|jƒx@|D]8}|jd|ƒt|||jƒ|jdƒqAW|jrF|jdƒt|jƒdkrá|jdj t j krá|jdj |dddƒnH|j|ƒx+|jD] }|j |||||ƒqøW|j|ƒ|jd|j|fƒn|jd |ƒdS( NRms %s="s"RniiR s%ss/>%s( RpRrt_get_attributesR«tsortRqRŠRR©RRR;R( R RRt addindentRR§ta_namesta_nameR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRs&         cCst|j|j|ƒS(N(R¥R”R•(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRì4scCs|jr tStSdS(N(R”RR(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt hasAttributes7s cCs |j|ƒ}|j|ƒdS(N(RØtsetIdAttributeNode(R RutidAttr((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytsetIdAttribute?scCs#|j||ƒ}|j|ƒdS(N(RÜRò(R RcRhRó((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytsetIdAttributeNSCscCs�|dks|j|jƒ r1tjjƒ‚nt|ƒdk rUtjjƒ‚n|js™t |j d<|j d7_ |j j d7_ t|ƒndS(NR–i(RRNR‹R$R%R-t_get_containing_entreftNoModificationAllowedErrR–RRiR—RDR˜R/(R Ró((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRòGs  N(,RaRbRR?RRR|RŸR¤R—R€R�R;R~RR#RRzRLRÔR=RÖR×RÚRßRØRÜRÙtsetAttributeNodeNSRæRçRâtremoveAttributeNodeNSRèRéRêRëRÐRRìRñRôRõRò(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÓvsL                         R}s*NamedNodeMap of attributes on the element.s%Namespace-local name of this element.cCsDt|ƒ||j|j<||j|j|jf<||jd%s(RpRþR<(R RRRîR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR¦s( RaRbRR€RRzRÿRRRR�R(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRý‹s       t CharacterDatacBsteZd„ZeZd„Zd„ZeZeZd„Zd„Z d„Z d„Z d„Z d„Z d „ZRS( cCs t|jƒS(N(R©R<(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRª«scCs |jdS(NR<(Ri(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÿ¯scCs|j}||d<|di(R<R©t __class__Ra(R R<t dotdotdot((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRоs   cCs~|dkr!tjjdƒ‚n|t|jƒkrKtjjdƒ‚n|dkrltjjdƒ‚n|j|||!S(Nisoffset cannot be negatives#offset cannot be beyond end of datascount cannot be negative(R$R%t IndexSizeErrR©R<(R toffsettcount((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt substringDataÇs  cCs|j||_dS(N(R<(R targ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt appendDataÐscCs||dkr!tjjdƒ‚n|t|jƒkrKtjjdƒ‚n|rxd|j| ||j|f|_ndS(Nisoffset cannot be negatives#offset cannot be beyond end of datas%s%s%s(R$R%RR©R<(R RR ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt insertDataÓs cCs˜|dkr!tjjdƒ‚n|t|jƒkrKtjjdƒ‚n|dkrltjjdƒ‚n|r”|j| |j|||_ndS(Nisoffset cannot be negatives#offset cannot be beyond end of datascount cannot be negative(R$R%RR©R<(R RR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt deleteDataÜs  cCs¡|dkr!tjjdƒ‚n|t|jƒkrKtjjdƒ‚n|dkrltjjdƒ‚n|r�d|j| ||j||f|_ndS(Nisoffset cannot be negatives#offset cannot be beyond end of datascount cannot be negatives%s%s%s(R$R%RR©R<(R RRR ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt replaceDataæs  (RaRbRªRËRÿRt_get_nodeValuet_set_nodeValueR�RÐR R R R R(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRªs      sLength of the string data.R„cBsSeZejZdZdZd„Zdddd„Z d„Z d„Z d„Z RS(s#textcCsË|dks!|t|jƒkr6tjjdƒ‚n|jƒ}|j||_|j|_|j}|jr·||jj kr·|dkr¡|jj |ƒq·|jj ||ƒn|j| |_|S(Nisillegal offset value( R©R<R$R%RRRDR1R(RRR*R"(R RtnewTexttnext((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt splitTextþs!    R cCs!t|d||j|fƒdS(Ns%s%s%s(RqR<(R RRRîR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR scCsÄ|jg}|j}xK|dk rb|jtjtjfkr^|jd|jƒ|j}qPqW|j}xH|dk r¶|jtjtjfkr²|j |jƒ|j}qoPqoWdj |ƒS(NiR ( R<R2RRRR;R~R0R1R>tjoin(R RARÁ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_wholeTexts     cCsü|j}|j}xK|dk r_|jtjtjfkr[|j}|j|ƒ|}qPqW|j}|s|j|ƒnxK|dk rÌ|jtjtjfkrÈ|j}|j|ƒ|}q‚Pq‚W|rô|j }||d<||d<|SdSdS(NR<R|( R(R2RRRR;R~R)R1Ri(R tcontentRtRÁRRW((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytreplaceWholeText$s.            cCs_|jjƒrtSt|ƒ}|dkr/tS|jj|ƒ}|dkrQtS|jƒSdS(N(R<tstripRt_get_containing_elementRRDRštisElementContent(R R™R�((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt!_get_isWhitespaceInElementContentBs   N( RaRbRR;RR{RR}RRRRR(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR„ôs    tisWhitespaceInElementContentsKTrue iff this text node contains only whitespace and is in element content.t wholeTexts.The text of all logically-adjacent text nodes.cCs?|j}x/|dk r:|jtjkr.|S|j}q WdS(N(R(RRRR?(R6R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRUs   cCs?|j}x/|dk r:|jtjkr.|S|j}q WdS(N(R(RRRR(R6R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRö]s   tCommentcBs2eZejZdZd„Zdddd„ZRS(s#commentcCs||_|_dS(N(R<R|(R R<((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRzjsR cCs?d|jkrtdƒ‚n|jd||j|fƒdS(Ns--s%'--' is not allowed in a comment nodes %s%s(R<R,Rp(R RRRîR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRms(RaRbRR�RR{RzR(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRfs  t CDATASectioncBs)eZejZdZdddd„ZRS(s#cdata-sectionR cCs?|jjdƒdkr'tdƒ‚n|jd|jƒdS(Ns]]>is$']]>' not allowed in a CDATA sections(R<tfindR,Rp(R RRRîR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR|s(RaRbRR~RR{R(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRss tReadOnlySequentialNamedNodeMapcBs†eZdZdd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „ZRS(t_seqcCs ||_dS(N(R"(R tseq((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRz…scCs t|jƒS(N(R©R"(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRˉscCs t|jƒS(N(R©R"(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRªŒscCs+x$|jD]}|j|kr |Sq WdS(N(R"R{(R RuRÁ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR¿�scCs:x3|jD](}|j|kr |j|kr |Sq WdS(N(R"RcRh(R RcRhRÁ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÀ”scCsLt|tƒr!|j|Œ}n|j|ƒ}|dkrHt|‚n|S(N(R°R!RÀR¿RRR(R t name_or_tupleR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRº™s   cCs8|dkrdSy|j|SWntk r3dSXdS(Ni(RR"R¬(R R+((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR­¢s   cCstjjdƒ‚dS(Ns"NamedNodeMap instance is read-only(R$R%R÷(R Ru((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRªs cCstjjdƒ‚dS(Ns"NamedNodeMap instance is read-only(R$R%R÷(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRîs cCstjjdƒ‚dS(Ns"NamedNodeMap instance is read-only(R$R%R÷(R R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR»²s cCstjjdƒ‚dS(Ns"NamedNodeMap instance is read-only(R$R%R÷(R R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRĶs cCs |jgS(N(R"(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRƺscCs|d|_dS(Ni(R"(R RÇ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRȽs(R"((RaRbRÊRzRËRªR¿RÀRºR­RÂRÃR»RÄRÆRÈ(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR!‚s           s&Number of entries in the NamedNodeMap.t IdentifiedcBs)eZdZd„Zd„Zd„ZRS(s@Mix-in class that supports the publicId and systemId attributes.cCs||_||_dS(N(tpublicIdtsystemId(R R&R'((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_identified_mixin_initÊs cCs|jS(N(R&(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_publicIdÎscCs|jS(N(R'(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_systemIdÑs(RaRbRÉR(R)R*(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR%Äs  t DocumentTypecBs\eZejZdZdZdZdZ dZ d„Z d„Z d„Z dddd„ZRS(cCsLtƒ|_tƒ|_|r<t|ƒ\}}||_n|j|_dS(N(R!tentitiest notationsRÛRuR{(R RÝRdRÞ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRzÜs    cCs|jS(N(tinternalSubset(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_internalSubsetäscCs\|jdkrTtdƒ}|j|_|j|_tjjj}|r=g|j _ g|j _ xU|j j D]G}t |j|j |jƒ}|j j j|ƒ|j|||ƒqmWx‚|j j D]q}t|j|j |j|jƒ}|j|_|j|_|j|_|j j j|ƒ|j|||ƒqÅWn|j|||ƒ|SdSdS(N(RDRR+RuR{R$R%tUserDataHandlert NODE_CLONEDR,R"R-tNotationR&R'R>R_tEntityt notationNametactualEncodingR RJ(R REtcloneR\RÁtnotationtetentity((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRFçs.         R cCsÃ|jdƒ|j|jƒ|jrL|jd||j||jfƒn&|jrr|jd||jfƒn|jdk r®|jdƒ|j|jƒ|jdƒn|jd|ƒdS(Ns R*R"R)R9(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR3s        R2cBs eZejZdZd„ZRS(cCs||_|j||ƒdS(N(R{R((R RuR&R'((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRz<s N(RaRbRR‚RRR|Rz(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR28s tDOMImplementationc BsSeZd d ddddddgZd„Zd„Zd„Zd „Zd „ZRS(tcores1.0s2.0R$sls-loads3.0cCs.|dkrd}n|jƒ|f|jkS(NR (Rtlowert _features(R RIRJ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRHLs  c CsK|r*|jdk r*tjjdƒ‚n|jƒ}|dkoW|dkoW|dk }| r}|r}tjjdƒ‚n|rt|ƒ\}}|dkrÂ|dkrÂtjjdƒ‚n|rä| rätjjdƒ‚n|j ||ƒ}|r |j |ƒn|j |ƒn|r5||_|_ n||_ ||_ |S(Ns(doctype object owned by another DOM treesElement with no nameR$s$http://www.w3.org/XML/1998/namespacesillegal use of 'xml' prefixs(illegal use of prefix without namespaces(R(RR$R%tWrongDocumentErrt_create_documenttInvalidCharacterErrRÛR�tcreateElementNSR*RDtdoctypeRG( R RcRÝRHRftadd_root_elementRdRÞRú((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateDocumentQs4              cCs"t|ƒ}||_||_|S(N(R+R&R'(R RÝR&R'RH((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateDocumentType~s   cCs|j|dƒr|SdSdS(N(RHR(R RI((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRO†scCstƒS(N(tDocument(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRE�s(RAs1.0(RAs2.0N(RAN(R$s1.0(R$s2.0(R$N(sls-loads3.0(sls-loadN( RaRbRRCRHRJRKRORE(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR@As   -  t ElementInfocBseeZdZd Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z RS( s÷Object that represents content-model information for an element. This implementation is not expected to be used in practice; DOM builders should provide implementations which do the right thing using information available to it. RrcCs ||_dS(N(Rr(R Ru((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRz›scCstS(N(RŸ(R taname((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR¡žscCstS(N(RŸ(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR ¡scCstS(N(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR¤scCstS(sQReturns true iff this element is declared to have an EMPTY content model.(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytisEmpty§scCstS(s7Returns true iff the named attribute is a DTD-style ID.(R(R RN((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRœ¬scCstS(s<Returns true iff the identified attribute is a DTD-style ID.(R(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR›°scCs|jS(N(Rr(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÆ´scCs ||_dS(N(Rr(R RÇ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÈ·s(Rr( RaRbRÉRÊRzR¡R RRORœR›RÆRÈ(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRM�s        cCsZ|jtjkr+|jjƒd|_n+t|ƒrV|jjjƒd|j_ndS(N( RRRt _id_cachetclearRt_id_search_stackRkRD(R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR/ºs    RLcBsÅeZejejejejfZejZ dZ d$Z d$Z d$Zd$Zd$ZZeƒZd$Zd$Zd$Zd$ZeZd$Zd$ZdZd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#d „Z$d „Z%d „Z&d „Z'd „Z(d„Z)d„Z*d„Z+d„Z,d„Z-d„Z.d„Z/d„Z0d„Z1d„Z2d„Z3d„Z4d„Z5d„Z6d„Z7d„Z8d„Z9d„Z:d „Z;d!d!d!d$d"„Z<d#„Z=RS(%s #documenticCs+tƒ|_i|_i|_d|_dS(N(R`Rt _elem_infoRPRRR(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRzÜs   cCs7|jr|j|jf}n |j}|jj|ƒS(N(RcRhRrRSR´(R RúRS((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRšäs  cCs|jS(N(R5(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR<ëscCs|jS(N(RH(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_doctypeîscCs|jS(N(t documentURI(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_documentURIñscCs|jS(N(R (R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR=ôscCs|jS(N(t errorHandler(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_errorHandler÷scCs|jS(N(t standalone(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_standaloneúscCs|jS(N(tstrictErrorChecking(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_strictErrorCheckingýscCs|jS(N(RJ(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR>scCs¢|j|jkr=tjjdt|ƒt|ƒfƒ‚n|jdk r_|jj|ƒn|jt j kr’|j ƒr’tjjdƒ‚nt j ||ƒS(Ns%s cannot be child of %ss two document elements disallowed( RR#R$R%R&R'R(RR)RR?t_get_documentElementR*(R R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR*s "   cCsoy|jj|ƒWn tk r6tjjƒ‚nXd|_|_d|_ |j |krkd|_ n|S(N( RR:R,R$R%R-RR1R2R(tdocumentElement(R R8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR)s   cCs.x'|jD]}|jtjkr |Sq WdS(N(RRRR?(R R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR]scCs9|jdk r(|jjƒd|_ntj|ƒdS(N(RHRR=R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR=$s  cCs|s dS|jjdddƒ}|j|_|j|_|j|_x±|jD]¦}t|||ƒ}|jj |ƒs€t ‚|jj |ƒ|j t jkrº|jdksít ‚n3|j t jkrí|jdksát ‚||_n||_qPW|jtjjj||ƒ|S(N(RRGRJR RYRJRRCRDRNtAssertionErrorR>RRRR^R;RHR(R_R$R%R0R1(R RER6RÁt childclone((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRF*s&      cCstƒ}||_|S(N(RyRD(R RW((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateDocumentFragment?s  cCst|ƒ}||_|S(N(RÓRD(R RrR8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt createElementDs  cCs:t|tƒstd‚ntƒ}||_||_|S(Nsnode contents must be a string(R°R±R¼R„R<RD(R R<tt((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateTextNodeIs     cCs:t|tƒstd‚ntƒ}||_||_|S(Nsnode contents must be a string(R°R±R¼RR<RD(R R<R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateCDATASectionQs     cCst|ƒ}||_|S(N(RRD(R R<R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt createCommentYs  cCst||ƒ}||_|S(N(RýRD(R RþR<tp((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateProcessingInstruction^s cCs"t|ƒ}||_d|_|S(NR (RƒRDRŠ(R R…ta((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateAttributecs   cCs1t|ƒ\}}t|||ƒ}||_|S(N(RÛRÓRD(R RcRÝRdRhR8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRGis cCs=t|ƒ\}}t||||ƒ}||_d|_|S(NR (RÛRƒRDRŠ(R RcRÝRdRhRi((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateAttributeNSos   cCs"t||||ƒ}||_|S(N(R3RD(R RuR&R'R4R8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_create_entityys cCst|||ƒ}||_|S(N(R2RD(R RuR&R'RÁ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_create_notation~s cCsE||jkr|j|S|jp)|js0dS|j}|dkr]|jg}||_n |sgdSd}xÑ|r@|jƒ}|jg|jD]}|j t kr’|^q’ƒ|j |ƒ}|rÓxa|j j ƒD]ó}|jr;|j|j|jƒrÌ||j|j<|j|kr(|}q8|js8Pq8qÌqÙ|j|jƒr…||j|j<|j|kru|}qÌ|jsÌPqÌqÙ|jrÙ||j|j<|j|kr¶|}qÌ|jdkrÌPqÌqÙqÙWnZ|jr-xN|j j ƒD]:}|jrì||j|j<|j|kr&|}q&qìqìWn|dk rpPqpqpW|S(Ni(RPRSR˜RRRR^tpoptextendRRR.RšR}R®RcR›RhRŠR—RœRuR–(R R·tstacktresultR6RBR�RÕ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytgetElementByIdƒs\                  cCst||tƒƒS(N(RsR`(R Ru((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRê½scCst|||tƒƒS(N(RwR`(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRëÀscCs|jj||ƒS(N(RGRH(R RIRJ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRKÄscCs^|jtjkr'tjjdƒ‚n'|jtjkrNtjjdƒ‚nt|||ƒS(Nscannot import document nodess!cannot import document type nodes(RRRR$R%tNotSupportedErrR;RC(R R6RE((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt importNodeÇs R cCse|dkr |jd|ƒn|jd||fƒx'|jD]}|j||||ƒqAWdS(Nss%%s(RRpRR(R RRRîRR R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÎs  c Cs|j|k r1tjjd||jfƒ‚n|jtjtjfkratjjdƒ‚n|t krd|krÇ|j ddƒ\}}|dkr|tjj krtjj dƒ‚qq'|dkr |tjj kr |jtjkr tjj dƒ‚nd}|}n d}d}|jtjkrj|j}|dk rp|j}|j|ƒqpnd}|j}||d<||d <||d <||d <|jtjkrÀ||d RaRbRR?R€R�R;R#RRR{RR|R}RHR(R2R1R@RGR5R RYRJRR[RWRUR˜RzRšR<RTRVR=RXRZR\R>R*R)R]R=RFRaRbRdReRfRhRjRGRkRlRmRrRêRëRKRtRRv(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRLÂsh                             :      R^s#Top-level element of this document.c Cs|jj|ƒr$tjjj}ntjjj}|jtj krö|j |j |j ƒ}xW|j jƒD]F}|j|j |j |jƒ|j|j |jƒ}|j|_qmW|rçx3|jD]%}t|||ƒ}|j|ƒqÇWqçnñ|jtjkrS|jƒ}|rçx3|jD]%}t|||ƒ}|j|ƒq$Wqçn”|jtjkrz|j|jƒ}nm|jtjkr¡|j|jƒ}nF|jtjkrÎ|j|j |jƒ}n|jtj!krõ|j"|jƒ}nò|jtj#kr7|j$|j |j ƒ}t%|_|j|_n°|jtj&krË|j|k s^t'‚tjjj}|j(j)|j*|j+|j,ƒ}||_|rçg|j-_.g|j/_.xp|j/j.D]b} t0| j | j+| j,ƒ} || _|j/j.j1| ƒt2| dƒrÂ| j3|| | ƒqÂqÂWx�|j-j.D]Œ} t4| j | j+| j,| j5ƒ} | j6| _6| j7| _7| j8| _8|| _|j-j.j1| ƒt2| dƒr5| j3|| | ƒq5q5Wqçntjj9dt:|ƒƒ‚t2|dƒr |j3|||ƒn|S(so Clone a node and give it the new owner document. Called by Node.cloneNode and Document.importNode R_sCannot clone node %s(;RDRNR$R%R0R1t NODE_IMPORTEDRRR?RGRcR{R}R®RßRŠRÜRhRˆRRCR*R RaR;RdR<R~ReR€RhRþR�RfR£RkRR;R_RGRKRuR&R'R,R"R-R2R>RYR_R3R4R5R RJRsR'( R6REtnewOwnerDocumentR\R6RÕRiRBR5RÁR7R8R9((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRCs~                  cCs:|jddƒ}t|ƒdkr(|Sd|dfSdS(NR†iii(R‡R©R(RÝtfields((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÛfscCsddlm}|ƒS(Niÿÿÿÿ(tStringIO(Rz(Rz((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRnscCs<|||Ž}|jƒ\}}|j|ƒ|jƒ|S(N(tgetEventt expandNodeRQ(tfunctargstkwargsteventsttoktypetrootNode((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_do_pulldom_parsess   cCsh|dkr0| r0ddlm}|j|ƒSddlm}t|j|fi|d6|d6ƒSdS(s3Parse a file into a DOM by filename or file object.iÿÿÿÿ(t expatbuilder(tpulldomtparsertbufsizeN(Rtxml.domR„tparseR…Rƒ(tfileR†R‡R„R…((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR‰zs  cCsZ|dkr)ddlm}|j|ƒSddlm}t|j|fi|d6ƒSdS(s&Parse a file into a DOM from a string.iÿÿÿÿ(R„(R…R†N(RRˆR„t parseStringR…Rƒ(tstringR†R„R…((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR‹„s   cCsa|rZt|tƒr'tj|ƒ}nx0|D]%\}}tjj||ƒs.dSq.WntjS(N(R°R±Rt_parse_feature_stringRLRGRHR(tfeaturestftv((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytgetDOMImplementationŽs (8RÉRˆR$RRRRtxml.dom.minicompattxml.dom.xmlbuilderRRR%RR?RR.t defpropertyR7RkRqRsRwRyRƒtobjectR¥t AttributeListRÎRRŸRÓRãRûRýRR„RRöRRR!R%R+R3R2R@RMR/RLRCRÛRRƒR‰R‹R‘(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyts„ "  í    r• Ü   (GZ     > <( O* ÿO  R    PK:©ç\eðiÂU U dom/minidom.pyonu„[µü¤ó ›V~gc@sdZddlZddlmZmZmZmZddlTddlm Z m Z ej j j ej j jfZdej j fd„ƒYZ ee dd d ƒee d d d ƒee d d dƒd„Zd„Zd„Zd„Zd„Zde fd„ƒYZde fd„ƒYZeedd dƒeed d dƒeedd dƒdefd„ƒYZeedd d ƒeZd!efd"„ƒYZeeeƒZd#e fd$„ƒYZeed%d d&ƒeed d d'ƒd(„Zd)fd*„ƒYZ d+e e fd,„ƒYZ!d-e e fd.„ƒYZ"ee"dd d/ƒd0e"fd1„ƒYZ#ee#d2d d3ƒee#d4d d5ƒd6„Z$d7„Z%d8e e"fd9„ƒYZ&d:e#fd;„ƒYZ'd<efd=„ƒYZ(ee(dd d>ƒd?fd@„ƒYZ)dAe)e e fdB„ƒYZ*dCe)e fdD„ƒYZ+dEe)e e fdF„ƒYZ,dGe fdH„ƒYZ-dIefdJ„ƒYZ.dK„Z/dLe e fdM„ƒYZ0ee0dNd dOƒdP„Z1dQ„Z2dR„Z3dS„Z4eedT„Z5edU„Z6edV„Z7dS(WscSimple implementation of the Level 1 DOM. Namespaces and other minor Level 2 features are also supported. parse("foo.xml") parseString("") Todo: ===== * convenience methods for getting elements and text. * more testing * bring some of the writer and linearizer code into conformance with this interface * SAX 2 namespaces iÿÿÿÿN(tEMPTY_NAMESPACEt EMPTY_PREFIXtXMLNS_NAMESPACEtdomreg(t*(tDOMImplementationLSt DocumentLStNodecBsõeZdZdZdZdZdZeZ d„Z dd„Z dddd„Z d„Z d„Zd„Zd„Zd „Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cCstS(N(tTrue(tself((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt __nonzero__*scCs|jdd|ƒS(Nt(t toprettyxml(R tencoding((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyttoxml-ss s cCs‹tƒ}|dk r=ddl}|j|ƒd|ƒ}n|jtjkrk|j|d|||ƒn|j|d||ƒ|jƒS(NiÿÿÿÿiR ( t _get_StringIOtNonetcodecstlookuptnodeTypeRt DOCUMENT_NODEtwritexmltgetvalue(R tindenttnewlR twriterR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR 0s   cCs|jr tStSdS(N(t childNodesRtFalse(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt hasChildNodes?s cCs|jS(N(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_childNodesEscCs|jr|jdSdS(Ni(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_firstChildHs cCs|jr|jdSdS(Niÿÿÿÿ(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_lastChildLs cCsw|j|jkr@x't|jƒD]}|j||ƒq"W|S|j|jkr}tjjdt |ƒt |ƒfƒ‚n|j dk rŸ|j j |ƒn|dkr»|j |ƒn¸y|jj|ƒ}Wn tk rótjjƒ‚nX|jtkrt|ƒn|jj||ƒ||_||_|ra|j|d}||_||_n d|_||_ |S(Ns%s cannot be child of %si(RtDOCUMENT_FRAGMENT_NODEttupleRt insertBeforet_child_node_typestxmltdomtHierarchyRequestErrtreprt parentNodeRt removeChildt appendChildtindext ValueErrort NotFoundErrt_nodeTypes_with_childrent_clear_id_cachetinsertt nextSiblingtpreviousSibling(R tnewChildtrefChildtcR+tnode((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR"Ps6 "         cCsÒ|j|jkr=x$t|jƒD]}|j|ƒq"W|S|j|jkrztjjdt |ƒt |ƒfƒ‚n|jt kr–t |ƒn|j dk r¸|j j|ƒnt||ƒd|_|S(Ns%s cannot be child of %s(RR R!RR*R#R$R%R&R'R.R/R(RR)t _append_childR1(R R6R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR*ps "   cCsˆ|j|jkr8|j}|j|ƒ|j||ƒS|j|jkrutjjdt |ƒt |ƒfƒ‚n||kr…dS|j dk r§|j j|ƒny|j j |ƒ}Wn tk rßtjjƒ‚nX||j |<||_ d|_ |jtks|jtkr*t|ƒn|j|_|j|_d|_d|_|jrl||j_n|jr„||j_n|S(Ns%s cannot be child of %s(RR R1R)R"R#R$R%R&R'R(RRR+R,R-R.R/R2(R R3toldChildR4R+((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt replaceChild�s<   "            cCs²y|jj|ƒWn tk r6tjjƒ‚nX|jdk rX|j|j_n|jdk ry|j|j_nd|_|_|j t kr¥t |ƒnd|_ |S(N( RtremoveR,R$R%R-R1RR2RR.R/R((R R8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR)¡s   cCs*g}x|jD]}|jtjkrì|jsr|rJ|j|d_n|jre|j|j_n|jƒq|rÜ|dj|jkrÜ|d}|j|j|_|j|_|jrÏ||j_n|jƒq|j|ƒq|j|ƒ|jtj kr|j ƒqqW||j(dS(Niÿÿÿÿ( RRRt TEXT_NODEtdataR1R2tunlinktappendt ELEMENT_NODEt normalize(R tLtchildR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR@±s*        cCst|||jp|ƒS(N(t _clone_nodet ownerDocument(R tdeep((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt cloneNodeÌscCs|jjj||ƒS(N(RDtimplementationt hasFeature(R tfeaturetversion((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt isSupportedÏscCsdS(N(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_localNameÒscCs ||kS(N((R tother((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt isSameNodeØscCs|j|dƒr|SdSdS(N(RKR(R RI((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt getInterfaceÛscCs2y|j|dSWnttfk r-dSXdS(Ni(t _user_datatAttributeErrortKeyErrorR(R tkey((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt getUserDataåscCs’d}y |j}Wn tk r5i}||_nX||krS||d}n|dkr~d}|dk rŽ||=qŽn||f||<|S(Ni(RRPRQ(R RSR<thandlertoldtd((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt setUserDataës       cCsdt|dƒr`xN|jjƒD]:\}\}}|dk r|j|||||ƒqqWndS(NRP(thasattrRPtitemsRthandle(R t operationtsrctdstRSR<RU((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_call_user_data_handlerýs" cCs\d|_|_|jrFx|jD]}|jƒq#Wtƒ|_nd|_d|_dS(N(RR(RDRR=tNodeListR2R1(R RB((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR=s  N(t__name__t __module__Rt namespaceURIR(RDR1R2RtprefixR RR RRRRR"R*R9R)R@RFRKRLRNRORTRXR_R=(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR!s6                t firstChildtdocsFirst child node, or None.t lastChildsLast child node, or None.t localNames"Namespace-local name of this node.cCsT|j}|r6|d}||jd<||jd(R R6Rtlast((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR7s    cCs6x/|dk r1|jtjkr%tS|j}qWtS(N(RRRRRR(R(R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _in_documents  cCsP|rL|jddƒjddƒjddƒjddƒ}|j|ƒnd S( sWrites datachars to writer.t&s&ts>N(treplacetwrite(RR<((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _write_data%scCsex^|jD]S}|jtjkrM|dks=|j|krM|j|ƒnt|||ƒq W|S(NR(RRRR?ttagNameR>t_get_elements_by_tagName_helper(tparenttnametrcR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRs,s cCs†x|jD]t}|jtjkr |dks=|j|krh|dksX|j|krh|j|ƒnt||||ƒq q W|S(NR(RRRR?RhRcR>t"_get_elements_by_tagName_ns_helper(RttnsURIRhRvR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRw4stDocumentFragmentcBsbeZejZdZdZdZdZ ej ej ej ej ejejejfZd„ZRS(s#document-fragmentcCstƒ|_dS(N(R`R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt__init__KsN(RaRbRR RtnodeNameRt nodeValuet attributesR(R?R;tCDATA_SECTION_NODEtENTITY_REFERENCE_NODEtPROCESSING_INSTRUCTION_NODEt COMMENT_NODEt NOTATION_NODER#Rz(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRy=s  tAttrcBs•eZejZd Zd ZeZ eZ ej ej fZ ed d d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS( cCsS|j}||d<|d<||d<||dtText(R tqNameRcRhRdRW((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRzXs     cCs|jjddƒdS(Nt:iiÿÿÿÿ(R{tsplit(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRLfscCs|jS(N(t specified(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_specifiediscCs¹|j}|dkrk||d<|d<|jdj}||d<|d<|jdk rµt|jƒqµnJ|dkr«||d<|d<|jdk rµt|jƒqµn |||R{RŠ(R RAR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRZßscCsFg}x9|jjƒD](}|j|j|jf|jfƒqW|S(N(R”R®R>RcRhRŠ(R RAR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytitemsNSås&cCs-t|tƒr||jkS||jkSdS(N(t isinstancet StringTypesR”R•(R RS((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pythas_keyës cCs |jjƒS(N(R”R«(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR«ñscCs |jjƒS(N(R•R«(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytkeysNSôscCs |jjƒS(N(R”R®(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR®÷scCs|jj||ƒS(N(R”tget(R RuRŠ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR´úscCs<|jt|ddƒkrdStt|ƒt|ƒƒSdS(NR”i(R”tgetattrRtcmptid(R RM((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt__cmp__scCs)t|tƒr|j|S|j|SdS(N(R°R!R•R”(R tattname_or_tuple((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt __getitem__s cCsšt|tƒrhy|j|}Wn9tk r[t|ƒ}|jj|_|j|ƒnX||_n.t|tƒsƒt d‚n|}|j|ƒdS(Ns%value must be a string or Attr object( R°R±R”RRRƒR¦RDt setNamedItemRŠt TypeError(R tattnameRŠR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt __setitem__ s    cCs(y|j|SWntk r#dSXdS(N(R”RRR(R Ru((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt getNamedItems cCs.y|j||fSWntk r)dSXdS(N(R•RRR(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytgetNamedItemNS"s cCs�|j|ƒ}|dk rnt|jƒ|j|j=|j|j|jf=d|j krjd|j ds (RÏRu(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt__repr__hs cCs|jS(N(Ru(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_namenscCs|jS(N(RÏ(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_namespaceqs(RÏRu(RaRbRÊRzRÐRÑRÒ(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÎas    tElementcBsLeZejZdZeZdZ ejej ej ej ej ejfZeddd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd „Zd „Zd „ZeZd „Zd „Zd„ZeZ d„Z!d„Z"d„Z#d„Z$d„Z%dddd„Z&d„Z'd„Z(d„Z)d„Z*d„Z+RS(icCsD||_|_||_||_tƒ|_i|_i|_dS(N(RrR{RdRcR`RR”R•(R RrRcRdRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRz„s     cCs|jjddƒdS(NR†iiÿÿÿÿ(RrR‡(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRL“scCs|jS(N(Rr(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_tagName–scCsGx!|jjƒD]}|jƒqWd|_d|_tj|ƒdS(N(R”R®R=RR•R(R tattr((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR=™s   cCs+y|j|jSWntk r&dSXdS(NR (R”RŠRR(R R½((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt getAttribute s cCs1y|j||fjSWntk r,dSXdS(NR (R•RŠRR(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytgetAttributeNS¦s cCs¦|j|ƒ}|dkr_t|ƒ}|j}||d<|d<|j|d<|j|ƒnC||jkr¢|j}||d<|d<|jr¢t|ƒq¢ndS(NRŠR|RD( tgetAttributeNodeRRƒRiRDtsetAttributeNodeRŠRœR/(R R½RŠRÕRW((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt setAttribute¬s      cCsþt|ƒ\}}|j||ƒ}|dkr‘t||||ƒ}|j}||d<||d<||d<|d<|j|d<|j|ƒni|j}||jkrÔ||d<|d<|jrÔt |ƒqÔn|j |krú||d<||d(RrR·(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÐsR c Cs[|j|d|jƒ|jƒ}|jƒ}|jƒx@|D]8}|jd|ƒt|||jƒ|jdƒqAW|jrF|jdƒt|jƒdkrá|jdj t j krá|jdj |dddƒnH|j|ƒx+|jD] }|j |||||ƒqøW|j|ƒ|jd|j|fƒn|jd |ƒdS( NRms %s="s"RniiR s%ss/>%s( RpRrt_get_attributesR«tsortRqRŠRR©RRR;R( R RRt addindentRR§ta_namesta_nameR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRs&         cCst|j|j|ƒS(N(R¥R”R•(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRì4scCs|jr tStSdS(N(R”RR(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt hasAttributes7s cCs |j|ƒ}|j|ƒdS(N(RØtsetIdAttributeNode(R RutidAttr((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytsetIdAttribute?scCs#|j||ƒ}|j|ƒdS(N(RÜRò(R RcRhRó((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytsetIdAttributeNSCscCs�|dks|j|jƒ r1tjjƒ‚nt|ƒdk rUtjjƒ‚n|js™t |j d<|j d7_ |j j d7_ t|ƒndS(NR–i(RRNR‹R$R%R-t_get_containing_entreftNoModificationAllowedErrR–RRiR—RDR˜R/(R Ró((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRòGs  N(,RaRbRR?RRR|RŸR¤R—R€R�R;R~RR#RRzRLRÔR=RÖR×RÚRßRØRÜRÙtsetAttributeNodeNSRæRçRâtremoveAttributeNodeNSRèRéRêRëRÐRRìRñRôRõRò(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÓvsL                         R}s*NamedNodeMap of attributes on the element.s%Namespace-local name of this element.cCsDt|ƒ||j|j<||j|j|jf<||jd%s(RpRþR<(R RRRîR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR¦s( RaRbRR€RRzRÿRRRR�R(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRý‹s       t CharacterDatacBsteZd„ZeZd„Zd„ZeZeZd„Zd„Z d„Z d„Z d„Z d„Z d „ZRS( cCs t|jƒS(N(R©R<(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRª«scCs |jdS(NR<(Ri(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÿ¯scCs|j}||d<|di(R<R©t __class__Ra(R R<t dotdotdot((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRоs   cCs~|dkr!tjjdƒ‚n|t|jƒkrKtjjdƒ‚n|dkrltjjdƒ‚n|j|||!S(Nisoffset cannot be negatives#offset cannot be beyond end of datascount cannot be negative(R$R%t IndexSizeErrR©R<(R toffsettcount((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt substringDataÇs  cCs|j||_dS(N(R<(R targ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt appendDataÐscCs||dkr!tjjdƒ‚n|t|jƒkrKtjjdƒ‚n|rxd|j| ||j|f|_ndS(Nisoffset cannot be negatives#offset cannot be beyond end of datas%s%s%s(R$R%RR©R<(R RR ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt insertDataÓs cCs˜|dkr!tjjdƒ‚n|t|jƒkrKtjjdƒ‚n|dkrltjjdƒ‚n|r”|j| |j|||_ndS(Nisoffset cannot be negatives#offset cannot be beyond end of datascount cannot be negative(R$R%RR©R<(R RR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt deleteDataÜs  cCs¡|dkr!tjjdƒ‚n|t|jƒkrKtjjdƒ‚n|dkrltjjdƒ‚n|r�d|j| ||j||f|_ndS(Nisoffset cannot be negatives#offset cannot be beyond end of datascount cannot be negatives%s%s%s(R$R%RR©R<(R RRR ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt replaceDataæs  (RaRbRªRËRÿRt_get_nodeValuet_set_nodeValueR�RÐR R R R R(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRªs      sLength of the string data.R„cBsSeZejZdZdZd„Zdddd„Z d„Z d„Z d„Z RS(s#textcCsË|dks!|t|jƒkr6tjjdƒ‚n|jƒ}|j||_|j|_|j}|jr·||jj kr·|dkr¡|jj |ƒq·|jj ||ƒn|j| |_|S(Nisillegal offset value( R©R<R$R%RRRDR1R(RRR*R"(R RtnewTexttnext((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt splitTextþs!    R cCs!t|d||j|fƒdS(Ns%s%s%s(RqR<(R RRRîR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR scCsÄ|jg}|j}xK|dk rb|jtjtjfkr^|jd|jƒ|j}qPqW|j}xH|dk r¶|jtjtjfkr²|j |jƒ|j}qoPqoWdj |ƒS(NiR ( R<R2RRRR;R~R0R1R>tjoin(R RARÁ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_wholeTexts     cCsü|j}|j}xK|dk r_|jtjtjfkr[|j}|j|ƒ|}qPqW|j}|s|j|ƒnxK|dk rÌ|jtjtjfkrÈ|j}|j|ƒ|}q‚Pq‚W|rô|j }||d<||d<|SdSdS(NR<R|( R(R2RRRR;R~R)R1Ri(R tcontentRtRÁRRW((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytreplaceWholeText$s.            cCs_|jjƒrtSt|ƒ}|dkr/tS|jj|ƒ}|dkrQtS|jƒSdS(N(R<tstripRt_get_containing_elementRRDRštisElementContent(R R™R�((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt!_get_isWhitespaceInElementContentBs   N( RaRbRR;RR{RR}RRRRR(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR„ôs    tisWhitespaceInElementContentsKTrue iff this text node contains only whitespace and is in element content.t wholeTexts.The text of all logically-adjacent text nodes.cCs?|j}x/|dk r:|jtjkr.|S|j}q WdS(N(R(RRRR?(R6R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRUs   cCs?|j}x/|dk r:|jtjkr.|S|j}q WdS(N(R(RRRR(R6R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRö]s   tCommentcBs2eZejZdZd„Zdddd„ZRS(s#commentcCs||_|_dS(N(R<R|(R R<((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRzjsR cCs?d|jkrtdƒ‚n|jd||j|fƒdS(Ns--s%'--' is not allowed in a comment nodes %s%s(R<R,Rp(R RRRîR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRms(RaRbRR�RR{RzR(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRfs  t CDATASectioncBs)eZejZdZdddd„ZRS(s#cdata-sectionR cCs?|jjdƒdkr'tdƒ‚n|jd|jƒdS(Ns]]>is$']]>' not allowed in a CDATA sections(R<tfindR,Rp(R RRRîR((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR|s(RaRbRR~RR{R(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRss tReadOnlySequentialNamedNodeMapcBs†eZdZdd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „ZRS(t_seqcCs ||_dS(N(R"(R tseq((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRz…scCs t|jƒS(N(R©R"(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRˉscCs t|jƒS(N(R©R"(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRªŒscCs+x$|jD]}|j|kr |Sq WdS(N(R"R{(R RuRÁ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR¿�scCs:x3|jD](}|j|kr |j|kr |Sq WdS(N(R"RcRh(R RcRhRÁ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÀ”scCsLt|tƒr!|j|Œ}n|j|ƒ}|dkrHt|‚n|S(N(R°R!RÀR¿RRR(R t name_or_tupleR6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRº™s   cCs8|dkrdSy|j|SWntk r3dSXdS(Ni(RR"R¬(R R+((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR­¢s   cCstjjdƒ‚dS(Ns"NamedNodeMap instance is read-only(R$R%R÷(R Ru((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRªs cCstjjdƒ‚dS(Ns"NamedNodeMap instance is read-only(R$R%R÷(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRîs cCstjjdƒ‚dS(Ns"NamedNodeMap instance is read-only(R$R%R÷(R R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR»²s cCstjjdƒ‚dS(Ns"NamedNodeMap instance is read-only(R$R%R÷(R R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRĶs cCs |jgS(N(R"(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRƺscCs|d|_dS(Ni(R"(R RÇ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRȽs(R"((RaRbRÊRzRËRªR¿RÀRºR­RÂRÃR»RÄRÆRÈ(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR!‚s           s&Number of entries in the NamedNodeMap.t IdentifiedcBs)eZdZd„Zd„Zd„ZRS(s@Mix-in class that supports the publicId and systemId attributes.cCs||_||_dS(N(tpublicIdtsystemId(R R&R'((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_identified_mixin_initÊs cCs|jS(N(R&(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_publicIdÎscCs|jS(N(R'(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_systemIdÑs(RaRbRÉR(R)R*(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR%Äs  t DocumentTypecBs\eZejZdZdZdZdZ dZ d„Z d„Z d„Z dddd„ZRS(cCsLtƒ|_tƒ|_|r<t|ƒ\}}||_n|j|_dS(N(R!tentitiest notationsRÛRuR{(R RÝRdRÞ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRzÜs    cCs|jS(N(tinternalSubset(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_internalSubsetäscCs\|jdkrTtdƒ}|j|_|j|_tjjj}|r=g|j _ g|j _ xU|j j D]G}t |j|j |jƒ}|j j j|ƒ|j|||ƒqmWx‚|j j D]q}t|j|j |j|jƒ}|j|_|j|_|j|_|j j j|ƒ|j|||ƒqÅWn|j|||ƒ|SdSdS(N(RDRR+RuR{R$R%tUserDataHandlert NODE_CLONEDR,R"R-tNotationR&R'R>R_tEntityt notationNametactualEncodingR RJ(R REtcloneR\RÁtnotationtetentity((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRFçs.         R cCsÃ|jdƒ|j|jƒ|jrL|jd||j||jfƒn&|jrr|jd||jfƒn|jdk r®|jdƒ|j|jƒ|jdƒn|jd|ƒdS(Ns R*R"R)R9(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR3s        R2cBs eZejZdZd„ZRS(cCs||_|j||ƒdS(N(R{R((R RuR&R'((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRz<s N(RaRbRR‚RRR|Rz(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR28s tDOMImplementationc BsSeZd d ddddddgZd„Zd„Zd„Zd „Zd „ZRS(tcores1.0s2.0R$sls-loads3.0cCs.|dkrd}n|jƒ|f|jkS(NR (Rtlowert _features(R RIRJ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRHLs  c CsK|r*|jdk r*tjjdƒ‚n|jƒ}|dkoW|dkoW|dk }| r}|r}tjjdƒ‚n|rt|ƒ\}}|dkrÂ|dkrÂtjjdƒ‚n|rä| rätjjdƒ‚n|j ||ƒ}|r |j |ƒn|j |ƒn|r5||_|_ n||_ ||_ |S(Ns(doctype object owned by another DOM treesElement with no nameR$s$http://www.w3.org/XML/1998/namespacesillegal use of 'xml' prefixs(illegal use of prefix without namespaces(R(RR$R%tWrongDocumentErrt_create_documenttInvalidCharacterErrRÛR�tcreateElementNSR*RDtdoctypeRG( R RcRÝRHRftadd_root_elementRdRÞRú((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateDocumentQs4              cCs"t|ƒ}||_||_|S(N(R+R&R'(R RÝR&R'RH((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateDocumentType~s   cCs|j|dƒr|SdSdS(N(RHR(R RI((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRO†scCstƒS(N(tDocument(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRE�s(RAs1.0(RAs2.0N(RAN(R$s1.0(R$s2.0(R$N(sls-loads3.0(sls-loadN( RaRbRRCRHRJRKRORE(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR@As   -  t ElementInfocBseeZdZd Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z RS( s÷Object that represents content-model information for an element. This implementation is not expected to be used in practice; DOM builders should provide implementations which do the right thing using information available to it. RrcCs ||_dS(N(Rr(R Ru((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRz›scCstS(N(RŸ(R taname((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR¡žscCstS(N(RŸ(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR ¡scCstS(N(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR¤scCstS(sQReturns true iff this element is declared to have an EMPTY content model.(R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytisEmpty§scCstS(s7Returns true iff the named attribute is a DTD-style ID.(R(R RN((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRœ¬scCstS(s<Returns true iff the identified attribute is a DTD-style ID.(R(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR›°scCs|jS(N(Rr(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÆ´scCs ||_dS(N(Rr(R RÇ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÈ·s(Rr( RaRbRÉRÊRzR¡R RRORœR›RÆRÈ(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRM�s        cCsZ|jtjkr+|jjƒd|_n+t|ƒrV|jjjƒd|j_ndS(N( RRRt _id_cachetclearRt_id_search_stackRkRD(R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR/ºs    RLcBsÅeZejejejejfZejZ dZ d$Z d$Z d$Zd$Zd$ZZeƒZd$Zd$Zd$Zd$ZeZd$Zd$ZdZd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#d „Z$d „Z%d „Z&d „Z'd „Z(d„Z)d„Z*d„Z+d„Z,d„Z-d„Z.d„Z/d„Z0d„Z1d„Z2d„Z3d„Z4d„Z5d„Z6d„Z7d„Z8d„Z9d„Z:d „Z;d!d!d!d$d"„Z<d#„Z=RS(%s #documenticCs+tƒ|_i|_i|_d|_dS(N(R`Rt _elem_infoRPRRR(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRzÜs   cCs7|jr|j|jf}n |j}|jj|ƒS(N(RcRhRrRSR´(R RúRS((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRšäs  cCs|jS(N(R5(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR<ëscCs|jS(N(RH(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt _get_doctypeîscCs|jS(N(t documentURI(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_documentURIñscCs|jS(N(R (R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR=ôscCs|jS(N(t errorHandler(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_errorHandler÷scCs|jS(N(t standalone(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_standaloneúscCs|jS(N(tstrictErrorChecking(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_get_strictErrorCheckingýscCs|jS(N(RJ(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR>scCs¢|j|jkr=tjjdt|ƒt|ƒfƒ‚n|jdk r_|jj|ƒn|jt j kr’|j ƒr’tjjdƒ‚nt j ||ƒS(Ns%s cannot be child of %ss two document elements disallowed( RR#R$R%R&R'R(RR)RR?t_get_documentElementR*(R R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR*s "   cCsoy|jj|ƒWn tk r6tjjƒ‚nXd|_|_d|_ |j |krkd|_ n|S(N( RR:R,R$R%R-RR1R2R(tdocumentElement(R R8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR)s   cCs.x'|jD]}|jtjkr |Sq WdS(N(RRRR?(R R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR]scCs9|jdk r(|jjƒd|_ntj|ƒdS(N(RHRR=R(R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyR=$s  cCsØ|s dS|jjdddƒ}|j|_|j|_|j|_xo|jD]d}t|||ƒ}|jj|ƒ|j t j kr�n|j t j kr«||_ n||_qPW|jtjjj||ƒ|S(N(RRGRJR RYRJRRCR>RRRR;RHR(R_R$R%R0R1(R RER6RÁt childclone((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRF*s"      cCstƒ}||_|S(N(RyRD(R RW((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateDocumentFragment?s  cCst|ƒ}||_|S(N(RÓRD(R RrR8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt createElementDs  cCs:t|tƒstd‚ntƒ}||_||_|S(Nsnode contents must be a string(R°R±R¼R„R<RD(R R<tt((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateTextNodeIs     cCs:t|tƒstd‚ntƒ}||_||_|S(Nsnode contents must be a string(R°R±R¼RR<RD(R R<R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateCDATASectionQs     cCst|ƒ}||_|S(N(RRD(R R<R5((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt createCommentYs  cCst||ƒ}||_|S(N(RýRD(R RþR<tp((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateProcessingInstruction^s cCs"t|ƒ}||_d|_|S(NR (RƒRDRŠ(R R…ta((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateAttributecs   cCs1t|ƒ\}}t|||ƒ}||_|S(N(RÛRÓRD(R RcRÝRdRhR8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRGis cCs=t|ƒ\}}t||||ƒ}||_d|_|S(NR (RÛRƒRDRŠ(R RcRÝRdRhRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytcreateAttributeNSos   cCs"t||||ƒ}||_|S(N(R3RD(R RuR&R'R4R8((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_create_entityys cCst|||ƒ}||_|S(N(R2RD(R RuR&R'RÁ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_create_notation~s cCsE||jkr|j|S|jp)|js0dS|j}|dkr]|jg}||_n |sgdSd}xÑ|r@|jƒ}|jg|jD]}|j t kr’|^q’ƒ|j |ƒ}|rÓxa|j j ƒD]ó}|jr;|j|j|jƒrÌ||j|j<|j|kr(|}q8|js8Pq8qÌqÙ|j|jƒr…||j|j<|j|kru|}qÌ|jsÌPqÌqÙ|jrÙ||j|j<|j|kr¶|}qÌ|jdkrÌPqÌqÙqÙWnZ|jr-xN|j j ƒD]:}|jrì||j|j<|j|kr&|}q&qìqìWn|dk rpPqpqpW|S(Ni(RPRSR˜RRRR^tpoptextendRRR.RšR}R®RcR›RhRŠR—RœRuR–(R R·tstacktresultR6RBR�RÕ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytgetElementByIdƒs\                  cCst||tƒƒS(N(RsR`(R Ru((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRê½scCst|||tƒƒS(N(RwR`(R RcRh((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRëÀscCs|jj||ƒS(N(RGRH(R RIRJ((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRKÄscCs^|jtjkr'tjjdƒ‚n'|jtjkrNtjjdƒ‚nt|||ƒS(Nscannot import document nodess!cannot import document type nodes(RRRR$R%tNotSupportedErrR;RC(R R6RE((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt importNodeÇs R cCse|dkr |jd|ƒn|jd||fƒx'|jD]}|j||||ƒqAWdS(Nss%%s(RRpRR(R RRRîRR R6((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÎs  c Cs|j|k r1tjjd||jfƒ‚n|jtjtjfkratjjdƒ‚n|t krd|krÇ|j ddƒ\}}|dkr|tjj krtjj dƒ‚qq'|dkr |tjj kr |jtjkr tjj dƒ‚nd}|}n d}d}|jtjkrj|j}|dk rp|j}|j|ƒqpnd}|j}||d<||d <||d <||d <|jtjkrÀ||d RaRbRR?R€R�R;R#RRR{RR|R}RHR(R2R1R@RGR5R RYRJRR[RWRUR˜RzRšR<RTRVR=RXRZR\R>R*R)R]R=RFR`RaRcRdReRgRiRGRjRkRlRqRêRëRKRsRRu(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRLÂsh                             :      R^s#Top-level element of this document.c Csû|jj|ƒr$tjjj}ntjjj}|jtj krö|j |j |j ƒ}xW|j jƒD]F}|j|j |j |jƒ|j|j |jƒ}|j|_qmW|rÒx3|jD]%}t|||ƒ}|j|ƒqÇWqÒnÜ|jtjkrS|jƒ}|rÒx3|jD]%}t|||ƒ}|j|ƒq$WqÒn|jtjkrz|j|jƒ}nX|jtjkr¡|j|jƒ}n1|jtjkrÎ|j|j |jƒ}n|jtj!krõ|j"|jƒ}nÝ|jtj#kr7|j$|j |j ƒ}t%|_|j|_n›|jtj&kr¶tjjj}|j'j(|j)|j*|j+ƒ}||_|rÒg|j,_-g|j._-xp|j.j-D]b} t/| j | j*| j+ƒ} || _|j.j-j0| ƒt1| dƒr­| j2|| | ƒq­q­Wx�|j,j-D]Œ} t3| j | j*| j+| j4ƒ} | j5| _5| j6| _6| j7| _7|| _|j,j-j0| ƒt1| dƒr | j2|| | ƒq q WqÒntjj8dt9|ƒƒ‚t1|dƒr÷|j2|||ƒn|S(so Clone a node and give it the new owner document. Called by Node.cloneNode and Document.importNode R_sCannot clone node %s(:RDRNR$R%R0R1t NODE_IMPORTEDRRR?RGRcR{R}R®RßRŠRÜRhRˆRRCR*R R`R;RcR<R~RdR€RgRþR�ReR£RjRR;RGRKRuR&R'R,R"R-R2R>RYR_R3R4R5R RJRrR'( R6REtnewOwnerDocumentR\R6RÕRhRBR5RÁR7R8R9((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRCs|                  cCs:|jddƒ}t|ƒdkr(|Sd|dfSdS(NR†iii(R‡R©R(RÝtfields((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRÛfscCsddlm}|ƒS(Niÿÿÿÿ(tStringIO(Ry(Ry((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRnscCs<|||Ž}|jƒ\}}|j|ƒ|jƒ|S(N(tgetEventt expandNodeRQ(tfunctargstkwargsteventsttoktypetrootNode((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyt_do_pulldom_parsess   cCsh|dkr0| r0ddlm}|j|ƒSddlm}t|j|fi|d6|d6ƒSdS(s3Parse a file into a DOM by filename or file object.iÿÿÿÿ(t expatbuilder(tpulldomtparsertbufsizeN(Rtxml.domRƒtparseR„R‚(tfileR…R†RƒR„((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRˆzs  cCsZ|dkr)ddlm}|j|ƒSddlm}t|j|fi|d6ƒSdS(s&Parse a file into a DOM from a string.iÿÿÿÿ(Rƒ(R„R…N(RR‡Rƒt parseStringR„R‚(tstringR…RƒR„((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyRŠ„s   cCsa|rZt|tƒr'tj|ƒ}nx0|D]%\}}tjj||ƒs.dSq.WntjS(N(R°R±Rt_parse_feature_stringRLRGRHR(tfeaturestftv((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pytgetDOMImplementationŽs (8RÉR‡R$RRRRtxml.dom.minicompattxml.dom.xmlbuilderRRR%RR?RR.t defpropertyR7RkRqRsRwRyRƒtobjectR¥t AttributeListRÎRRŸRÓRãRûRýRR„RRöRRR!R%R+R3R2R@RMR/RLRCRÛRR‚RˆRŠR�(((s4/opt/alt/python27/lib64/python2.7/xml/dom/minidom.pyts„ "  í    r• Ü   (GZ     > <( O* ÿO  R    PK:©ç\`ÖÙÆ.Æ.dom/pulldom.pynu„[µü¤import xml.sax import xml.sax.handler import types try: _StringTypes = [types.StringType, types.UnicodeType] except AttributeError: _StringTypes = [types.StringType] START_ELEMENT = "START_ELEMENT" END_ELEMENT = "END_ELEMENT" COMMENT = "COMMENT" START_DOCUMENT = "START_DOCUMENT" END_DOCUMENT = "END_DOCUMENT" PROCESSING_INSTRUCTION = "PROCESSING_INSTRUCTION" IGNORABLE_WHITESPACE = "IGNORABLE_WHITESPACE" CHARACTERS = "CHARACTERS" class PullDOM(xml.sax.ContentHandler): _locator = None document = None def __init__(self, documentFactory=None): from xml.dom import XML_NAMESPACE self.documentFactory = documentFactory self.firstEvent = [None, None] self.lastEvent = self.firstEvent self.elementStack = [] self.push = self.elementStack.append try: self.pop = self.elementStack.pop except AttributeError: # use class' pop instead pass self._ns_contexts = [{XML_NAMESPACE:'xml'}] # contains uri -> prefix dicts self._current_context = self._ns_contexts[-1] self.pending_events = [] def pop(self): result = self.elementStack[-1] del self.elementStack[-1] return result def setDocumentLocator(self, locator): self._locator = locator def startPrefixMapping(self, prefix, uri): if not hasattr(self, '_xmlns_attrs'): self._xmlns_attrs = [] self._xmlns_attrs.append((prefix or 'xmlns', uri)) self._ns_contexts.append(self._current_context.copy()) self._current_context[uri] = prefix or None def endPrefixMapping(self, prefix): self._current_context = self._ns_contexts.pop() def startElementNS(self, name, tagName , attrs): # Retrieve xml namespace declaration attributes. xmlns_uri = 'http://www.w3.org/2000/xmlns/' xmlns_attrs = getattr(self, '_xmlns_attrs', None) if xmlns_attrs is not None: for aname, value in xmlns_attrs: attrs._attrs[(xmlns_uri, aname)] = value self._xmlns_attrs = [] uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: prefix = self._current_context[uri] if prefix: tagName = prefix + ":" + localname else: tagName = localname if self.document: node = self.document.createElementNS(uri, tagName) else: node = self.buildDocument(uri, tagName) else: # When the tagname is not prefixed, it just appears as # localname if self.document: node = self.document.createElement(localname) else: node = self.buildDocument(None, localname) for aname,value in attrs.items(): a_uri, a_localname = aname if a_uri == xmlns_uri: if a_localname == 'xmlns': qname = a_localname else: qname = 'xmlns:' + a_localname attr = self.document.createAttributeNS(a_uri, qname) node.setAttributeNodeNS(attr) elif a_uri: prefix = self._current_context[a_uri] if prefix: qname = prefix + ":" + a_localname else: qname = a_localname attr = self.document.createAttributeNS(a_uri, qname) node.setAttributeNodeNS(attr) else: attr = self.document.createAttribute(a_localname) node.setAttributeNode(attr) attr.value = value self.lastEvent[1] = [(START_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] self.push(node) def endElementNS(self, name, tagName): self.lastEvent[1] = [(END_ELEMENT, self.pop()), None] self.lastEvent = self.lastEvent[1] def startElement(self, name, attrs): if self.document: node = self.document.createElement(name) else: node = self.buildDocument(None, name) for aname,value in attrs.items(): attr = self.document.createAttribute(aname) attr.value = value node.setAttributeNode(attr) self.lastEvent[1] = [(START_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] self.push(node) def endElement(self, name): self.lastEvent[1] = [(END_ELEMENT, self.pop()), None] self.lastEvent = self.lastEvent[1] def comment(self, s): if self.document: node = self.document.createComment(s) self.lastEvent[1] = [(COMMENT, node), None] self.lastEvent = self.lastEvent[1] else: event = [(COMMENT, s), None] self.pending_events.append(event) def processingInstruction(self, target, data): if self.document: node = self.document.createProcessingInstruction(target, data) self.lastEvent[1] = [(PROCESSING_INSTRUCTION, node), None] self.lastEvent = self.lastEvent[1] else: event = [(PROCESSING_INSTRUCTION, target, data), None] self.pending_events.append(event) def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) self.lastEvent[1] = [(IGNORABLE_WHITESPACE, node), None] self.lastEvent = self.lastEvent[1] def characters(self, chars): node = self.document.createTextNode(chars) self.lastEvent[1] = [(CHARACTERS, node), None] self.lastEvent = self.lastEvent[1] def startDocument(self): if self.documentFactory is None: import xml.dom.minidom self.documentFactory = xml.dom.minidom.Document.implementation def buildDocument(self, uri, tagname): # Can't do that in startDocument, since we need the tagname # XXX: obtain DocumentType node = self.documentFactory.createDocument(uri, tagname, None) self.document = node self.lastEvent[1] = [(START_DOCUMENT, node), None] self.lastEvent = self.lastEvent[1] self.push(node) # Put everything we have seen so far into the document for e in self.pending_events: if e[0][0] == PROCESSING_INSTRUCTION: _,target,data = e[0] n = self.document.createProcessingInstruction(target, data) e[0] = (PROCESSING_INSTRUCTION, n) elif e[0][0] == COMMENT: n = self.document.createComment(e[0][1]) e[0] = (COMMENT, n) else: raise AssertionError("Unknown pending event ",e[0][0]) self.lastEvent[1] = e self.lastEvent = e self.pending_events = None return node.firstChild def endDocument(self): self.lastEvent[1] = [(END_DOCUMENT, self.document), None] self.pop() def clear(self): "clear(): Explicitly release parsing structures" self.document = None class ErrorHandler: def warning(self, exception): print exception def error(self, exception): raise exception def fatalError(self, exception): raise exception class DOMEventStream: def __init__(self, stream, parser, bufsize): self.stream = stream self.parser = parser self.bufsize = bufsize if not hasattr(self.parser, 'feed'): self.getEvent = self._slurp self.reset() def reset(self): self.pulldom = PullDOM() # This content handler relies on namespace support self.parser.setFeature(xml.sax.handler.feature_namespaces, 1) self.parser.setContentHandler(self.pulldom) def __getitem__(self, pos): rc = self.getEvent() if rc: return rc raise IndexError def next(self): rc = self.getEvent() if rc: return rc raise StopIteration def __iter__(self): return self def expandNode(self, node): event = self.getEvent() parents = [node] while event: token, cur_node = event if cur_node is node: return if token != END_ELEMENT: parents[-1].appendChild(cur_node) if token == START_ELEMENT: parents.append(cur_node) elif token == END_ELEMENT: del parents[-1] event = self.getEvent() def getEvent(self): # use IncrementalParser interface, so we get the desired # pull effect if not self.pulldom.firstEvent[1]: self.pulldom.lastEvent = self.pulldom.firstEvent while not self.pulldom.firstEvent[1]: buf = self.stream.read(self.bufsize) if not buf: self.parser.close() return None self.parser.feed(buf) rc = self.pulldom.firstEvent[1][0] self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1] return rc def _slurp(self): """ Fallback replacement for getEvent() using the standard SAX2 interface, which means we slurp the SAX events into memory (no performance gain, but we are compatible to all SAX parsers). """ self.parser.parse(self.stream) self.getEvent = self._emit return self._emit() def _emit(self): """ Fallback replacement for getEvent() that emits the events that _slurp() read previously. """ rc = self.pulldom.firstEvent[1][0] self.pulldom.firstEvent[1] = self.pulldom.firstEvent[1][1] return rc def clear(self): """clear(): Explicitly release parsing objects""" self.pulldom.clear() del self.pulldom self.parser = None self.stream = None class SAX2DOM(PullDOM): def startElementNS(self, name, tagName , attrs): PullDOM.startElementNS(self, name, tagName, attrs) curNode = self.elementStack[-1] parentNode = self.elementStack[-2] parentNode.appendChild(curNode) def startElement(self, name, attrs): PullDOM.startElement(self, name, attrs) curNode = self.elementStack[-1] parentNode = self.elementStack[-2] parentNode.appendChild(curNode) def processingInstruction(self, target, data): PullDOM.processingInstruction(self, target, data) node = self.lastEvent[0][1] parentNode = self.elementStack[-1] parentNode.appendChild(node) def ignorableWhitespace(self, chars): PullDOM.ignorableWhitespace(self, chars) node = self.lastEvent[0][1] parentNode = self.elementStack[-1] parentNode.appendChild(node) def characters(self, chars): PullDOM.characters(self, chars) node = self.lastEvent[0][1] parentNode = self.elementStack[-1] parentNode.appendChild(node) default_bufsize = (2 ** 14) - 20 def parse(stream_or_string, parser=None, bufsize=None): if bufsize is None: bufsize = default_bufsize if type(stream_or_string) in _StringTypes: stream = open(stream_or_string) else: stream = stream_or_string if not parser: parser = xml.sax.make_parser() return DOMEventStream(stream, parser, bufsize) def parseString(string, parser=None): try: from cStringIO import StringIO except ImportError: from StringIO import StringIO bufsize = len(string) buf = StringIO(string) if not parser: parser = xml.sax.make_parser() return DOMEventStream(buf, parser, bufsize) PK:©ç\hH–é8585dom/pulldom.pycnu„[µü¤ó ›V~gc@sddlZddlZddlZyejejgZWnek rYejgZnXdZdZ dZ dZ dZ dZ dZd Zd ejjfd „ƒYZd dd „ƒYZddd„ƒYZdefd„ƒYZdZddd„Zdd„ZdS(iÿÿÿÿNt START_ELEMENTt END_ELEMENTtCOMMENTtSTART_DOCUMENTt END_DOCUMENTtPROCESSING_INSTRUCTIONtIGNORABLE_WHITESPACEt CHARACTERStPullDOMcBs°eZdZdZdd„Zd„Zd„Zd„Zd„Z d„Z d„Z d„Z d„Z d „Zd „Zd „Zd „Zd „Zd„Zd„Zd„ZRS(cCs£ddlm}||_ddg|_|j|_g|_|jj|_y|jj |_ Wnt k rrnXid|6g|_ |j d|_ g|_ dS(Niÿÿÿÿ(t XML_NAMESPACEtxml(txml.domR tdocumentFactorytNonet firstEventt lastEventt elementStacktappendtpushtpoptAttributeErrort _ns_contextst_current_contexttpending_events(tselfR R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt__init__s    cCs|jd}|jd=|S(Niÿÿÿÿ(R(Rtresult((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyR's  cCs ||_dS(N(t_locator(Rtlocator((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pytsetDocumentLocator,scCsgt|dƒsg|_n|jj|p-d|fƒ|jj|jjƒƒ|pYd|j|((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt startElementvs  cCs3t|jƒfdg|jd<|jd|_dS(Ni(RRR R(RR3((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt endElement…scCsm|jrG|jj|ƒ}t|fdg|jd<|jd|_n"t|fdg}|jj|ƒdS(Ni(R)t createCommentRR RRR(RtsR:tevent((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pytcomment‰s  cCss|jrJ|jj||ƒ}t|fdg|jd<|jd|_n%t||fdg}|jj|ƒdS(Ni(R)tcreateProcessingInstructionRR RRR(RttargettdataR:RE((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pytprocessingInstruction’s  cCs?|jj|ƒ}t|fdg|jd<|jd|_dS(Ni(R)tcreateTextNodeRR R(RtcharsR:((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pytignorableWhitespace›scCs?|jj|ƒ}t|fdg|jd<|jd|_dS(Ni(R)RKRR R(RRLR:((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt characters scCs7|jdkr3ddl}|jjjj|_ndS(Niÿÿÿÿ(R R txml.dom.minidomtdomtminidomtDocumenttimplementation(RR ((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt startDocument¥s c Cs8|jj||dƒ}||_t|fdg|jd<|jd|_|j|ƒxÎ|jD]Ã}|ddtkr¶|d\}}}|jj ||ƒ}t|f|dtj|||ƒ|jd}|jd}|j|ƒdS(Niÿÿÿÿiþÿÿÿ(RRARRz(RR3R5R…R†((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyRA/s  cCsBtj|||ƒ|jdd}|jd}|j|ƒdS(Niiiÿÿÿÿ(RRJRRRz(RRHRIR:R†((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyRJ5s cCs?tj||ƒ|jdd}|jd}|j|ƒdS(Niiiÿÿÿÿ(RRMRRRz(RRLR:R†((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyRM;s cCs?tj||ƒ|jdd}|jd}|j|ƒdS(Niiiÿÿÿÿ(RRNRRRz(RRLR:R†((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyRNAs (R^R_R?RARJRMRN(((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyR„'s     iiicCsd|dkrt}nt|ƒtkr6t|ƒ}n|}|sTtjjƒ}nt|||ƒS(N( R tdefault_bufsizettypet _StringTypestopenR Rot make_parserRe(tstream_or_stringRhRiRg((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyR‚Js  cCsxyddlm}Wn!tk r7ddlm}nXt|ƒ}||ƒ}|shtjjƒ}nt|||ƒS(Niÿÿÿÿ(tStringIO(t cStringIOR�t ImportErrortlenR RoR‹Re(tstringRhR�RiR�((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt parseStringUs   ((i@iì?(txml.saxR txml.sax.handlerttypest StringTypet UnicodeTypeR‰RRRRRRRRRRotContentHandlerRR`ReR„R‡R R‚R’(((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyts*    ·U! PK:©ç\hH–é8585dom/pulldom.pyonu„[µü¤ó ›V~gc@sddlZddlZddlZyejejgZWnek rYejgZnXdZdZ dZ dZ dZ dZ dZd Zd ejjfd „ƒYZd dd „ƒYZddd„ƒYZdefd„ƒYZdZddd„Zdd„ZdS(iÿÿÿÿNt START_ELEMENTt END_ELEMENTtCOMMENTtSTART_DOCUMENTt END_DOCUMENTtPROCESSING_INSTRUCTIONtIGNORABLE_WHITESPACEt CHARACTERStPullDOMcBs°eZdZdZdd„Zd„Zd„Zd„Zd„Z d„Z d„Z d„Z d„Z d „Zd „Zd „Zd „Zd „Zd„Zd„Zd„ZRS(cCs£ddlm}||_ddg|_|j|_g|_|jj|_y|jj |_ Wnt k rrnXid|6g|_ |j d|_ g|_ dS(Niÿÿÿÿ(t XML_NAMESPACEtxml(txml.domR tdocumentFactorytNonet firstEventt lastEventt elementStacktappendtpushtpoptAttributeErrort _ns_contextst_current_contexttpending_events(tselfR R ((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt__init__s    cCs|jd}|jd=|S(Niÿÿÿÿ(R(Rtresult((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyR's  cCs ||_dS(N(t_locator(Rtlocator((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pytsetDocumentLocator,scCsgt|dƒsg|_n|jj|p-d|fƒ|jj|jjƒƒ|pYd|j|((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt startElementvs  cCs3t|jƒfdg|jd<|jd|_dS(Ni(RRR R(RR3((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt endElement…scCsm|jrG|jj|ƒ}t|fdg|jd<|jd|_n"t|fdg}|jj|ƒdS(Ni(R)t createCommentRR RRR(RtsR:tevent((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pytcomment‰s  cCss|jrJ|jj||ƒ}t|fdg|jd<|jd|_n%t||fdg}|jj|ƒdS(Ni(R)tcreateProcessingInstructionRR RRR(RttargettdataR:RE((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pytprocessingInstruction’s  cCs?|jj|ƒ}t|fdg|jd<|jd|_dS(Ni(R)tcreateTextNodeRR R(RtcharsR:((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pytignorableWhitespace›scCs?|jj|ƒ}t|fdg|jd<|jd|_dS(Ni(R)RKRR R(RRLR:((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt characters scCs7|jdkr3ddl}|jjjj|_ndS(Niÿÿÿÿ(R R txml.dom.minidomtdomtminidomtDocumenttimplementation(RR ((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt startDocument¥s c Cs8|jj||dƒ}||_t|fdg|jd<|jd|_|j|ƒxÎ|jD]Ã}|ddtkr¶|d\}}}|jj ||ƒ}t|f|dtj|||ƒ|jd}|jd}|j|ƒdS(Niÿÿÿÿiþÿÿÿ(RRARRz(RR3R5R…R†((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyRA/s  cCsBtj|||ƒ|jdd}|jd}|j|ƒdS(Niiiÿÿÿÿ(RRJRRRz(RRHRIR:R†((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyRJ5s cCs?tj||ƒ|jdd}|jd}|j|ƒdS(Niiiÿÿÿÿ(RRMRRRz(RRLR:R†((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyRM;s cCs?tj||ƒ|jdd}|jd}|j|ƒdS(Niiiÿÿÿÿ(RRNRRRz(RRLR:R†((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyRNAs (R^R_R?RARJRMRN(((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyR„'s     iiicCsd|dkrt}nt|ƒtkr6t|ƒ}n|}|sTtjjƒ}nt|||ƒS(N( R tdefault_bufsizettypet _StringTypestopenR Rot make_parserRe(tstream_or_stringRhRiRg((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyR‚Js  cCsxyddlm}Wn!tk r7ddlm}nXt|ƒ}||ƒ}|shtjjƒ}nt|||ƒS(Niÿÿÿÿ(tStringIO(t cStringIOR�t ImportErrortlenR RoR‹Re(tstringRhR�RiR�((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyt parseStringUs   ((i@iì?(txml.saxR txml.sax.handlerttypest StringTypet UnicodeTypeR‰RRRRRRRRRRotContentHandlerRR`ReR„R‡R R‚R’(((s4/opt/alt/python27/lib64/python2.7/xml/dom/pulldom.pyts*    ·U! PK:©ç\l$Å„1010dom/xmlbuilder.pynu„[µü¤"""Implementation of the DOM Level 3 'LS-Load' feature.""" import copy import xml.dom from xml.dom.NodeFilter import NodeFilter __all__ = ["DOMBuilder", "DOMEntityResolver", "DOMInputSource"] class Options: """Features 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. """ # Note that the DOMBuilder class in LoadSave constrains which of these # values can be set using the DOM Level 3 LoadSave feature. namespaces = 1 namespace_declarations = True validation = False external_parameter_entities = True external_general_entities = True external_dtd_subset = True validate_if_schema = False validate = False datatype_normalization = False create_entity_ref_nodes = True entities = True whitespace_in_element_content = True cdata_sections = True comments = True charset_overrides_xml_encoding = True infoset = False supported_mediatypes_only = False errorHandler = None filter = None class DOMBuilder: entityResolver = None errorHandler = None filter = None ACTION_REPLACE = 1 ACTION_APPEND_AS_CHILDREN = 2 ACTION_INSERT_AFTER = 3 ACTION_INSERT_BEFORE = 4 _legal_actions = (ACTION_REPLACE, ACTION_APPEND_AS_CHILDREN, ACTION_INSERT_AFTER, ACTION_INSERT_BEFORE) def __init__(self): self._options = Options() def _get_entityResolver(self): return self.entityResolver def _set_entityResolver(self, entityResolver): self.entityResolver = entityResolver def _get_errorHandler(self): return self.errorHandler def _set_errorHandler(self, errorHandler): self.errorHandler = errorHandler def _get_filter(self): return self.filter def _set_filter(self, filter): self.filter = filter def setFeature(self, name, state): if self.supportsFeature(name): state = state and 1 or 0 try: settings = self._settings[(_name_xform(name), state)] except KeyError: raise xml.dom.NotSupportedErr( "unsupported feature: %r" % (name,)) else: for name, value in settings: setattr(self._options, name, value) else: raise xml.dom.NotFoundErr("unknown feature: " + repr(name)) def supportsFeature(self, name): return hasattr(self._options, _name_xform(name)) def canSetFeature(self, name, state): key = (_name_xform(name), state and 1 or 0) return key in self._settings # This dictionary maps from (feature,value) to a list of # (option,value) pairs that should be set on the Options object. # If a (feature,value) setting is not in this dictionary, it is # not supported by the DOMBuilder. # _settings = { ("namespace_declarations", 0): [ ("namespace_declarations", 0)], ("namespace_declarations", 1): [ ("namespace_declarations", 1)], ("validation", 0): [ ("validation", 0)], ("external_general_entities", 0): [ ("external_general_entities", 0)], ("external_general_entities", 1): [ ("external_general_entities", 1)], ("external_parameter_entities", 0): [ ("external_parameter_entities", 0)], ("external_parameter_entities", 1): [ ("external_parameter_entities", 1)], ("validate_if_schema", 0): [ ("validate_if_schema", 0)], ("create_entity_ref_nodes", 0): [ ("create_entity_ref_nodes", 0)], ("create_entity_ref_nodes", 1): [ ("create_entity_ref_nodes", 1)], ("entities", 0): [ ("create_entity_ref_nodes", 0), ("entities", 0)], ("entities", 1): [ ("entities", 1)], ("whitespace_in_element_content", 0): [ ("whitespace_in_element_content", 0)], ("whitespace_in_element_content", 1): [ ("whitespace_in_element_content", 1)], ("cdata_sections", 0): [ ("cdata_sections", 0)], ("cdata_sections", 1): [ ("cdata_sections", 1)], ("comments", 0): [ ("comments", 0)], ("comments", 1): [ ("comments", 1)], ("charset_overrides_xml_encoding", 0): [ ("charset_overrides_xml_encoding", 0)], ("charset_overrides_xml_encoding", 1): [ ("charset_overrides_xml_encoding", 1)], ("infoset", 0): [], ("infoset", 1): [ ("namespace_declarations", 0), ("validate_if_schema", 0), ("create_entity_ref_nodes", 0), ("entities", 0), ("cdata_sections", 0), ("datatype_normalization", 1), ("whitespace_in_element_content", 1), ("comments", 1), ("charset_overrides_xml_encoding", 1)], ("supported_mediatypes_only", 0): [ ("supported_mediatypes_only", 0)], ("namespaces", 0): [ ("namespaces", 0)], ("namespaces", 1): [ ("namespaces", 1)], } def getFeature(self, name): xname = _name_xform(name) try: return getattr(self._options, xname) except AttributeError: if name == "infoset": options = self._options return (options.datatype_normalization and options.whitespace_in_element_content and options.comments and options.charset_overrides_xml_encoding and not (options.namespace_declarations or options.validate_if_schema or options.create_entity_ref_nodes or options.entities or options.cdata_sections)) raise xml.dom.NotFoundErr("feature %s not known" % repr(name)) def parseURI(self, uri): if self.entityResolver: input = self.entityResolver.resolveEntity(None, uri) else: input = DOMEntityResolver().resolveEntity(None, uri) return self.parse(input) def parse(self, input): options = copy.copy(self._options) options.filter = self.filter options.errorHandler = self.errorHandler fp = input.byteStream if fp is None and options.systemId: import urllib2 fp = urllib2.urlopen(input.systemId) return self._parse_bytestream(fp, options) def parseWithContext(self, input, cnode, action): if action not in self._legal_actions: raise ValueError("not a legal action") raise NotImplementedError("Haven't written this yet...") def _parse_bytestream(self, stream, options): import xml.dom.expatbuilder builder = xml.dom.expatbuilder.makeBuilder(options) return builder.parseFile(stream) def _name_xform(name): return name.lower().replace('-', '_') class DOMEntityResolver(object): __slots__ = '_opener', def resolveEntity(self, publicId, systemId): assert systemId is not None source = DOMInputSource() source.publicId = publicId source.systemId = systemId source.byteStream = self._get_opener().open(systemId) # determine the encoding if the transport provided it source.encoding = self._guess_media_encoding(source) # determine the base URI is we can import posixpath, urlparse parts = urlparse.urlparse(systemId) scheme, netloc, path, params, query, fragment = parts # XXX should we check the scheme here as well? if path and not path.endswith("/"): path = posixpath.dirname(path) + "/" parts = scheme, netloc, path, params, query, fragment source.baseURI = urlparse.urlunparse(parts) return source def _get_opener(self): try: return self._opener except AttributeError: self._opener = self._create_opener() return self._opener def _create_opener(self): import urllib2 return urllib2.build_opener() def _guess_media_encoding(self, source): info = source.byteStream.info() if "Content-Type" in info: for param in info.getplist(): if param.startswith("charset="): return param.split("=", 1)[1].lower() class DOMInputSource(object): __slots__ = ('byteStream', 'characterStream', 'stringData', 'encoding', 'publicId', 'systemId', 'baseURI') def __init__(self): self.byteStream = None self.characterStream = None self.stringData = None self.encoding = None self.publicId = None self.systemId = None self.baseURI = None def _get_byteStream(self): return self.byteStream def _set_byteStream(self, byteStream): self.byteStream = byteStream def _get_characterStream(self): return self.characterStream def _set_characterStream(self, characterStream): self.characterStream = characterStream def _get_stringData(self): return self.stringData def _set_stringData(self, data): self.stringData = data def _get_encoding(self): return self.encoding def _set_encoding(self, encoding): self.encoding = encoding def _get_publicId(self): return self.publicId def _set_publicId(self, publicId): self.publicId = publicId def _get_systemId(self): return self.systemId def _set_systemId(self, systemId): self.systemId = systemId def _get_baseURI(self): return self.baseURI def _set_baseURI(self, uri): self.baseURI = uri class DOMBuilderFilter: """Element filter which can be used to tailor construction of a DOM instance. """ # There's really no need for this class; concrete implementations # should just implement the endElement() and startElement() # methods as appropriate. Using this makes it easy to only # implement one of them. FILTER_ACCEPT = 1 FILTER_REJECT = 2 FILTER_SKIP = 3 FILTER_INTERRUPT = 4 whatToShow = NodeFilter.SHOW_ALL def _get_whatToShow(self): return self.whatToShow def acceptNode(self, element): return self.FILTER_ACCEPT def startContainer(self, element): return self.FILTER_ACCEPT del NodeFilter class DocumentLS: """Mixin to create documents that conform to the load/save spec.""" async = False def _get_async(self): return False def _set_async(self, async): if async: raise xml.dom.NotSupportedErr( "asynchronous document loading is not supported") def abort(self): # What does it mean to "clear" a document? Does the # documentElement disappear? raise NotImplementedError( "haven't figured out what this means yet") def load(self, uri): raise NotImplementedError("haven't written this yet") def loadXML(self, source): raise NotImplementedError("haven't written this yet") def saveXML(self, snode): if snode is None: snode = self elif snode.ownerDocument is not self: raise xml.dom.WrongDocumentErr() return snode.toxml() class DOMImplementationLS: MODE_SYNCHRONOUS = 1 MODE_ASYNCHRONOUS = 2 def createDOMBuilder(self, mode, schemaType): if schemaType is not None: raise xml.dom.NotSupportedErr( "schemaType not yet supported") if mode == self.MODE_SYNCHRONOUS: return DOMBuilder() if mode == self.MODE_ASYNCHRONOUS: raise xml.dom.NotSupportedErr( "asynchronous builders are not supported") raise ValueError("unknown value for mode") def createDOMWriter(self): raise NotImplementedError( "the writer interface hasn't been written yet!") def createDOMInputSource(self): return DOMInputSource() PK:©ç\2+Æ·>·>dom/xmlbuilder.pycnu„[µü¤ó ›V~gc@sØdZddlZddlZddlmZdddgZddd„ƒYZddd „ƒYZd „Z de fd „ƒYZ de fd „ƒYZ d dd„ƒYZ [ddd„ƒYZddd„ƒYZdS(s4Implementation of the DOM Level 3 'LS-Load' feature.iÿÿÿÿN(t NodeFiltert DOMBuildertDOMEntityResolvertDOMInputSourcetOptionscBs€eZdZdZeZeZeZeZ eZ eZ eZ eZ eZeZeZeZeZeZeZeZdZdZRS(s±Features 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. iN(t__name__t __module__t__doc__t namespacestTruetnamespace_declarationstFalset validationtexternal_parameter_entitiestexternal_general_entitiestexternal_dtd_subsettvalidate_if_schematvalidatetdatatype_normalizationtcreate_entity_ref_nodestentitiestwhitespace_in_element_contenttcdata_sectionstcommentstcharset_overrides_xml_encodingtinfosettsupported_mediatypes_onlytNonet errorHandlertfilter(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR s(c BsãeZd#Zd#Zd#ZdZdZdZdZ eeee fZ d„Z d„Z d„Z d„Zd„Zd „Zd „Zd „Zd „Zd „Zid$gd%6d&gd'6d(gd)6d*gd+6d,gd-6d.gd/6d0gd16d2gd36d4gd56d6gd76d8d9gd:6d;gd<6d=gd>6d?gd@6dAgdB6dCgdD6dEgdF6dGgdH6dIgdJ6dKgdL6gdM6dNdOdPdQdRdSdTdUdVg dW6dXgdY6dZgd[6d\gd]6Zd„Zd„Zd „Zd!„Zd"„ZRS(^iiiicCstƒ|_dS(N(Rt_options(tself((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt__init__9scCs|jS(N(tentityResolver(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_entityResolver<scCs ||_dS(N(R!(RR!((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_entityResolver>scCs|jS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_errorHandlerAscCs ||_dS(N(R(RR((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_errorHandlerCscCs|jS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_filterFscCs ||_dS(N(R(RR((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_filterHscCs¸|j|ƒr˜|rdpd}y|jt|ƒ|f}Wn*tk rjtjjd|fƒ‚q´XxF|D]\}}t|j||ƒqrWntjj dt |ƒƒ‚dS(Niisunsupported feature: %rsunknown feature: ( tsupportsFeaturet _settingst _name_xformtKeyErrortxmltdomtNotSupportedErrtsetattrRt NotFoundErrtrepr(Rtnametstatetsettingstvalue((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt setFeatureKs  cCst|jt|ƒƒS(N(thasattrRR*(RR2((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR(YscCs+t|ƒ|rdpdf}||jkS(Nii(R*R)(RR2R3tkey((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt canSetFeature\sR iR RR RRRRRRRRRRRcCs¹t|ƒ}yt|j|ƒSWn’tk r´|dkr•|j}|jo”|jo”|jo”|jo”|jp“|j p“|j p“|j p“|j St jjdt|ƒƒ‚nXdS(NRsfeature %s not known(R*tgetattrRtAttributeErrorRRRRR RRRRR,R-R0R1(RR2txnametoptions((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt getFeature¢s             cCsC|jr!|jjd|ƒ}ntƒjd|ƒ}|j|ƒS(N(R!t resolveEntityRRtparse(Rturitinput((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytparseURI´s cCsytj|jƒ}|j|_|j|_|j}|dkri|jriddl}|j|jƒ}n|j ||ƒS(Niÿÿÿÿ( tcopyRRRt byteStreamRtsystemIdturllib2turlopent_parse_bytestream(RRBR=tfpRG((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR@»s    cCs.||jkrtdƒ‚ntdƒ‚dS(Nsnot a legal actionsHaven't written this yet...(t_legal_actionst ValueErrortNotImplementedError(RRBtcnodetaction((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytparseWithContextÅscCs.ddl}|jjj|ƒ}|j|ƒS(Niÿÿÿÿ(txml.dom.expatbuilderR-t expatbuildert makeBuildert parseFile(RtstreamR=R,tbuilder((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRIÊs N(R i(R i(R i(R i(R i(R i(Ri(Ri(Ri(Ri(R i(R i(R i(R i(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(R i(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(RRRR!RRtACTION_REPLACEtACTION_APPEND_AS_CHILDRENtACTION_INSERT_AFTERtACTION_INSERT_BEFORERKR R"R#R$R%R&R'R6R(R9R)R>RCR@RPRI(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR,sv                                      cCs|jƒjddƒS(Nt-t_(tlowertreplace(R2((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR*ÐscBs2eZdZd„Zd„Zd„Zd„ZRS(t_openerc Csð|dk st‚tƒ}||_||_|jƒj|ƒ|_|j|ƒ|_ ddl }ddl }|j |ƒ}|\}}} } } } | rì| j dƒ rì|j | ƒd} ||| | | | f}|j|ƒ|_n|S(Niÿÿÿÿt/(RtAssertionErrorRtpublicIdRFt _get_openertopenREt_guess_media_encodingtencodingt posixpathturlparsetendswithtdirnamet urlunparsetbaseURI( RRbRFtsourceRgRhtpartstschemetnetloctpathtparamstquerytfragment((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR?×s   cCs6y |jSWn$tk r1|jƒ|_|jSXdS(N(R_R;t_create_opener(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRcís   cCsddl}|jƒS(Niÿÿÿÿ(RGt build_opener(RRG((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRuôs cCsb|jjƒ}d|kr^x@|jƒD]/}|jdƒr(|jddƒdjƒSq(WndS(Ns Content-Typescharset=t=i(REtinfotgetplistt startswithtsplitR](RRmRxtparam((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyReøs  (R_(RRt __slots__R?RcRuRe(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRÔs    cBs•eZdZd„Zd„Zd „Zd „Zd „Zd „Zd „Z d„Z d„Z d„Z d„Z d„Zd„Zd„Zd„ZRS(REtcharacterStreamt stringDataRfRbRFRlcCsCd|_d|_d|_d|_d|_d|_d|_dS(N(RRER~RRfRbRFRl(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR s      cCs|jS(N(RE(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_byteStream scCs ||_dS(N(RE(RRE((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_byteStreamscCs|jS(N(R~(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_characterStreamscCs ||_dS(N(R~(RR~((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_characterStreamscCs|jS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_stringDatascCs ||_dS(N(R(Rtdata((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_stringDatascCs|jS(N(Rf(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_encodingscCs ||_dS(N(Rf(RRf((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_encodingscCs|jS(N(Rb(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_publicId!scCs ||_dS(N(Rb(RRb((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_publicId#scCs|jS(N(RF(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_systemId&scCs ||_dS(N(RF(RRF((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_systemId(scCs|jS(N(Rl(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_baseURI+scCs ||_dS(N(Rl(RRA((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_baseURI-s(RER~RRfRbRFRl(RRR}R R€R�R‚RƒR„R†R‡RˆR‰RŠR‹RŒR�RŽ(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRs"             tDOMBuilderFiltercBsJeZdZdZdZdZdZejZ d„Z d„Z d„Z RS(sSElement filter which can be used to tailor construction of a DOM instance. iiiicCs|jS(N(t whatToShow(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_whatToShowBscCs|jS(N(t FILTER_ACCEPT(Rtelement((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt acceptNodeEscCs|jS(N(R’(RR“((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytstartContainerHs( RRRR’t FILTER_REJECTt FILTER_SKIPtFILTER_INTERRUPTRtSHOW_ALLR�R‘R”R•(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR�1s   t DocumentLScBsJeZdZeZd„Zd„Zd„Zd„Zd„Z d„Z RS(s=Mixin to create documents that conform to the load/save spec.cCstS(N(R (R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_asyncSscCs|rtjjdƒ‚ndS(Ns.asynchronous document loading is not supported(R,R-R.(Rtasync((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_asyncUs cCstdƒ‚dS(Ns'haven't figured out what this means yet(RM(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytabortZscCstdƒ‚dS(Nshaven't written this yet(RM(RRA((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytload`scCstdƒ‚dS(Nshaven't written this yet(RM(RRm((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytloadXMLcscCs@|dkr|}n!|j|k r6tjjƒ‚n|jƒS(N(Rt ownerDocumentR,R-tWrongDocumentErrttoxml(Rtsnode((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytsaveXMLfs   ( RRRR RœR›R�RžRŸR R¥(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRšNs     tDOMImplementationLScBs/eZdZdZd„Zd„Zd„ZRS(iicCsk|dk r!tjjdƒ‚n||jkr7tƒS||jkr[tjjdƒ‚ntdƒ‚dS(NsschemaType not yet supporteds'asynchronous builders are not supportedsunknown value for mode(RR,R-R.tMODE_SYNCHRONOUSRtMODE_ASYNCHRONOUSRL(Rtmodet schemaType((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytcreateDOMBuilderrs     cCstdƒ‚dS(Ns-the writer interface hasn't been written yet!(RM(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytcreateDOMWriter}scCstƒS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytcreateDOMInputSource�s(RRR§R¨R«R¬R­(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR¦ns  ((((((RRDtxml.domR,txml.dom.NodeFilterRt__all__RRR*tobjectRRR�RšR¦(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyts   ¤ ,1 PK:©ç\/Ú1‹>‹>dom/xmlbuilder.pyonu„[µü¤ó ›V~gc@sØdZddlZddlZddlmZdddgZddd„ƒYZddd „ƒYZd „Z de fd „ƒYZ de fd „ƒYZ d dd„ƒYZ [ddd„ƒYZddd„ƒYZdS(s4Implementation of the DOM Level 3 'LS-Load' feature.iÿÿÿÿN(t NodeFiltert DOMBuildertDOMEntityResolvertDOMInputSourcetOptionscBs€eZdZdZeZeZeZeZ eZ eZ eZ eZ eZeZeZeZeZeZeZeZdZdZRS(s±Features 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. iN(t__name__t __module__t__doc__t namespacestTruetnamespace_declarationstFalset validationtexternal_parameter_entitiestexternal_general_entitiestexternal_dtd_subsettvalidate_if_schematvalidatetdatatype_normalizationtcreate_entity_ref_nodestentitiestwhitespace_in_element_contenttcdata_sectionstcommentstcharset_overrides_xml_encodingtinfosettsupported_mediatypes_onlytNonet errorHandlertfilter(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR s(c BsãeZd#Zd#Zd#ZdZdZdZdZ eeee fZ d„Z d„Z d„Z d„Zd„Zd „Zd „Zd „Zd „Zd „Zid$gd%6d&gd'6d(gd)6d*gd+6d,gd-6d.gd/6d0gd16d2gd36d4gd56d6gd76d8d9gd:6d;gd<6d=gd>6d?gd@6dAgdB6dCgdD6dEgdF6dGgdH6dIgdJ6dKgdL6gdM6dNdOdPdQdRdSdTdUdVg dW6dXgdY6dZgd[6d\gd]6Zd„Zd„Zd „Zd!„Zd"„ZRS(^iiiicCstƒ|_dS(N(Rt_options(tself((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt__init__9scCs|jS(N(tentityResolver(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_entityResolver<scCs ||_dS(N(R!(RR!((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_entityResolver>scCs|jS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_errorHandlerAscCs ||_dS(N(R(RR((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_errorHandlerCscCs|jS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_filterFscCs ||_dS(N(R(RR((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_filterHscCs¸|j|ƒr˜|rdpd}y|jt|ƒ|f}Wn*tk rjtjjd|fƒ‚q´XxF|D]\}}t|j||ƒqrWntjj dt |ƒƒ‚dS(Niisunsupported feature: %rsunknown feature: ( tsupportsFeaturet _settingst _name_xformtKeyErrortxmltdomtNotSupportedErrtsetattrRt NotFoundErrtrepr(Rtnametstatetsettingstvalue((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt setFeatureKs  cCst|jt|ƒƒS(N(thasattrRR*(RR2((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR(YscCs+t|ƒ|rdpdf}||jkS(Nii(R*R)(RR2R3tkey((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt canSetFeature\sR iR RR RRRRRRRRRRRcCs¹t|ƒ}yt|j|ƒSWn’tk r´|dkr•|j}|jo”|jo”|jo”|jo”|jp“|j p“|j p“|j p“|j St jjdt|ƒƒ‚nXdS(NRsfeature %s not known(R*tgetattrRtAttributeErrorRRRRR RRRRR,R-R0R1(RR2txnametoptions((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt getFeature¢s             cCsC|jr!|jjd|ƒ}ntƒjd|ƒ}|j|ƒS(N(R!t resolveEntityRRtparse(Rturitinput((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytparseURI´s cCsytj|jƒ}|j|_|j|_|j}|dkri|jriddl}|j|jƒ}n|j ||ƒS(Niÿÿÿÿ( tcopyRRRt byteStreamRtsystemIdturllib2turlopent_parse_bytestream(RRBR=tfpRG((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR@»s    cCs.||jkrtdƒ‚ntdƒ‚dS(Nsnot a legal actionsHaven't written this yet...(t_legal_actionst ValueErrortNotImplementedError(RRBtcnodetaction((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytparseWithContextÅscCs.ddl}|jjj|ƒ}|j|ƒS(Niÿÿÿÿ(txml.dom.expatbuilderR-t expatbuildert makeBuildert parseFile(RtstreamR=R,tbuilder((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRIÊs N(R i(R i(R i(R i(R i(R i(Ri(Ri(Ri(Ri(R i(R i(R i(R i(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(R i(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(Ri(RRRR!RRtACTION_REPLACEtACTION_APPEND_AS_CHILDRENtACTION_INSERT_AFTERtACTION_INSERT_BEFORERKR R"R#R$R%R&R'R6R(R9R)R>RCR@RPRI(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR,sv                                      cCs|jƒjddƒS(Nt-t_(tlowertreplace(R2((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR*ÐscBs2eZdZd„Zd„Zd„Zd„ZRS(t_openerc CsÞtƒ}||_||_|jƒj|ƒ|_|j|ƒ|_ddl}ddl }|j |ƒ}|\}}} } } } | rÚ| j dƒ rÚ|j | ƒd} ||| | | | f}|j |ƒ|_ n|S(Niÿÿÿÿt/(RtpublicIdRFt _get_openertopenREt_guess_media_encodingtencodingt posixpathturlparsetendswithtdirnamet urlunparsetbaseURI( RRaRFtsourceRfRgtpartstschemetnetloctpathtparamstquerytfragment((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR?×s   cCs6y |jSWn$tk r1|jƒ|_|jSXdS(N(R_R;t_create_opener(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRbís   cCsddl}|jƒS(Niÿÿÿÿ(RGt build_opener(RRG((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRtôs cCsb|jjƒ}d|kr^x@|jƒD]/}|jdƒr(|jddƒdjƒSq(WndS(Ns Content-Typescharset=t=i(REtinfotgetplistt startswithtsplitR](RRlRwtparam((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRdøs  (R_(RRt __slots__R?RbRtRd(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRÔs    cBs•eZdZd„Zd„Zd „Zd „Zd „Zd „Zd „Z d„Z d„Z d„Z d„Z d„Zd„Zd„Zd„ZRS(REtcharacterStreamt stringDataReRaRFRkcCsCd|_d|_d|_d|_d|_d|_d|_dS(N(RRER}R~ReRaRFRk(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR s      cCs|jS(N(RE(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_byteStream scCs ||_dS(N(RE(RRE((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_byteStreamscCs|jS(N(R}(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_characterStreamscCs ||_dS(N(R}(RR}((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_characterStreamscCs|jS(N(R~(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_stringDatascCs ||_dS(N(R~(Rtdata((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_set_stringDatascCs|jS(N(Re(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_encodingscCs ||_dS(N(Re(RRe((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_encodingscCs|jS(N(Ra(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_publicId!scCs ||_dS(N(Ra(RRa((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_publicId#scCs|jS(N(RF(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_systemId&scCs ||_dS(N(RF(RRF((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_systemId(scCs|jS(N(Rk(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_baseURI+scCs ||_dS(N(Rk(RRA((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_baseURI-s(RER}R~ReRaRFRk(RRR|R RR€R�R‚RƒR…R†R‡RˆR‰RŠR‹RŒR�(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRs"             tDOMBuilderFiltercBsJeZdZdZdZdZdZejZ d„Z d„Z d„Z RS(sSElement filter which can be used to tailor construction of a DOM instance. iiiicCs|jS(N(t whatToShow(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt_get_whatToShowBscCs|jS(N(t FILTER_ACCEPT(Rtelement((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt acceptNodeEscCs|jS(N(R‘(RR’((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytstartContainerHs( RRRR‘t FILTER_REJECTt FILTER_SKIPtFILTER_INTERRUPTRtSHOW_ALLR�R�R“R”(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyRŽ1s   t DocumentLScBsJeZdZeZd„Zd„Zd„Zd„Zd„Z d„Z RS(s=Mixin to create documents that conform to the load/save spec.cCstS(N(R (R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _get_asyncSscCs|rtjjdƒ‚ndS(Ns.asynchronous document loading is not supported(R,R-R.(Rtasync((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyt _set_asyncUs cCstdƒ‚dS(Ns'haven't figured out what this means yet(RM(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytabortZscCstdƒ‚dS(Nshaven't written this yet(RM(RRA((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytload`scCstdƒ‚dS(Nshaven't written this yet(RM(RRl((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytloadXMLcscCs@|dkr|}n!|j|k r6tjjƒ‚n|jƒS(N(Rt ownerDocumentR,R-tWrongDocumentErrttoxml(Rtsnode((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytsaveXMLfs   ( RRRR R›RšRœR�RžRŸR¤(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR™Ns     tDOMImplementationLScBs/eZdZdZd„Zd„Zd„ZRS(iicCsk|dk r!tjjdƒ‚n||jkr7tƒS||jkr[tjjdƒ‚ntdƒ‚dS(NsschemaType not yet supporteds'asynchronous builders are not supportedsunknown value for mode(RR,R-R.tMODE_SYNCHRONOUSRtMODE_ASYNCHRONOUSRL(Rtmodet schemaType((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytcreateDOMBuilderrs     cCstdƒ‚dS(Ns-the writer interface hasn't been written yet!(RM(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytcreateDOMWriter}scCstƒS(N(R(R((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pytcreateDOMInputSource�s(RRR¦R§RªR«R¬(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyR¥ns  ((((((RRDtxml.domR,txml.dom.NodeFilterRt__all__RRR*tobjectRRRŽR™R¥(((s7/opt/alt/python27/lib64/python2.7/xml/dom/xmlbuilder.pyts   ¤ ,1 PK:©ç\ÎïÔÔetree/ElementInclude.pynu„[µü¤# # ElementTree # $Id: ElementInclude.py 3375 2008-02-13 08:05:08Z fredrik $ # # limited xinclude support for element trees # # history: # 2003-08-15 fl created # 2003-11-14 fl fixed default loader # # Copyright (c) 2003-2004 by Fredrik Lundh. All rights reserved. # # fredrik@pythonware.com # http://www.pythonware.com # # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2008 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Secret Labs AB or the author not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See http://www.python.org/psf/license for licensing details. ## # Limited XInclude support for the ElementTree package. ## import copy from . import ElementTree XINCLUDE = "{http://www.w3.org/2001/XInclude}" XINCLUDE_INCLUDE = XINCLUDE + "include" XINCLUDE_FALLBACK = XINCLUDE + "fallback" ## # Fatal include error. class FatalIncludeError(SyntaxError): pass ## # Default loader. This loader reads an included resource from disk. # # @param href Resource reference. # @param parse Parse mode. Either "xml" or "text". # @param encoding Optional text encoding. # @return The expanded resource. If the parse mode is "xml", this # is an ElementTree instance. If the parse mode is "text", this # is a Unicode string. If the loader fails, it can return None # or raise an IOError exception. # @throws IOError If the loader fails to load the resource. def default_loader(href, parse, encoding=None): with open(href) as file: if parse == "xml": data = ElementTree.parse(file).getroot() else: data = file.read() if encoding: data = data.decode(encoding) return data ## # Expand XInclude directives. # # @param elem Root element. # @param loader Optional resource loader. If omitted, it defaults # to {@link default_loader}. If given, it should be a callable # that implements the same interface as default_loader. # @throws FatalIncludeError If the function fails to include a given # resource, or if the tree contains malformed XInclude elements. # @throws IOError If the function fails to load a given resource. def include(elem, loader=None): if loader is None: loader = default_loader # look for xinclude elements i = 0 while i < len(elem): e = elem[i] if e.tag == XINCLUDE_INCLUDE: # process xinclude directive href = e.get("href") parse = e.get("parse", "xml") if parse == "xml": node = loader(href, parse) if node is None: raise FatalIncludeError( "cannot load %r as %r" % (href, parse) ) node = copy.copy(node) if e.tail: node.tail = (node.tail or "") + e.tail elem[i] = node elif parse == "text": text = loader(href, parse, e.get("encoding")) if text is None: raise FatalIncludeError( "cannot load %r as %r" % (href, parse) ) if i: node = elem[i-1] node.tail = (node.tail or "") + text + (e.tail or "") else: elem.text = (elem.text or "") + text + (e.tail or "") del elem[i] continue else: raise FatalIncludeError( "unknown parse type in xi:include tag (%r)" % parse ) elif e.tag == XINCLUDE_FALLBACK: raise FatalIncludeError( "xi:fallback tag must be child of xi:include (%r)" % e.tag ) else: include(e, loader) i = i + 1 PK:©ç\\¦‹ããetree/ElementInclude.pycnu„[µü¤ó ›V~gc@shddlZddlmZdZedZedZdefd„ƒYZdd „Z dd „Z dS( iÿÿÿÿNi(t ElementTrees!{http://www.w3.org/2001/XInclude}tincludetfallbacktFatalIncludeErrorcBseZRS((t__name__t __module__(((s=/opt/alt/python27/lib64/python2.7/xml/etree/ElementInclude.pyR>scCsat|ƒ�O}|dkr3tj|ƒjƒ}n$|jƒ}|rW|j|ƒ}nWdQX|S(Ntxml(topenRtparsetgetroottreadtdecode(threfRtencodingtfiletdata((s=/opt/alt/python27/lib64/python2.7/xml/etree/ElementInclude.pytdefault_loaderMs  cCsø|dkrt}nd}xÖ|t|ƒkró||}|jtkr´|jdƒ}|jddƒ}|dkrë|||ƒ}|dkrªtd||fƒ‚ntj|ƒ}|jrÞ|jpÎd|j|_n|||3s    PK:©ç\\¦‹ããetree/ElementInclude.pyonu„[µü¤ó ›V~gc@shddlZddlmZdZedZedZdefd„ƒYZdd „Z dd „Z dS( iÿÿÿÿNi(t ElementTrees!{http://www.w3.org/2001/XInclude}tincludetfallbacktFatalIncludeErrorcBseZRS((t__name__t __module__(((s=/opt/alt/python27/lib64/python2.7/xml/etree/ElementInclude.pyR>scCsat|ƒ�O}|dkr3tj|ƒjƒ}n$|jƒ}|rW|j|ƒ}nWdQX|S(Ntxml(topenRtparsetgetroottreadtdecode(threfRtencodingtfiletdata((s=/opt/alt/python27/lib64/python2.7/xml/etree/ElementInclude.pytdefault_loaderMs  cCsø|dkrt}nd}xÖ|t|ƒkró||}|jtkr´|jdƒ}|jddƒ}|dkrë|||ƒ}|dkrªtd||fƒ‚ntj|ƒ}|jrÞ|jpÎd|j|_n|||3s    PK:©ç\E¢²g%%etree/ElementPath.pynu„[µü¤# # ElementTree # $Id: ElementPath.py 3375 2008-02-13 08:05:08Z fredrik $ # # limited xpath support for element trees # # history: # 2003-05-23 fl created # 2003-05-28 fl added support for // etc # 2003-08-27 fl fixed parsing of periods in element names # 2007-09-10 fl new selection engine # 2007-09-12 fl fixed parent selector # 2007-09-13 fl added iterfind; changed findall to return a list # 2007-11-30 fl added namespaces support # 2009-10-30 fl added child element value filter # # Copyright (c) 2003-2009 by Fredrik Lundh. All rights reserved. # # fredrik@pythonware.com # http://www.pythonware.com # # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2009 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Secret Labs AB or the author not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See http://www.python.org/psf/license for licensing details. ## # Implementation module for XPath support. There's usually no reason # to import this module directly; the ElementTree does this for # you, if needed. ## import re xpath_tokenizer_re = re.compile( "(" "'[^']*'|\"[^\"]*\"|" "::|" "//?|" "\.\.|" "\(\)|" "[/.*:\[\]\(\)@=])|" "((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|" "\s+" ) def xpath_tokenizer(pattern, namespaces=None): for token in xpath_tokenizer_re.findall(pattern): tag = token[1] if tag and tag[0] != "{" and ":" in tag: try: prefix, uri = tag.split(":", 1) if not namespaces: raise KeyError yield token[0], "{%s}%s" % (namespaces[prefix], uri) except KeyError: raise SyntaxError("prefix %r not found in prefix map" % prefix) else: yield token def get_parent_map(context): parent_map = context.parent_map if parent_map is None: context.parent_map = parent_map = {} for p in context.root.iter(): for e in p: parent_map[e] = p return parent_map def prepare_child(next, token): tag = token[1] def select(context, result): for elem in result: for e in elem: if e.tag == tag: yield e return select def prepare_star(next, token): def select(context, result): for elem in result: for e in elem: yield e return select def prepare_self(next, token): def select(context, result): for elem in result: yield elem return select def prepare_descendant(next, token): token = next() if token[0] == "*": tag = "*" elif not token[0]: tag = token[1] else: raise SyntaxError("invalid descendant") def select(context, result): for elem in result: for e in elem.iter(tag): if e is not elem: yield e return select def prepare_parent(next, token): def select(context, result): # FIXME: raise error if .. is applied at toplevel? parent_map = get_parent_map(context) result_map = {} for elem in result: if elem in parent_map: parent = parent_map[elem] if parent not in result_map: result_map[parent] = None yield parent return select def prepare_predicate(next, token): # FIXME: replace with real parser!!! refs: # http://effbot.org/zone/simple-iterator-parser.htm # http://javascript.crockford.com/tdop/tdop.html signature = [] predicate = [] while 1: token = next() if token[0] == "]": break if token[0] and token[0][:1] in "'\"": token = "'", token[0][1:-1] signature.append(token[0] or "-") predicate.append(token[1]) signature = "".join(signature) # use signature to determine predicate type if signature == "@-": # [@attribute] predicate key = predicate[1] def select(context, result): for elem in result: if elem.get(key) is not None: yield elem return select if signature == "@-='": # [@attribute='value'] key = predicate[1] value = predicate[-1] def select(context, result): for elem in result: if elem.get(key) == value: yield elem return select if signature == "-" and not re.match("\d+$", predicate[0]): # [tag] tag = predicate[0] def select(context, result): for elem in result: if elem.find(tag) is not None: yield elem return select if signature == "-='" and not re.match("\d+$", predicate[0]): # [tag='value'] tag = predicate[0] value = predicate[-1] def select(context, result): for elem in result: for e in elem.findall(tag): if "".join(e.itertext()) == value: yield elem break return select if signature == "-" or signature == "-()" or signature == "-()-": # [index] or [last()] or [last()-index] if signature == "-": index = int(predicate[0]) - 1 else: if predicate[0] != "last": raise SyntaxError("unsupported function") if signature == "-()-": try: index = int(predicate[2]) - 1 except ValueError: raise SyntaxError("unsupported expression") else: index = -1 def select(context, result): parent_map = get_parent_map(context) for elem in result: try: parent = parent_map[elem] # FIXME: what if the selector is "*" ? elems = list(parent.findall(elem.tag)) if elems[index] is elem: yield elem except (IndexError, KeyError): pass return select raise SyntaxError("invalid predicate") ops = { "": prepare_child, "*": prepare_star, ".": prepare_self, "..": prepare_parent, "//": prepare_descendant, "[": prepare_predicate, } _cache = {} class _SelectorContext: parent_map = None def __init__(self, root): self.root = root # -------------------------------------------------------------------- ## # Generate all matching objects. def iterfind(elem, path, namespaces=None): # compile selector pattern if path[-1:] == "/": path = path + "*" # implicit all (FIXME: keep this?) try: selector = _cache[path] except KeyError: if len(_cache) > 100: _cache.clear() if path[:1] == "/": raise SyntaxError("cannot use absolute path on element") next = iter(xpath_tokenizer(path, namespaces)).next token = next() selector = [] while 1: try: selector.append(ops[token[0]](next, token)) except StopIteration: raise SyntaxError("invalid path") try: token = next() if token[0] == "/": token = next() except StopIteration: break _cache[path] = selector # execute selector pattern result = [elem] context = _SelectorContext(elem) for select in selector: result = select(context, result) return result ## # Find first matching object. def find(elem, path, namespaces=None): try: return iterfind(elem, path, namespaces).next() except StopIteration: return None ## # Find all matching objects. def findall(elem, path, namespaces=None): return list(iterfind(elem, path, namespaces)) ## # Find text for first matching object. def findtext(elem, path, default=None, namespaces=None): try: elem = iterfind(elem, path, namespaces).next() return elem.text or "" except StopIteration: return default PK:©ç\w¶Ëetree/ElementPath.pycnu„[µü¤ó ›V~gc@sæddlZejdƒZdd„Zd„Zd„Zd„Zd„Zd„Z d „Z d „Z ied 6ed 6ed 6e d6e d6e d6Z iZ ddd„ƒYZdd„Zdd„Zdd„Zddd„ZdS(iÿÿÿÿNsY('[^']*'|"[^"]*"|::|//?|\.\.|\(\)|[/.*:\[\]\(\)@=])|((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|\s+ccs¾x·tj|ƒD]¦}|d}|r±|ddkr±d|kr±yH|jddƒ\}}|slt‚n|dd|||ffVWq¶tk r­td|ƒ‚q¶Xq|VqWdS(Niit{t:s{%s}%ss!prefix %r not found in prefix map(txpath_tokenizer_retfindalltsplittKeyErrort SyntaxError(tpatternt namespacesttokenttagtprefixturi((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pytxpath_tokenizerIs " ! cCs^|j}|dkrZi|_}x5|jjƒD]!}x|D]}|||tjd |dƒ r>|d‰‡fd†}|S|dkr‹tjd |dƒ r‹|d‰|d‰‡‡fd†}|S|dks¯|dks¯|dkrQ|dkrÒt|dƒd‰nl|ddkrñtdƒ‚n|dkr8yt|dƒd‰Wq>tk r4tdƒ‚q>Xnd‰‡fd†}|Stdƒ‚dS(Nit]is'"t'iÿÿÿÿt-ts@-c3s2x+|D]#}|jˆƒdk r|VqqWdS(N(tgetR(RRR(tkey(s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR¥s s@-='c3s2x+|D]#}|jˆƒˆkr|VqqWdS(N(R&(RRR(R'tvalue(s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR®s s\d+$c3s2x+|D]#}|jˆƒdk r|VqqWdS(N(tfindR(RRR(R (s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR¶s s-='c3sSxL|D]D}x;|jˆƒD]*}dj|jƒƒˆkr|VPqqWqWdS(NR%(Rtjointitertext(RRRR(R R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR¿s  s-()s-()-tlastsunsupported functionisunsupported expressionc3syt|ƒ}xf|D]^}y>||}t|j|jƒƒ}|ˆ|krV|VnWqttfk rpqXqWdS(N(RtlistRR t IndexErrorR(RRRRR telems(tindex(s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyRÔs    sinvalid predicate(tappendR*tretmatchtintRt ValueError(RR t signaturet predicateR((R0R'R R(s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pytprepare_predicate’sV      # #  $    R%Rt.s..s//t[t_SelectorContextcBseZdZd„ZRS(cCs ||_dS(N(R(tselfR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyt__init__ïsN(t__name__t __module__RRR=(((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR;ísc Csn|ddkr|d}nyt|}Wntk r4ttƒdkrZtjƒn|d dkrytdƒ‚ntt||ƒƒj}|ƒ}g}x„y"|jt |d||ƒƒWnt k rätdƒ‚nXy)|ƒ}|ddkr |ƒ}nWq£t k r"Pq£Xq£W|t|;s.      P  $ PK:©ç\w¶Ëetree/ElementPath.pyonu„[µü¤ó ›V~gc@sæddlZejdƒZdd„Zd„Zd„Zd„Zd„Zd„Z d „Z d „Z ied 6ed 6ed 6e d6e d6e d6Z iZ ddd„ƒYZdd„Zdd„Zdd„Zddd„ZdS(iÿÿÿÿNsY('[^']*'|"[^"]*"|::|//?|\.\.|\(\)|[/.*:\[\]\(\)@=])|((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|\s+ccs¾x·tj|ƒD]¦}|d}|r±|ddkr±d|kr±yH|jddƒ\}}|slt‚n|dd|||ffVWq¶tk r­td|ƒ‚q¶Xq|VqWdS(Niit{t:s{%s}%ss!prefix %r not found in prefix map(txpath_tokenizer_retfindalltsplittKeyErrort SyntaxError(tpatternt namespacesttokenttagtprefixturi((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pytxpath_tokenizerIs " ! cCs^|j}|dkrZi|_}x5|jjƒD]!}x|D]}|||tjd |dƒ r>|d‰‡fd†}|S|dkr‹tjd |dƒ r‹|d‰|d‰‡‡fd†}|S|dks¯|dks¯|dkrQ|dkrÒt|dƒd‰nl|ddkrñtdƒ‚n|dkr8yt|dƒd‰Wq>tk r4tdƒ‚q>Xnd‰‡fd†}|Stdƒ‚dS(Nit]is'"t'iÿÿÿÿt-ts@-c3s2x+|D]#}|jˆƒdk r|VqqWdS(N(tgetR(RRR(tkey(s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR¥s s@-='c3s2x+|D]#}|jˆƒˆkr|VqqWdS(N(R&(RRR(R'tvalue(s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR®s s\d+$c3s2x+|D]#}|jˆƒdk r|VqqWdS(N(tfindR(RRR(R (s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR¶s s-='c3sSxL|D]D}x;|jˆƒD]*}dj|jƒƒˆkr|VPqqWqWdS(NR%(Rtjointitertext(RRRR(R R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR¿s  s-()s-()-tlastsunsupported functionisunsupported expressionc3syt|ƒ}xf|D]^}y>||}t|j|jƒƒ}|ˆ|krV|VnWqttfk rpqXqWdS(N(RtlistRR t IndexErrorR(RRRRR telems(tindex(s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyRÔs    sinvalid predicate(tappendR*tretmatchtintRt ValueError(RR t signaturet predicateR((R0R'R R(s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pytprepare_predicate’sV      # #  $    R%Rt.s..s//t[t_SelectorContextcBseZdZd„ZRS(cCs ||_dS(N(R(tselfR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyt__init__ïsN(t__name__t __module__RRR=(((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementPath.pyR;ísc Csn|ddkr|d}nyt|}Wntk r4ttƒdkrZtjƒn|d dkrytdƒ‚ntt||ƒƒj}|ƒ}g}x„y"|jt |d||ƒƒWnt k rätdƒ‚nXy)|ƒ}|ddkr |ƒ}nWq£t k r"Pq£Xq£W|t|;s.      P  $ PK:©ç\Õ"/¤ÈÞÈÞetree/ElementTree.pynu„[µü¤# # ElementTree # $Id: ElementTree.py 3440 2008-07-18 14:45:01Z fredrik $ # # light-weight XML support for Python 2.3 and later. # # history (since 1.2.6): # 2005-11-12 fl added tostringlist/fromstringlist helpers # 2006-07-05 fl merged in selected changes from the 1.3 sandbox # 2006-07-05 fl removed support for 2.1 and earlier # 2007-06-21 fl added deprecation/future warnings # 2007-08-25 fl added doctype hook, added parser version attribute etc # 2007-08-26 fl added new serializer code (better namespace handling, etc) # 2007-08-27 fl warn for broken /tag searches on tree level # 2007-09-02 fl added html/text methods to serializer (experimental) # 2007-09-05 fl added method argument to tostring/tostringlist # 2007-09-06 fl improved error handling # 2007-09-13 fl added itertext, iterfind; assorted cleanups # 2007-12-15 fl added C14N hooks, copy method (experimental) # # Copyright (c) 1999-2008 by Fredrik Lundh. All rights reserved. # # fredrik@pythonware.com # http://www.pythonware.com # # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2008 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Secret Labs AB or the author not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See http://www.python.org/psf/license for licensing details. __all__ = [ # public symbols "Comment", "dump", "Element", "ElementTree", "fromstring", "fromstringlist", "iselement", "iterparse", "parse", "ParseError", "PI", "ProcessingInstruction", "QName", "SubElement", "tostring", "tostringlist", "TreeBuilder", "VERSION", "XML", "XMLParser", "XMLTreeBuilder", ] VERSION = "1.3.0" ## # The Element type is a flexible container object, designed to # store hierarchical data structures in memory. The type can be # described as a cross between a list and a dictionary. #

# Each element has a number of properties associated with it: #

    #
  • a tag. This is a string identifying what kind of data # this element represents (the element type, in other words).
  • #
  • a number of attributes, stored in a Python dictionary.
  • #
  • a text string.
  • #
  • an optional tail string.
  • #
  • a number of child elements, stored in a Python sequence
  • #
# # To create an element instance, use the {@link #Element} constructor # or the {@link #SubElement} factory function. #

# The {@link #ElementTree} class can be used to wrap an element # structure, and convert it from and to XML. ## import sys import re import warnings class _SimpleElementPath(object): # emulate pre-1.2 find/findtext/findall behaviour def find(self, element, tag, namespaces=None): for elem in element: if elem.tag == tag: return elem return None def findtext(self, element, tag, default=None, namespaces=None): elem = self.find(element, tag) if elem is None: return default return elem.text or "" def iterfind(self, element, tag, namespaces=None): if tag[:3] == ".//": for elem in element.iter(tag[3:]): yield elem for elem in element: if elem.tag == tag: yield elem def findall(self, element, tag, namespaces=None): return list(self.iterfind(element, tag, namespaces)) try: from . import ElementPath except ImportError: ElementPath = _SimpleElementPath() ## # Parser error. This is a subclass of SyntaxError. #

# In addition to the exception value, an exception instance contains a # specific exception code in the code attribute, and the line and # column of the error in the position attribute. class ParseError(SyntaxError): pass # -------------------------------------------------------------------- ## # Checks if an object appears to be a valid element object. # # @param An element instance. # @return A true value if this is an element object. # @defreturn flag def iselement(element): # FIXME: not sure about this; might be a better idea to look # for tag/attrib/text attributes return isinstance(element, Element) or hasattr(element, "tag") ## # Element class. This class defines the Element interface, and # provides a reference implementation of this interface. #

# The element name, attribute names, and attribute values can be # either ASCII strings (ordinary Python strings containing only 7-bit # ASCII characters) or Unicode strings. # # @param tag The element name. # @param attrib An optional dictionary, containing element attributes. # @param **extra Additional attributes, given as keyword arguments. # @see Element # @see SubElement # @see Comment # @see ProcessingInstruction class Element(object): # text...tail ## # (Attribute) Element tag. tag = None ## # (Attribute) Element attribute dictionary. Where possible, use # {@link #Element.get}, # {@link #Element.set}, # {@link #Element.keys}, and # {@link #Element.items} to access # element attributes. attrib = None ## # (Attribute) Text before first subelement. This is either a # string or the value None. Note that if there was no text, this # attribute may be either None or an empty string, depending on # the parser. text = None ## # (Attribute) Text after this element's end tag, but before the # next sibling element's start tag. This is either a string or # the value None. Note that if there was no text, this attribute # may be either None or an empty string, depending on the parser. tail = None # text after end tag, if any # constructor def __init__(self, tag, attrib={}, **extra): attrib = attrib.copy() attrib.update(extra) self.tag = tag self.attrib = attrib self._children = [] def __repr__(self): return "" % (repr(self.tag), id(self)) ## # Creates a new element object of the same type as this element. # # @param tag Element tag. # @param attrib Element attributes, given as a dictionary. # @return A new element instance. def makeelement(self, tag, attrib): return self.__class__(tag, attrib) ## # (Experimental) Copies the current element. This creates a # shallow copy; subelements will be shared with the original tree. # # @return A new element instance. def copy(self): elem = self.makeelement(self.tag, self.attrib) elem.text = self.text elem.tail = self.tail elem[:] = self return elem ## # Returns the number of subelements. Note that this only counts # full elements; to check if there's any content in an element, you # have to check both the length and the text attribute. # # @return The number of subelements. def __len__(self): return len(self._children) def __nonzero__(self): warnings.warn( "The behavior of this method will change in future versions. " "Use specific 'len(elem)' or 'elem is not None' test instead.", FutureWarning, stacklevel=2 ) return len(self._children) != 0 # emulate old behaviour, for now ## # Returns the given subelement, by index. # # @param index What subelement to return. # @return The given subelement. # @exception IndexError If the given element does not exist. def __getitem__(self, index): return self._children[index] ## # Replaces the given subelement, by index. # # @param index What subelement to replace. # @param element The new element value. # @exception IndexError If the given element does not exist. def __setitem__(self, index, element): # if isinstance(index, slice): # for elt in element: # assert iselement(elt) # else: # assert iselement(element) self._children[index] = element ## # Deletes the given subelement, by index. # # @param index What subelement to delete. # @exception IndexError If the given element does not exist. def __delitem__(self, index): del self._children[index] ## # Adds a subelement to the end of this element. In document order, # the new element will appear after the last existing subelement (or # directly after the text, if it's the first subelement), but before # the end tag for this element. # # @param element The element to add. def append(self, element): # assert iselement(element) self._children.append(element) ## # Appends subelements from a sequence. # # @param elements A sequence object with zero or more elements. # @since 1.3 def extend(self, elements): # for element in elements: # assert iselement(element) self._children.extend(elements) ## # Inserts a subelement at the given position in this element. # # @param index Where to insert the new subelement. def insert(self, index, element): # assert iselement(element) self._children.insert(index, element) ## # Removes a matching subelement. Unlike the find methods, # this method compares elements based on identity, not on tag # value or contents. To remove subelements by other means, the # easiest way is often to use a list comprehension to select what # elements to keep, and use slice assignment to update the parent # element. # # @param element What element to remove. # @exception ValueError If a matching element could not be found. def remove(self, element): # assert iselement(element) self._children.remove(element) ## # (Deprecated) Returns all subelements. The elements are returned # in document order. # # @return A list of subelements. # @defreturn list of Element instances def getchildren(self): warnings.warn( "This method will be removed in future versions. " "Use 'list(elem)' or iteration over elem instead.", DeprecationWarning, stacklevel=2 ) return self._children ## # Finds the first matching subelement, by tag name or path. # # @param path What element to look for. # @keyparam namespaces Optional namespace prefix map. # @return The first matching element, or None if no element was found. # @defreturn Element or None def find(self, path, namespaces=None): return ElementPath.find(self, path, namespaces) ## # Finds text for the first matching subelement, by tag name or path. # # @param path What element to look for. # @param default What to return if the element was not found. # @keyparam namespaces Optional namespace prefix map. # @return The text content of the first matching element, or the # default value no element was found. Note that if the element # is found, but has no text content, this method returns an # empty string. # @defreturn string def findtext(self, path, default=None, namespaces=None): return ElementPath.findtext(self, path, default, namespaces) ## # Finds all matching subelements, by tag name or path. # # @param path What element to look for. # @keyparam namespaces Optional namespace prefix map. # @return A list or other sequence containing all matching elements, # in document order. # @defreturn list of Element instances def findall(self, path, namespaces=None): return ElementPath.findall(self, path, namespaces) ## # Finds all matching subelements, by tag name or path. # # @param path What element to look for. # @keyparam namespaces Optional namespace prefix map. # @return An iterator or sequence containing all matching elements, # in document order. # @defreturn a generated sequence of Element instances def iterfind(self, path, namespaces=None): return ElementPath.iterfind(self, path, namespaces) ## # Resets an element. This function removes all subelements, clears # all attributes, and sets the text and tail attributes # to None. def clear(self): self.attrib.clear() self._children = [] self.text = self.tail = None ## # Gets an element attribute. Equivalent to attrib.get, but # some implementations may handle this a bit more efficiently. # # @param key What attribute to look for. # @param default What to return if the attribute was not found. # @return The attribute value, or the default value, if the # attribute was not found. # @defreturn string or None def get(self, key, default=None): return self.attrib.get(key, default) ## # Sets an element attribute. Equivalent to attrib[key] = value, # but some implementations may handle this a bit more efficiently. # # @param key What attribute to set. # @param value The attribute value. def set(self, key, value): self.attrib[key] = value ## # Gets a list of attribute names. The names are returned in an # arbitrary order (just like for an ordinary Python dictionary). # Equivalent to attrib.keys(). # # @return A list of element attribute names. # @defreturn list of strings def keys(self): return self.attrib.keys() ## # Gets element attributes, as a sequence. The attributes are # returned in an arbitrary order. Equivalent to attrib.items(). # # @return A list of (name, value) tuples for all attributes. # @defreturn list of (string, string) tuples def items(self): return self.attrib.items() ## # Creates a tree iterator. The iterator loops over this element # and all subelements, in document order, and returns all elements # with a matching tag. #

# If the tree structure is modified during iteration, new or removed # elements may or may not be included. To get a stable set, use the # list() function on the iterator, and loop over the resulting list. # # @param tag What tags to look for (default is to return all elements). # @return An iterator containing all the matching elements. # @defreturn iterator def iter(self, tag=None): if tag == "*": tag = None if tag is None or self.tag == tag: yield self for e in self._children: for e in e.iter(tag): yield e # compatibility def getiterator(self, tag=None): # Change for a DeprecationWarning in 1.4 warnings.warn( "This method will be removed in future versions. " "Use 'elem.iter()' or 'list(elem.iter())' instead.", PendingDeprecationWarning, stacklevel=2 ) return list(self.iter(tag)) ## # Creates a text iterator. The iterator loops over this element # and all subelements, in document order, and returns all inner # text. # # @return An iterator containing all inner text. # @defreturn iterator def itertext(self): tag = self.tag if not isinstance(tag, basestring) and tag is not None: return if self.text: yield self.text for e in self: for s in e.itertext(): yield s if e.tail: yield e.tail # compatibility _Element = _ElementInterface = Element ## # Subelement factory. This function creates an element instance, and # appends it to an existing element. #

# The element name, attribute names, and attribute values can be # either 8-bit ASCII strings or Unicode strings. # # @param parent The parent element. # @param tag The subelement name. # @param attrib An optional dictionary, containing element attributes. # @param **extra Additional attributes, given as keyword arguments. # @return An element instance. # @defreturn Element def SubElement(parent, tag, attrib={}, **extra): attrib = attrib.copy() attrib.update(extra) element = parent.makeelement(tag, attrib) parent.append(element) return element ## # Comment element factory. This factory function creates a special # element that will be serialized as an XML comment by the standard # serializer. #

# The comment string can be either an 8-bit ASCII string or a Unicode # string. # # @param text A string containing the comment string. # @return An element instance, representing a comment. # @defreturn Element def Comment(text=None): element = Element(Comment) element.text = text return element ## # PI element factory. This factory function creates a special element # that will be serialized as an XML processing instruction by the standard # serializer. # # @param target A string containing the PI target. # @param text A string containing the PI contents, if any. # @return An element instance, representing a PI. # @defreturn Element def ProcessingInstruction(target, text=None): element = Element(ProcessingInstruction) element.text = target if text: element.text = element.text + " " + text return element PI = ProcessingInstruction ## # QName wrapper. This can be used to wrap a QName attribute value, in # order to get proper namespace handling on output. # # @param text A string containing the QName value, in the form {uri}local, # or, if the tag argument is given, the URI part of a QName. # @param tag Optional tag. If given, the first argument is interpreted as # a URI, and this argument is interpreted as a local name. # @return An opaque object, representing the QName. class QName(object): def __init__(self, text_or_uri, tag=None): if tag: text_or_uri = "{%s}%s" % (text_or_uri, tag) self.text = text_or_uri def __str__(self): return self.text def __hash__(self): return hash(self.text) def __cmp__(self, other): if isinstance(other, QName): return cmp(self.text, other.text) return cmp(self.text, other) # -------------------------------------------------------------------- ## # ElementTree wrapper class. This class represents an entire element # hierarchy, and adds some extra support for serialization to and from # standard XML. # # @param element Optional root element. # @keyparam file Optional file handle or file name. If given, the # tree is initialized with the contents of this XML file. class ElementTree(object): def __init__(self, element=None, file=None): # assert element is None or iselement(element) self._root = element # first node if file: self.parse(file) ## # Gets the root element for this tree. # # @return An element instance. # @defreturn Element def getroot(self): return self._root ## # Replaces the root element for this tree. This discards the # current contents of the tree, and replaces it with the given # element. Use with care. # # @param element An element instance. def _setroot(self, element): # assert iselement(element) self._root = element ## # Loads an external XML document into this element tree. # # @param source A file name or file object. If a file object is # given, it only has to implement a read(n) method. # @keyparam parser An optional parser instance. If not given, the # standard {@link XMLParser} parser is used. # @return The document root element. # @defreturn Element # @exception ParseError If the parser fails to parse the document. def parse(self, source, parser=None): close_source = False if not hasattr(source, "read"): source = open(source, "rb") close_source = True try: if not parser: parser = XMLParser(target=TreeBuilder()) while 1: data = source.read(65536) if not data: break parser.feed(data) self._root = parser.close() return self._root finally: if close_source: source.close() ## # Creates a tree iterator for the root element. The iterator loops # over all elements in this tree, in document order. # # @param tag What tags to look for (default is to return all elements) # @return An iterator. # @defreturn iterator def iter(self, tag=None): # assert self._root is not None return self._root.iter(tag) # compatibility def getiterator(self, tag=None): # Change for a DeprecationWarning in 1.4 warnings.warn( "This method will be removed in future versions. " "Use 'tree.iter()' or 'list(tree.iter())' instead.", PendingDeprecationWarning, stacklevel=2 ) return list(self.iter(tag)) ## # Same as getroot().find(path), starting at the root of the # tree. # # @param path What element to look for. # @keyparam namespaces Optional namespace prefix map. # @return The first matching element, or None if no element was found. # @defreturn Element or None def find(self, path, namespaces=None): # assert self._root is not None if path[:1] == "/": path = "." + path warnings.warn( "This search is broken in 1.3 and earlier, and will be " "fixed in a future version. If you rely on the current " "behaviour, change it to %r" % path, FutureWarning, stacklevel=2 ) return self._root.find(path, namespaces) ## # Same as getroot().findtext(path), starting at the root of the tree. # # @param path What element to look for. # @param default What to return if the element was not found. # @keyparam namespaces Optional namespace prefix map. # @return The text content of the first matching element, or the # default value no element was found. Note that if the element # is found, but has no text content, this method returns an # empty string. # @defreturn string def findtext(self, path, default=None, namespaces=None): # assert self._root is not None if path[:1] == "/": path = "." + path warnings.warn( "This search is broken in 1.3 and earlier, and will be " "fixed in a future version. If you rely on the current " "behaviour, change it to %r" % path, FutureWarning, stacklevel=2 ) return self._root.findtext(path, default, namespaces) ## # Same as getroot().findall(path), starting at the root of the tree. # # @param path What element to look for. # @keyparam namespaces Optional namespace prefix map. # @return A list or iterator containing all matching elements, # in document order. # @defreturn list of Element instances def findall(self, path, namespaces=None): # assert self._root is not None if path[:1] == "/": path = "." + path warnings.warn( "This search is broken in 1.3 and earlier, and will be " "fixed in a future version. If you rely on the current " "behaviour, change it to %r" % path, FutureWarning, stacklevel=2 ) return self._root.findall(path, namespaces) ## # Finds all matching subelements, by tag name or path. # Same as getroot().iterfind(path). # # @param path What element to look for. # @keyparam namespaces Optional namespace prefix map. # @return An iterator or sequence containing all matching elements, # in document order. # @defreturn a generated sequence of Element instances def iterfind(self, path, namespaces=None): # assert self._root is not None if path[:1] == "/": path = "." + path warnings.warn( "This search is broken in 1.3 and earlier, and will be " "fixed in a future version. If you rely on the current " "behaviour, change it to %r" % path, FutureWarning, stacklevel=2 ) return self._root.iterfind(path, namespaces) ## # Writes the element tree to a file, as XML. # # @def write(file, **options) # @param file A file name, or a file object opened for writing. # @param **options Options, given as keyword arguments. # @keyparam encoding Optional output encoding (default is US-ASCII). # @keyparam xml_declaration Controls if an XML declaration should # be added to the file. Use False for never, True for always, # None for only if not US-ASCII or UTF-8. None is default. # @keyparam default_namespace Sets the default XML namespace (for "xmlns"). # @keyparam method Optional output method ("xml", "html", "text" or # "c14n"; default is "xml"). def write(self, file_or_filename, # keyword arguments encoding=None, xml_declaration=None, default_namespace=None, method=None): # assert self._root is not None if not method: method = "xml" elif method not in _serialize: # FIXME: raise an ImportError for c14n if ElementC14N is missing? raise ValueError("unknown method %r" % method) if hasattr(file_or_filename, "write"): file = file_or_filename else: file = open(file_or_filename, "wb") write = file.write if not encoding: if method == "c14n": encoding = "utf-8" else: encoding = "us-ascii" elif xml_declaration or (xml_declaration is None and encoding not in ("utf-8", "us-ascii")): if method == "xml": write("\n" % encoding) if method == "text": _serialize_text(write, self._root, encoding) else: qnames, namespaces = _namespaces( self._root, encoding, default_namespace ) serialize = _serialize[method] serialize(write, self._root, encoding, qnames, namespaces) if file_or_filename is not file: file.close() def write_c14n(self, file): # lxml.etree compatibility. use output method instead return self.write(file, method="c14n") # -------------------------------------------------------------------- # serialization support def _namespaces(elem, encoding, default_namespace=None): # identify namespaces used in this tree # maps qnames to *encoded* prefix:local names qnames = {None: None} # maps uri:s to prefixes namespaces = {} if default_namespace: namespaces[default_namespace] = "" def encode(text): return text.encode(encoding) def add_qname(qname): # calculate serialized qname representation try: if qname[:1] == "{": uri, tag = qname[1:].rsplit("}", 1) prefix = namespaces.get(uri) if prefix is None: prefix = _namespace_map.get(uri) if prefix is None: prefix = "ns%d" % len(namespaces) if prefix != "xml": namespaces[uri] = prefix if prefix: qnames[qname] = encode("%s:%s" % (prefix, tag)) else: qnames[qname] = encode(tag) # default element else: if default_namespace: # FIXME: can this be handled in XML 1.0? raise ValueError( "cannot use non-qualified names with " "default_namespace option" ) qnames[qname] = encode(qname) except TypeError: _raise_serialization_error(qname) # populate qname and namespaces table try: iterate = elem.iter except AttributeError: iterate = elem.getiterator # cET compatibility for elem in iterate(): tag = elem.tag if isinstance(tag, QName): if tag.text not in qnames: add_qname(tag.text) elif isinstance(tag, basestring): if tag not in qnames: add_qname(tag) elif tag is not None and tag is not Comment and tag is not PI: _raise_serialization_error(tag) for key, value in elem.items(): if isinstance(key, QName): key = key.text if key not in qnames: add_qname(key) if isinstance(value, QName) and value.text not in qnames: add_qname(value.text) text = elem.text if isinstance(text, QName) and text.text not in qnames: add_qname(text.text) return qnames, namespaces def _serialize_xml(write, elem, encoding, qnames, namespaces): tag = elem.tag text = elem.text if tag is Comment: write("" % _encode(text, encoding)) elif tag is ProcessingInstruction: write("" % _encode(text, encoding)) else: tag = qnames[tag] if tag is None: if text: write(_escape_cdata(text, encoding)) for e in elem: _serialize_xml(write, e, encoding, qnames, None) else: write("<" + tag) items = elem.items() if items or namespaces: if namespaces: for v, k in sorted(namespaces.items(), key=lambda x: x[1]): # sort on prefix if k: k = ":" + k write(" xmlns%s=\"%s\"" % ( k.encode(encoding), _escape_attrib(v, encoding) )) for k, v in sorted(items): # lexical order if isinstance(k, QName): k = k.text if isinstance(v, QName): v = qnames[v.text] else: v = _escape_attrib(v, encoding) write(" %s=\"%s\"" % (qnames[k], v)) if text or len(elem): write(">") if text: write(_escape_cdata(text, encoding)) for e in elem: _serialize_xml(write, e, encoding, qnames, None) write("") else: write(" />") if elem.tail: write(_escape_cdata(elem.tail, encoding)) HTML_EMPTY = ("area", "base", "basefont", "br", "col", "frame", "hr", "img", "input", "isindex", "link", "meta", "param") try: HTML_EMPTY = set(HTML_EMPTY) except NameError: pass def _serialize_html(write, elem, encoding, qnames, namespaces): tag = elem.tag text = elem.text if tag is Comment: write("" % _escape_cdata(text, encoding)) elif tag is ProcessingInstruction: write("" % _escape_cdata(text, encoding)) else: tag = qnames[tag] if tag is None: if text: write(_escape_cdata(text, encoding)) for e in elem: _serialize_html(write, e, encoding, qnames, None) else: write("<" + tag) items = elem.items() if items or namespaces: if namespaces: for v, k in sorted(namespaces.items(), key=lambda x: x[1]): # sort on prefix if k: k = ":" + k write(" xmlns%s=\"%s\"" % ( k.encode(encoding), _escape_attrib(v, encoding) )) for k, v in sorted(items): # lexical order if isinstance(k, QName): k = k.text if isinstance(v, QName): v = qnames[v.text] else: v = _escape_attrib_html(v, encoding) # FIXME: handle boolean attributes write(" %s=\"%s\"" % (qnames[k], v)) write(">") ltag = tag.lower() if text: if ltag == "script" or ltag == "style": write(_encode(text, encoding)) else: write(_escape_cdata(text, encoding)) for e in elem: _serialize_html(write, e, encoding, qnames, None) if ltag not in HTML_EMPTY: write("") if elem.tail: write(_escape_cdata(elem.tail, encoding)) def _serialize_text(write, elem, encoding): for part in elem.itertext(): write(part.encode(encoding)) if elem.tail: write(elem.tail.encode(encoding)) _serialize = { "xml": _serialize_xml, "html": _serialize_html, "text": _serialize_text, # this optional method is imported at the end of the module # "c14n": _serialize_c14n, } ## # Registers a namespace prefix. The registry is global, and any # existing mapping for either the given prefix or the namespace URI # will be removed. # # @param prefix Namespace prefix. # @param uri Namespace uri. Tags and attributes in this namespace # will be serialized with the given prefix, if at all possible. # @exception ValueError If the prefix is reserved, or is otherwise # invalid. def register_namespace(prefix, uri): if re.match("ns\d+$", prefix): raise ValueError("Prefix format reserved for internal use") for k, v in _namespace_map.items(): if k == uri or v == prefix: del _namespace_map[k] _namespace_map[uri] = prefix _namespace_map = { # "well-known" namespace prefixes "http://www.w3.org/XML/1998/namespace": "xml", "http://www.w3.org/1999/xhtml": "html", "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf", "http://schemas.xmlsoap.org/wsdl/": "wsdl", # xml schema "http://www.w3.org/2001/XMLSchema": "xs", "http://www.w3.org/2001/XMLSchema-instance": "xsi", # dublin core "http://purl.org/dc/elements/1.1/": "dc", } def _raise_serialization_error(text): raise TypeError( "cannot serialize %r (type %s)" % (text, type(text).__name__) ) def _encode(text, encoding): try: return text.encode(encoding, "xmlcharrefreplace") except (TypeError, AttributeError): _raise_serialization_error(text) def _escape_cdata(text, encoding): # escape character data try: # it's worth avoiding do-nothing calls for strings that are # shorter than 500 character, or so. assume that's, by far, # the most common case in most applications. if "&" in text: text = text.replace("&", "&") if "<" in text: text = text.replace("<", "<") if ">" in text: text = text.replace(">", ">") return text.encode(encoding, "xmlcharrefreplace") except (TypeError, AttributeError): _raise_serialization_error(text) def _escape_attrib(text, encoding): # escape attribute value try: if "&" in text: text = text.replace("&", "&") if "<" in text: text = text.replace("<", "<") if ">" in text: text = text.replace(">", ">") if "\"" in text: text = text.replace("\"", """) if "\n" in text: text = text.replace("\n", " ") return text.encode(encoding, "xmlcharrefreplace") except (TypeError, AttributeError): _raise_serialization_error(text) def _escape_attrib_html(text, encoding): # escape attribute value try: if "&" in text: text = text.replace("&", "&") if ">" in text: text = text.replace(">", ">") if "\"" in text: text = text.replace("\"", """) return text.encode(encoding, "xmlcharrefreplace") except (TypeError, AttributeError): _raise_serialization_error(text) # -------------------------------------------------------------------- ## # Generates a string representation of an XML element, including all # subelements. # # @param element An Element instance. # @keyparam encoding Optional output encoding (default is US-ASCII). # @keyparam method Optional output method ("xml", "html", "text" or # "c14n"; default is "xml"). # @return An encoded string containing the XML data. # @defreturn string def tostring(element, encoding=None, method=None): class dummy: pass data = [] file = dummy() file.write = data.append ElementTree(element).write(file, encoding, method=method) return "".join(data) ## # Generates a string representation of an XML element, including all # subelements. The string is returned as a sequence of string fragments. # # @param element An Element instance. # @keyparam encoding Optional output encoding (default is US-ASCII). # @keyparam method Optional output method ("xml", "html", "text" or # "c14n"; default is "xml"). # @return A sequence object containing the XML data. # @defreturn sequence # @since 1.3 def tostringlist(element, encoding=None, method=None): class dummy: pass data = [] file = dummy() file.write = data.append ElementTree(element).write(file, encoding, method=method) # FIXME: merge small fragments into larger parts return data ## # Writes an element tree or element structure to sys.stdout. This # function should be used for debugging only. #

# The exact output format is implementation dependent. In this # version, it's written as an ordinary XML file. # # @param elem An element tree or an individual element. def dump(elem): # debugging if not isinstance(elem, ElementTree): elem = ElementTree(elem) elem.write(sys.stdout) tail = elem.getroot().tail if not tail or tail[-1] != "\n": sys.stdout.write("\n") # -------------------------------------------------------------------- # parsing ## # Parses an XML document into an element tree. # # @param source A filename or file object containing XML data. # @param parser An optional parser instance. If not given, the # standard {@link XMLParser} parser is used. # @return An ElementTree instance def parse(source, parser=None): tree = ElementTree() tree.parse(source, parser) return tree ## # Parses an XML document into an element tree incrementally, and reports # what's going on to the user. # # @param source A filename or file object containing XML data. # @param events A list of events to report back. If omitted, only "end" # events are reported. # @param parser An optional parser instance. If not given, the # standard {@link XMLParser} parser is used. # @return A (event, elem) iterator. def iterparse(source, events=None, parser=None): close_source = False if not hasattr(source, "read"): source = open(source, "rb") close_source = True try: if not parser: parser = XMLParser(target=TreeBuilder()) return _IterParseIterator(source, events, parser, close_source) except: if close_source: source.close() raise class _IterParseIterator(object): def __init__(self, source, events, parser, close_source=False): self._file = source self._close_file = close_source self._events = [] self._index = 0 self._error = None self.root = self._root = None self._parser = parser # wire up the parser for event reporting parser = self._parser._parser append = self._events.append if events is None: events = ["end"] for event in events: if event == "start": try: parser.ordered_attributes = 1 parser.specified_attributes = 1 def handler(tag, attrib_in, event=event, append=append, start=self._parser._start_list): append((event, start(tag, attrib_in))) parser.StartElementHandler = handler except AttributeError: def handler(tag, attrib_in, event=event, append=append, start=self._parser._start): append((event, start(tag, attrib_in))) parser.StartElementHandler = handler elif event == "end": def handler(tag, event=event, append=append, end=self._parser._end): append((event, end(tag))) parser.EndElementHandler = handler elif event == "start-ns": def handler(prefix, uri, event=event, append=append): try: uri = (uri or "").encode("ascii") except UnicodeError: pass append((event, (prefix or "", uri or ""))) parser.StartNamespaceDeclHandler = handler elif event == "end-ns": def handler(prefix, event=event, append=append): append((event, None)) parser.EndNamespaceDeclHandler = handler else: raise ValueError("unknown event %r" % event) def next(self): try: while 1: try: item = self._events[self._index] self._index += 1 return item except IndexError: pass if self._error: e = self._error self._error = None raise e if self._parser is None: self.root = self._root break # load event buffer del self._events[:] self._index = 0 data = self._file.read(16384) if data: try: self._parser.feed(data) except SyntaxError as exc: self._error = exc else: self._root = self._parser.close() self._parser = None except: if self._close_file: self._file.close() raise if self._close_file: self._file.close() raise StopIteration def __iter__(self): return self ## # Parses an XML document from a string constant. This function can # be used to embed "XML literals" in Python code. # # @param source A string containing XML data. # @param parser An optional parser instance. If not given, the # standard {@link XMLParser} parser is used. # @return An Element instance. # @defreturn Element def XML(text, parser=None): if not parser: parser = XMLParser(target=TreeBuilder()) parser.feed(text) return parser.close() ## # Parses an XML document from a string constant, and also returns # a dictionary which maps from element id:s to elements. # # @param source A string containing XML data. # @param parser An optional parser instance. If not given, the # standard {@link XMLParser} parser is used. # @return A tuple containing an Element instance and a dictionary. # @defreturn (Element, dictionary) def XMLID(text, parser=None): if not parser: parser = XMLParser(target=TreeBuilder()) parser.feed(text) tree = parser.close() ids = {} for elem in tree.iter(): id = elem.get("id") if id: ids[id] = elem return tree, ids ## # Parses an XML document from a string constant. Same as {@link #XML}. # # @def fromstring(text) # @param source A string containing XML data. # @return An Element instance. # @defreturn Element fromstring = XML ## # Parses an XML document from a sequence of string fragments. # # @param sequence A list or other sequence containing XML data fragments. # @param parser An optional parser instance. If not given, the # standard {@link XMLParser} parser is used. # @return An Element instance. # @defreturn Element # @since 1.3 def fromstringlist(sequence, parser=None): if not parser: parser = XMLParser(target=TreeBuilder()) for text in sequence: parser.feed(text) return parser.close() # -------------------------------------------------------------------- ## # Generic element structure builder. This builder converts a sequence # of {@link #TreeBuilder.start}, {@link #TreeBuilder.data}, and {@link # #TreeBuilder.end} method calls to a well-formed element structure. #

# You can use this class to build an element structure using a custom XML # parser, or a parser for some other XML-like format. # # @param element_factory Optional element factory. This factory # is called to create new Element instances, as necessary. class TreeBuilder(object): def __init__(self, element_factory=None): self._data = [] # data collector self._elem = [] # element stack self._last = None # last element self._tail = None # true if we're after an end tag if element_factory is None: element_factory = Element self._factory = element_factory ## # Flushes the builder buffers, and returns the toplevel document # element. # # @return An Element instance. # @defreturn Element def close(self): assert len(self._elem) == 0, "missing end tags" assert self._last is not None, "missing toplevel element" return self._last def _flush(self): if self._data: if self._last is not None: text = "".join(self._data) if self._tail: assert self._last.tail is None, "internal error (tail)" self._last.tail = text else: assert self._last.text is None, "internal error (text)" self._last.text = text self._data = [] ## # Adds text to the current element. # # @param data A string. This should be either an 8-bit string # containing ASCII text, or a Unicode string. def data(self, data): self._data.append(data) ## # Opens a new element. # # @param tag The element name. # @param attrib A dictionary containing element attributes. # @return The opened element. # @defreturn Element def start(self, tag, attrs): self._flush() self._last = elem = self._factory(tag, attrs) if self._elem: self._elem[-1].append(elem) self._elem.append(elem) self._tail = 0 return elem ## # Closes the current element. # # @param tag The element name. # @return The closed element. # @defreturn Element def end(self, tag): self._flush() self._last = self._elem.pop() assert self._last.tag == tag,\ "end tag mismatch (expected %s, got %s)" % ( self._last.tag, tag) self._tail = 1 return self._last _sentinel = ['sentinel'] ## # Element structure builder for XML source data, based on the # expat parser. # # @keyparam target Target object. If omitted, the builder uses an # instance of the standard {@link #TreeBuilder} class. # @keyparam html Predefine HTML entities. This flag is not supported # by the current implementation. # @keyparam encoding Optional encoding. If given, the value overrides # the encoding specified in the XML file. # @see #ElementTree # @see #TreeBuilder class XMLParser(object): def __init__(self, html=_sentinel, target=None, encoding=None): if html is not _sentinel: warnings.warnpy3k( "The html argument of XMLParser() is deprecated", DeprecationWarning, stacklevel=2) try: from xml.parsers import expat except ImportError: try: import pyexpat as expat except ImportError: raise ImportError( "No module named expat; use SimpleXMLTreeBuilder instead" ) parser = expat.ParserCreate(encoding, "}") if target is None: target = TreeBuilder() # underscored names are provided for compatibility only self.parser = self._parser = parser self.target = self._target = target self._error = expat.error self._names = {} # name memo cache # callbacks parser.DefaultHandlerExpand = self._default parser.StartElementHandler = self._start parser.EndElementHandler = self._end parser.CharacterDataHandler = self._data # optional callbacks parser.CommentHandler = self._comment parser.ProcessingInstructionHandler = self._pi # let expat do the buffering, if supported try: self._parser.buffer_text = 1 except AttributeError: pass # use new-style attribute handling, if supported try: self._parser.ordered_attributes = 1 self._parser.specified_attributes = 1 parser.StartElementHandler = self._start_list except AttributeError: pass self._doctype = None self.entity = {} try: self.version = "Expat %d.%d.%d" % expat.version_info except AttributeError: pass # unknown def _raiseerror(self, value): err = ParseError(value) err.code = value.code err.position = value.lineno, value.offset raise err def _fixtext(self, text): # convert text string to ascii, if possible try: return text.encode("ascii") except UnicodeError: return text def _fixname(self, key): # expand qname, and convert name string to ascii, if possible try: name = self._names[key] except KeyError: name = key if "}" in name: name = "{" + name self._names[key] = name = self._fixtext(name) return name def _start(self, tag, attrib_in): fixname = self._fixname fixtext = self._fixtext tag = fixname(tag) attrib = {} for key, value in attrib_in.items(): attrib[fixname(key)] = fixtext(value) return self.target.start(tag, attrib) def _start_list(self, tag, attrib_in): fixname = self._fixname fixtext = self._fixtext tag = fixname(tag) attrib = {} if attrib_in: for i in range(0, len(attrib_in), 2): attrib[fixname(attrib_in[i])] = fixtext(attrib_in[i+1]) return self.target.start(tag, attrib) def _data(self, text): return self.target.data(self._fixtext(text)) def _end(self, tag): return self.target.end(self._fixname(tag)) def _comment(self, data): try: comment = self.target.comment except AttributeError: pass else: return comment(self._fixtext(data)) def _pi(self, target, data): try: pi = self.target.pi except AttributeError: pass else: return pi(self._fixtext(target), self._fixtext(data)) def _default(self, text): prefix = text[:1] if prefix == "&": # deal with undefined entities try: self.target.data(self.entity[text[1:-1]]) except KeyError: from xml.parsers import expat err = expat.error( "undefined entity %s: line %d, column %d" % (text, self._parser.ErrorLineNumber, self._parser.ErrorColumnNumber) ) err.code = 11 # XML_ERROR_UNDEFINED_ENTITY err.lineno = self._parser.ErrorLineNumber err.offset = self._parser.ErrorColumnNumber raise err elif prefix == "<" and text[:9] == "": self._doctype = None return text = text.strip() if not text: return self._doctype.append(text) n = len(self._doctype) if n > 2: type = self._doctype[1] if type == "PUBLIC" and n == 4: name, type, pubid, system = self._doctype elif type == "SYSTEM" and n == 3: name, type, system = self._doctype pubid = None else: return if pubid: pubid = pubid[1:-1] if hasattr(self.target, "doctype"): self.target.doctype(name, pubid, system[1:-1]) elif self.doctype != self._XMLParser__doctype: # warn about deprecated call self._XMLParser__doctype(name, pubid, system[1:-1]) self.doctype(name, pubid, system[1:-1]) self._doctype = None ## # (Deprecated) Handles a doctype declaration. # # @param name Doctype name. # @param pubid Public identifier. # @param system System identifier. def doctype(self, name, pubid, system): """This method of XMLParser is deprecated.""" warnings.warn( "This method of XMLParser is deprecated. Define doctype() " "method on the TreeBuilder target.", DeprecationWarning, ) # sentinel, if doctype is redefined in a subclass __doctype = doctype ## # Feeds data to the parser. # # @param data Encoded data. def feed(self, data): try: self._parser.Parse(data, 0) except self._error, v: self._raiseerror(v) ## # Finishes feeding data to the parser. # # @return An element structure. # @defreturn Element def close(self): try: self._parser.Parse("", 1) # end of data except self._error, v: self._raiseerror(v) tree = self.target.close() del self.target, self._parser # get rid of circular references return tree # compatibility XMLTreeBuilder = XMLParser # workaround circular import. try: from ElementC14N import _serialize_c14n _serialize["c14n"] = _serialize_c14n except ImportError: pass PK:©ç\̹éµ��etree/ElementTree.pycnu„[µü¤ó ›V~gc@s>dddddddddd d d d d dddddddgZdZddlZddlZddlZdefd„ƒYZyddlmZWne k rµeƒZnXd e fd„ƒYZ d„Z defd„ƒYZ e ZZid„Zed „Zed!„ZeZd efd"„ƒYZdefd#„ƒYZed$„Zd%„Zd&d'd(d)d*d+d,d-d.d/d0d1d2f ZyeeƒZWnek r°nXd3„Zd4„Zied56ed66ed76Zd8„Zid5d96d6d:6d;d<6d=d>6d?d@6dAdB6dCdD6Z dE„Z!dF„Z"dG„Z#dH„Z$dI„Z%eedJ„Z&eedK„Z'dL„Z(edM„Z)eedN„Z*dOefdP„ƒYZ+edQ„Z,edR„Z-e,Z.edS„Z/defdT„ƒYZ0dUgZ1defdV„ƒYZ2e2Z3yddWl4m5Z5e5edX(treprRtid(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__repr__ÖscCs|j||ƒS(N(t __class__(RRR,((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt makeelementàscCs;|j|j|jƒ}|j|_|j|_||(|S(N(R4RR,Rttail(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR*és   cCs t|jƒS(N(tlenR-(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__len__÷scCs)tjdtddƒt|jƒdkS(NsyThe behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.t stacklevelii(twarningstwarnt FutureWarningR6R-(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt __nonzero__ús cCs |j|S(N(R-(Rtindex((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt __getitem__ scCs||j||D]6}x|jƒD] }|VqWW|jrD|jVqDqDWdS(N(RR(t basestringRRtitertextR5(RRRQts((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyRUòs      N(!R%R&RRR,RR5R/R2R4R*R7R<R>R?R@RARBRDRERGRR R$R"RIRJRMRNROR!RSRU(((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR«s<             cKs<|jƒ}|j|ƒ|j||ƒ}|j|ƒ|S(N(R*R+R4RA(tparentRR,R.R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR s    cCsttƒ}||_|S(N(RRR(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR"s  cCs6ttƒ}||_|r2|jd||_n|S(Nt (RR R(ttargetRR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR 1s   cBs/eZdd„Zd„Zd„Zd„ZRS(cCs&|rd||f}n||_dS(Ns{%s}%s(R(Rt text_or_uriR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR/EscCs|jS(N(R(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__str__IscCs t|jƒS(N(thashR(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__hash__KscCs2t|tƒr"t|j|jƒSt|j|ƒS(N(R(R tcmpR(Rtother((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__cmp__MsN(R%R&RR/R[R]R`(((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR Ds   cBsžeZd d d„Zd„Zd„Zd d„Zd d„Zd d„Zd d„Z d d d„Z d d„Z d d „Z d d d d d „Z d „ZRS( cCs#||_|r|j|ƒndS(N(t_rootR(RRtfile((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR/_s cCs|jS(N(Ra(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pytgetrootkscCs ||_dS(N(Ra(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt_setrootuscCsªt}t|dƒs-t|dƒ}t}nzb|sKtdtƒƒ}nx*|jdƒ}|sgPn|j|ƒqNW|jƒ|_ |j SWd|r¥|jƒnXdS(NtreadtrbRYi( tFalseR)topentTrueRRRetfeedtcloseRa(Rtsourcetparsert close_sourcetdata((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR„s   cCs|jj|ƒS(N(RaR!(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR!ŸscCs)tjdtddƒt|j|ƒƒS(NsbThis method will be removed in future versions. Use 'tree.iter()' or 'list(tree.iter())' instead.R8i(R9R:RRR#R!(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyRS¤s cCsJ|d dkr7d|}tjd|tddƒn|jj||ƒS(Nit/t.s‡This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rR8i(R9R:R;RaR(RRHR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR¶s cCsM|d dkr7d|}tjd|tddƒn|jj|||ƒS(NiRpRqs‡This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rR8i(R9R:R;RaR (RRHRR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR Îs cCsJ|d dkr7d|}tjd|tddƒn|jj||ƒS(NiRpRqs‡This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rR8i(R9R:R;RaR$(RRHR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR$ãs cCsJ|d dkr7d|}tjd|tddƒn|jj||ƒS(NiRpRqs‡This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rR8i(R9R:R;RaR"(RRHR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR"ùs c Cs=|sd}n|tkr.td|ƒ‚nt|dƒrF|}nt|dƒ}|j}|s‚|dkryd}qÀd}n>|s |dkrÀ|d krÀ|dkrÀ|d|ƒqÀn|d krât||j|ƒn>t|j||ƒ\}} t|} | ||j||| ƒ||k r9|j ƒndS( Ntxmlsunknown method %rtwritetwbtc14nsutf-8sus-asciis$ R(sutf-8sus-ascii( t _serializet ValueErrorR)RhRsRt_serialize_textRat _namespacesRk( Rtfile_or_filenametencodingtxml_declarationtdefault_namespacetmethodRbRstqnamesRt serialize((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyRss0            cCs|j|ddƒS(NR~Ru(Rs(RRb((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt write_c14n8sN(R%R&RR/RcRdRR!RSRR R$R"RsR�(((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR]s        c sáidd6‰i‰ˆr&dˆˆ       $     c Css|j}|j}|tkr8|dt||ƒƒn|tkr^|dt||ƒƒnï||}|dkrº|r�|t||ƒƒnxº|D]}t||||dƒq—Wn“|d|ƒ|jƒ}|sà|rÏ|rNxet |jƒdd„ƒD]E\} } | r!d| } n|d| j |ƒt | |ƒfƒqWnx~t |ƒD]m\} } t | t ƒr‚| j} nt | t ƒr¡|| j} nt | |ƒ} |d|| | fƒq[Wn|sát|ƒrC|d ƒ|r|t||ƒƒnx$|D]}t||||dƒqW|d |d ƒn |d ƒ|jro|t|j|ƒƒndS( Ns st—Rt:s xmlns%s="%s"s %s="%s"t>s(RRRt_encodeR Rt _escape_cdatat_serialize_xmlROtsortedR‚t_escape_attribR(R R6R5( RsRR{RRRRRQROtvtk((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR–ƒsP                tareatbasetbasefonttbrtcoltframethrtimgtinputtisindextlinktmetatparamc Cs�|j}|j}|tkr8|dt||ƒƒn?|tkr^|dt||ƒƒn||}|dkrº|r�|t||ƒƒnxä|D]}t||||dƒq—Wn½|d|ƒ|jƒ}|sà|rÏ|rNxet|jƒdd„ƒD]E\} } | r!d| } n|d| j |ƒt | |ƒfƒqWnx~t|ƒD]m\} } t | t ƒr‚| j} nt | t ƒr¡|| j} nt | |ƒ} |d|| | fƒq[Wn|d ƒ|jƒ} |r/| d ks| d kr|t||ƒƒq/|t||ƒƒnx$|D]}t||||dƒq6W| tkrw|d |d ƒn|jr™|t|j|ƒƒndS( Ns sR�RKcSs|dS(Ni((R�((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR‘ÎRR’s xmlns%s="%s"s %s="%s"R“tscripttstyles;s        ÿU     â D /  2           b   M Ñ PK:©ç\­‚ܤ�¤�etree/ElementTree.pyonu„[µü¤ó ›V~gc@s>dddddddddd d d d d dddddddgZdZddlZddlZddlZdefd„ƒYZyddlmZWne k rµeƒZnXd e fd„ƒYZ d„Z defd„ƒYZ e ZZid„Zed „Zed!„ZeZd efd"„ƒYZdefd#„ƒYZed$„Zd%„Zd&d'd(d)d*d+d,d-d.d/d0d1d2f ZyeeƒZWnek r°nXd3„Zd4„Zied56ed66ed76Zd8„Zid5d96d6d:6d;d<6d=d>6d?d@6dAdB6dCdD6Z dE„Z!dF„Z"dG„Z#dH„Z$dI„Z%eedJ„Z&eedK„Z'dL„Z(edM„Z)eedN„Z*dOefdP„ƒYZ+edQ„Z,edR„Z-e,Z.edS„Z/defdT„ƒYZ0dUgZ1defdV„ƒYZ2e2Z3yddWl4m5Z5e5edX(treprRtid(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__repr__ÖscCs|j||ƒS(N(t __class__(RRR,((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt makeelementàscCs;|j|j|jƒ}|j|_|j|_||(|S(N(R4RR,Rttail(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR*és   cCs t|jƒS(N(tlenR-(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__len__÷scCs)tjdtddƒt|jƒdkS(NsyThe behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.t stacklevelii(twarningstwarnt FutureWarningR6R-(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt __nonzero__ús cCs |j|S(N(R-(Rtindex((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt __getitem__ scCs||j||D]6}x|jƒD] }|VqWW|jrD|jVqDqDWdS(N(RR(t basestringRRtitertextR5(RRRQts((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyRUòs      N(!R%R&RRR,RR5R/R2R4R*R7R<R>R?R@RARBRDRERGRR R$R"RIRJRMRNROR!RSRU(((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR«s<             cKs<|jƒ}|j|ƒ|j||ƒ}|j|ƒ|S(N(R*R+R4RA(tparentRR,R.R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR s    cCsttƒ}||_|S(N(RRR(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR"s  cCs6ttƒ}||_|r2|jd||_n|S(Nt (RR R(ttargetRR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR 1s   cBs/eZdd„Zd„Zd„Zd„ZRS(cCs&|rd||f}n||_dS(Ns{%s}%s(R(Rt text_or_uriR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR/EscCs|jS(N(R(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__str__IscCs t|jƒS(N(thashR(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__hash__KscCs2t|tƒr"t|j|jƒSt|j|ƒS(N(R(R tcmpR(Rtother((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt__cmp__MsN(R%R&RR/R[R]R`(((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR Ds   cBsžeZd d d„Zd„Zd„Zd d„Zd d„Zd d„Zd d„Z d d d„Z d d„Z d d „Z d d d d d „Z d „ZRS( cCs#||_|r|j|ƒndS(N(t_rootR(RRtfile((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR/_s cCs|jS(N(Ra(R((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pytgetrootkscCs ||_dS(N(Ra(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt_setrootuscCsªt}t|dƒs-t|dƒ}t}nzb|sKtdtƒƒ}nx*|jdƒ}|sgPn|j|ƒqNW|jƒ|_ |j SWd|r¥|jƒnXdS(NtreadtrbRYi( tFalseR)topentTrueRRRetfeedtcloseRa(Rtsourcetparsert close_sourcetdata((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR„s   cCs|jj|ƒS(N(RaR!(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR!ŸscCs)tjdtddƒt|j|ƒƒS(NsbThis method will be removed in future versions. Use 'tree.iter()' or 'list(tree.iter())' instead.R8i(R9R:RRR#R!(RR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyRS¤s cCsJ|d dkr7d|}tjd|tddƒn|jj||ƒS(Nit/t.s‡This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rR8i(R9R:R;RaR(RRHR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR¶s cCsM|d dkr7d|}tjd|tddƒn|jj|||ƒS(NiRpRqs‡This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rR8i(R9R:R;RaR (RRHRR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR Îs cCsJ|d dkr7d|}tjd|tddƒn|jj||ƒS(NiRpRqs‡This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rR8i(R9R:R;RaR$(RRHR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR$ãs cCsJ|d dkr7d|}tjd|tddƒn|jj||ƒS(NiRpRqs‡This search is broken in 1.3 and earlier, and will be fixed in a future version. If you rely on the current behaviour, change it to %rR8i(R9R:R;RaR"(RRHR((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR"ùs c Cs=|sd}n|tkr.td|ƒ‚nt|dƒrF|}nt|dƒ}|j}|s‚|dkryd}qÀd}n>|s |dkrÀ|d krÀ|dkrÀ|d|ƒqÀn|d krât||j|ƒn>t|j||ƒ\}} t|} | ||j||| ƒ||k r9|j ƒndS( Ntxmlsunknown method %rtwritetwbtc14nsutf-8sus-asciis$ R(sutf-8sus-ascii( t _serializet ValueErrorR)RhRsRt_serialize_textRat _namespacesRk( Rtfile_or_filenametencodingtxml_declarationtdefault_namespacetmethodRbRstqnamesRt serialize((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyRss0            cCs|j|ddƒS(NR~Ru(Rs(RRb((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyt write_c14n8sN(R%R&RR/RcRdRR!RSRR R$R"RsR�(((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR]s        c sáidd6‰i‰ˆr&dˆˆ       $     c Css|j}|j}|tkr8|dt||ƒƒn|tkr^|dt||ƒƒnï||}|dkrº|r�|t||ƒƒnxº|D]}t||||dƒq—Wn“|d|ƒ|jƒ}|sà|rÏ|rNxet |jƒdd„ƒD]E\} } | r!d| } n|d| j |ƒt | |ƒfƒqWnx~t |ƒD]m\} } t | t ƒr‚| j} nt | t ƒr¡|| j} nt | |ƒ} |d|| | fƒq[Wn|sát|ƒrC|d ƒ|r|t||ƒƒnx$|D]}t||||dƒqW|d |d ƒn |d ƒ|jro|t|j|ƒƒndS( Ns st—Rt:s xmlns%s="%s"s %s="%s"t>s(RRRt_encodeR Rt _escape_cdatat_serialize_xmlROtsortedR‚t_escape_attribR(R R6R5( RsRR{RRRRRQROtvtk((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR–ƒsP                tareatbasetbasefonttbrtcoltframethrtimgtinputtisindextlinktmetatparamc Cs�|j}|j}|tkr8|dt||ƒƒn?|tkr^|dt||ƒƒn||}|dkrº|r�|t||ƒƒnxä|D]}t||||dƒq—Wn½|d|ƒ|jƒ}|sà|rÏ|rNxet|jƒdd„ƒD]E\} } | r!d| } n|d| j |ƒt | |ƒfƒqWnx~t|ƒD]m\} } t | t ƒr‚| j} nt | t ƒr¡|| j} nt | |ƒ} |d|| | fƒq[Wn|d ƒ|jƒ} |r/| d ks| d kr|t||ƒƒq/|t||ƒƒnx$|D]}t||||dƒq6W| tkrw|d |d ƒn|jr™|t|j|ƒƒndS( Ns sR�RKcSs|dS(Ni((R�((s:/opt/alt/python27/lib64/python2.7/xml/etree/ElementTree.pyR‘ÎRR’s xmlns%s="%s"s %s="%s"R“tscripttstyles;s        ÿU     â D /  2           b   M Ñ PK:©ç\W€ZµDDetree/__init__.pynu„[µü¤# $Id: __init__.py 3375 2008-02-13 08:05:08Z fredrik $ # elementtree package # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2008 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Secret Labs AB or the author not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See http://www.python.org/psf/license for licensing details. PK:©ç\lˆZŽŽetree/__init__.pycnu„[µü¤ó ›V~gc@sdS(N((((s7/opt/alt/python27/lib64/python2.7/xml/etree/__init__.pyttPK:©ç\lˆZŽŽetree/__init__.pyonu„[µü¤ó ›V~gc@sdS(N((((s7/opt/alt/python27/lib64/python2.7/xml/etree/__init__.pyttPK:©ç\ð>)>>etree/cElementTree.pynu„[µü¤# Wrapper module for _elementtree from _elementtree import * PK:©ç\"Š£’½½etree/cElementTree.pycnu„[µü¤ó ›V~gc@sddlTdS(iÿÿÿÿ(t*N(t _elementtree(((s;/opt/alt/python27/lib64/python2.7/xml/etree/cElementTree.pyttPK:©ç\"Š£’½½etree/cElementTree.pyonu„[µü¤ó ›V~gc@sddlTdS(iÿÿÿÿ(t*N(t _elementtree(((s;/opt/alt/python27/lib64/python2.7/xml/etree/cElementTree.pyttPK:©ç\;Ý|¹§§parsers/__init__.pynu„[µü¤"""Python interfaces to XML parsers. This package contains one module: expat -- Python wrapper for James Clark's Expat parser, with namespace support. """ PK:©ç\Áš“GGparsers/__init__.pycnu„[µü¤ó ›V~gc@s dZdS(s Python interfaces to XML parsers. This package contains one module: expat -- Python wrapper for James Clark's Expat parser, with namespace support. N(t__doc__(((s9/opt/alt/python27/lib64/python2.7/xml/parsers/__init__.pyttPK:©ç\Áš“GGparsers/__init__.pyonu„[µü¤ó ›V~gc@s dZdS(s Python interfaces to XML parsers. This package contains one module: expat -- Python wrapper for James Clark's Expat parser, with namespace support. N(t__doc__(((s9/opt/alt/python27/lib64/python2.7/xml/parsers/__init__.pyttPK:©ç\¹vÙÏrrparsers/expat.pynu„[µü¤"""Interface to the Expat non-validating XML parser.""" __version__ = '$Revision: 17640 $' from pyexpat import * PK:©ç\�¥g,,parsers/expat.pycnu„[µü¤ó ›V~gc@sdZdZddlTdS(s1Interface to the Expat non-validating XML parser.s$Revision: 17640 $iÿÿÿÿ(t*N(t__doc__t __version__tpyexpat(((s6/opt/alt/python27/lib64/python2.7/xml/parsers/expat.pytsPK:©ç\�¥g,,parsers/expat.pyonu„[µü¤ó ›V~gc@sdZdZddlTdS(s1Interface to the Expat non-validating XML parser.s$Revision: 17640 $iÿÿÿÿ(t*N(t__doc__t __version__tpyexpat(((s6/opt/alt/python27/lib64/python2.7/xml/parsers/expat.pytsPK:©ç\,†•ÿ""sax/__init__.pynu„[µü¤"""Simple API for XML (SAX) implementation for Python. This module provides an implementation of the SAX 2 interface; information about the Java version of the interface can be found at http://www.megginson.com/SAX/. The Python version of the interface is documented at <...>. This package contains the following modules: handler -- Base classes and constants which define the SAX 2 API for the 'client-side' of SAX for Python. saxutils -- Implementation of the convenience classes commonly used to work with SAX. xmlreader -- Base classes and constants which define the SAX 2 API for the parsers used with SAX for Python. expatreader -- Driver that allows use of the Expat parser with SAX. """ from xmlreader import InputSource from handler import ContentHandler, ErrorHandler from _exceptions import SAXException, SAXNotRecognizedException, \ SAXParseException, SAXNotSupportedException, \ SAXReaderNotAvailable def parse(source, handler, errorHandler=ErrorHandler()): parser = make_parser() parser.setContentHandler(handler) parser.setErrorHandler(errorHandler) parser.parse(source) def parseString(string, handler, errorHandler=ErrorHandler()): try: from cStringIO import StringIO except ImportError: from StringIO import StringIO if errorHandler is None: errorHandler = ErrorHandler() parser = make_parser() parser.setContentHandler(handler) parser.setErrorHandler(errorHandler) inpsrc = InputSource() inpsrc.setByteStream(StringIO(string)) parser.parse(inpsrc) # this is the parser list used by the make_parser function if no # alternatives are given as parameters to the function default_parser_list = ["xml.sax.expatreader"] # tell modulefinder that importing sax potentially imports expatreader _false = 0 if _false: import xml.sax.expatreader import os, sys if not sys.flags.ignore_environment and "PY_SAX_PARSER" in os.environ: default_parser_list = os.environ["PY_SAX_PARSER"].split(",") del os _key = "python.xml.sax.parser" if sys.platform[:4] == "java" and sys.registry.containsKey(_key): default_parser_list = sys.registry.getProperty(_key).split(",") def make_parser(parser_list = []): """Creates and returns a SAX parser. Creates the first parser it is able to instantiate of the ones given in the list created by doing parser_list + default_parser_list. The lists must contain the names of Python modules containing both a SAX parser and a create_parser function.""" for parser_name in parser_list + default_parser_list: try: return _create_parser(parser_name) except ImportError,e: import sys if parser_name in sys.modules: # The parser module was found, but importing it # failed unexpectedly, pass this exception through raise except SAXReaderNotAvailable: # The parser module detected that it won't work properly, # so try the next one pass raise SAXReaderNotAvailable("No parsers found", None) # --- Internal utility methods used by make_parser if sys.platform[ : 4] == "java": def _create_parser(parser_name): from org.python.core import imp drv_module = imp.importName(parser_name, 0, globals()) return drv_module.create_parser() else: def _create_parser(parser_name): drv_module = __import__(parser_name,{},{},['create_parser']) return drv_module.create_parser() del sys PK:©ç\3•z‘ïïsax/__init__.pycnu„[µü¤ó ›V~gc@sjdZddlmZddlmZmZddlmZmZm Z m Z m Z eƒd„Z eƒd„Z dgZdZer–dd lZndd lZdd lZejj rãd ejkrãejd jd ƒZn[d Zejd dkr/ejjeƒr/ejjeƒjd ƒZngd„Zejd dkrZd„Zn d„Z[d S(sÛSimple API for XML (SAX) implementation for Python. This module provides an implementation of the SAX 2 interface; information about the Java version of the interface can be found at http://www.megginson.com/SAX/. The Python version of the interface is documented at <...>. This package contains the following modules: handler -- Base classes and constants which define the SAX 2 API for the 'client-side' of SAX for Python. saxutils -- Implementation of the convenience classes commonly used to work with SAX. xmlreader -- Base classes and constants which define the SAX 2 API for the parsers used with SAX for Python. expatreader -- Driver that allows use of the Expat parser with SAX. iÿÿÿÿ(t InputSource(tContentHandlert ErrorHandler(t SAXExceptiontSAXNotRecognizedExceptiontSAXParseExceptiontSAXNotSupportedExceptiontSAXReaderNotAvailablecCs4tƒ}|j|ƒ|j|ƒ|j|ƒdS(N(t make_parsertsetContentHandlertsetErrorHandlertparse(tsourcethandlert errorHandlertparser((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyR s   cCs yddlm}Wn!tk r7ddlm}nX|dkrPtƒ}ntƒ}|j|ƒ|j|ƒtƒ}|j ||ƒƒ|j |ƒdS(Niÿÿÿÿ(tStringIO( t cStringIORt ImportErrortNoneRRR R Rt setByteStreamR (tstringR RRRtinpsrc((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyt parseString#s       sxml.sax.expatreaderiNt PY_SAX_PARSERt,spython.xml.sax.parseritjavacCs}xg|tD][}yt|ƒSWq tk rU}ddl}||jkrf‚qfq tk req Xq Wtddƒ‚dS(s&Creates and returns a SAX parser. Creates the first parser it is able to instantiate of the ones given in the list created by doing parser_list + default_parser_list. The lists must contain the names of Python modules containing both a SAX parser and a create_parser function.iÿÿÿÿNsNo parsers found(tdefault_parser_listt_create_parserRtsystmodulesRR(t parser_listt parser_nameteR((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyRGs   cCs2ddlm}|j|dtƒƒ}|jƒS(Niÿÿÿÿ(timpi(torg.python.coreR"t importNametglobalst create_parser(R R"t drv_module((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyRbscCs"t|iidgƒ}|jƒS(NR&(t __import__R&(R R'((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyRhs(t__doc__t xmlreaderRR RRt _exceptionsRRRRRR RRt_falsetxml.sax.expatreadertxmltosRtflagstignore_environmenttenvirontsplitt_keytplatformtregistryt containsKeyt getPropertyRR(((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyts*( %   PK:©ç\3•z‘ïïsax/__init__.pyonu„[µü¤ó ›V~gc@sjdZddlmZddlmZmZddlmZmZm Z m Z m Z eƒd„Z eƒd„Z dgZdZer–dd lZndd lZdd lZejj rãd ejkrãejd jd ƒZn[d Zejd dkr/ejjeƒr/ejjeƒjd ƒZngd„Zejd dkrZd„Zn d„Z[d S(sÛSimple API for XML (SAX) implementation for Python. This module provides an implementation of the SAX 2 interface; information about the Java version of the interface can be found at http://www.megginson.com/SAX/. The Python version of the interface is documented at <...>. This package contains the following modules: handler -- Base classes and constants which define the SAX 2 API for the 'client-side' of SAX for Python. saxutils -- Implementation of the convenience classes commonly used to work with SAX. xmlreader -- Base classes and constants which define the SAX 2 API for the parsers used with SAX for Python. expatreader -- Driver that allows use of the Expat parser with SAX. iÿÿÿÿ(t InputSource(tContentHandlert ErrorHandler(t SAXExceptiontSAXNotRecognizedExceptiontSAXParseExceptiontSAXNotSupportedExceptiontSAXReaderNotAvailablecCs4tƒ}|j|ƒ|j|ƒ|j|ƒdS(N(t make_parsertsetContentHandlertsetErrorHandlertparse(tsourcethandlert errorHandlertparser((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyR s   cCs yddlm}Wn!tk r7ddlm}nX|dkrPtƒ}ntƒ}|j|ƒ|j|ƒtƒ}|j ||ƒƒ|j |ƒdS(Niÿÿÿÿ(tStringIO( t cStringIORt ImportErrortNoneRRR R Rt setByteStreamR (tstringR RRRtinpsrc((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyt parseString#s       sxml.sax.expatreaderiNt PY_SAX_PARSERt,spython.xml.sax.parseritjavacCs}xg|tD][}yt|ƒSWq tk rU}ddl}||jkrf‚qfq tk req Xq Wtddƒ‚dS(s&Creates and returns a SAX parser. Creates the first parser it is able to instantiate of the ones given in the list created by doing parser_list + default_parser_list. The lists must contain the names of Python modules containing both a SAX parser and a create_parser function.iÿÿÿÿNsNo parsers found(tdefault_parser_listt_create_parserRtsystmodulesRR(t parser_listt parser_nameteR((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyRGs   cCs2ddlm}|j|dtƒƒ}|jƒS(Niÿÿÿÿ(timpi(torg.python.coreR"t importNametglobalst create_parser(R R"t drv_module((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyRbscCs"t|iidgƒ}|jƒS(NR&(t __import__R&(R R'((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyRhs(t__doc__t xmlreaderRR RRt _exceptionsRRRRRR RRt_falsetxml.sax.expatreadertxmltosRtflagstignore_environmenttenvirontsplitt_keytplatformtregistryt containsKeyt getPropertyRR(((s5/opt/alt/python27/lib64/python2.7/xml/sax/__init__.pyts*( %   PK:©ç\}F¾¾±±sax/_exceptions.pynu„[µü¤"""Different kinds of SAX Exceptions""" import sys if sys.platform[:4] == "java": from java.lang import Exception del sys # ===== SAXEXCEPTION ===== class SAXException(Exception): """Encapsulate an XML error or warning. This class can contain basic error or warning information from either the XML parser or the application: you can subclass it to provide additional functionality, or to add localization. Note that although you will receive a SAXException as the argument to the handlers in the ErrorHandler interface, you are not actually required to raise the exception; instead, you can simply read the information in it.""" def __init__(self, msg, exception=None): """Creates an exception. The message is required, but the exception is optional.""" self._msg = msg self._exception = exception Exception.__init__(self, msg) def getMessage(self): "Return a message for this exception." return self._msg def getException(self): "Return the embedded exception, or None if there was none." return self._exception def __str__(self): "Create a string representation of the exception." return self._msg def __getitem__(self, ix): """Avoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined.""" raise AttributeError("__getitem__") # ===== SAXPARSEEXCEPTION ===== class SAXParseException(SAXException): """Encapsulate an XML parse error or warning. This exception will include information for locating the error in the original XML document. Note that although the application will receive a SAXParseException as the argument to the handlers in the ErrorHandler interface, the application is not actually required to raise the exception; instead, it can simply read the information in it and take a different action. Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception.""" def __init__(self, msg, exception, locator): "Creates the exception. The exception parameter is allowed to be None." SAXException.__init__(self, msg, exception) self._locator = locator # We need to cache this stuff at construction time. # If this exception is raised, the objects through which we must # traverse to get this information may be deleted by the time # it gets caught. self._systemId = self._locator.getSystemId() self._colnum = self._locator.getColumnNumber() self._linenum = self._locator.getLineNumber() def getColumnNumber(self): """The column number of the end of the text where the exception occurred.""" return self._colnum def getLineNumber(self): "The line number of the end of the text where the exception occurred." return self._linenum def getPublicId(self): "Get the public identifier of the entity where the exception occurred." return self._locator.getPublicId() def getSystemId(self): "Get the system identifier of the entity where the exception occurred." return self._systemId def __str__(self): "Create a string representation of the exception." sysid = self.getSystemId() if sysid is None: sysid = "" linenum = self.getLineNumber() if linenum is None: linenum = "?" colnum = self.getColumnNumber() if colnum is None: colnum = "?" return "%s:%s:%s: %s" % (sysid, linenum, colnum, self._msg) # ===== SAXNOTRECOGNIZEDEXCEPTION ===== class SAXNotRecognizedException(SAXException): """Exception class for an unrecognized identifier. An XMLReader will raise this exception when it is confronted with an unrecognized feature or property. SAX applications and extensions may use this class for similar purposes.""" # ===== SAXNOTSUPPORTEDEXCEPTION ===== class SAXNotSupportedException(SAXException): """Exception class for an unsupported operation. An XMLReader will raise this exception when a service it cannot perform is requested (specifically setting a state or value). SAX applications and extensions may use this class for similar purposes.""" # ===== SAXNOTSUPPORTEDEXCEPTION ===== class SAXReaderNotAvailable(SAXNotSupportedException): """Exception class for a missing driver. An XMLReader module (driver) should raise this exception when it is first imported, e.g. when a support module cannot be imported. It also may be raised during parsing, e.g. if executing an external program is not permitted.""" PK:©ç\ßÃÝÃöösax/_exceptions.pycnu„[µü¤ó ›V~gc@s­dZddlZejd dkr8ddlmZn[defd„ƒYZdefd „ƒYZd efd „ƒYZd efd „ƒYZdefd„ƒYZ dS(s!Different kinds of SAX ExceptionsiÿÿÿÿNitjava(t Exceptiont SAXExceptioncBs>eZdZdd„Zd„Zd„Zd„Zd„ZRS(sÖEncapsulate an XML error or warning. This class can contain basic error or warning information from either the XML parser or the application: you can subclass it to provide additional functionality, or to add localization. Note that although you will receive a SAXException as the argument to the handlers in the ErrorHandler interface, you are not actually required to raise the exception; instead, you can simply read the information in it.cCs&||_||_tj||ƒdS(sUCreates an exception. The message is required, but the exception is optional.N(t_msgt _exceptionRt__init__(tselftmsgt exception((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRs  cCs|jS(s$Return a message for this exception.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyt getMessagescCs|jS(s9Return the embedded exception, or None if there was none.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyt getExceptionscCs|jS(s0Create a string representation of the exception.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyt__str__"scCstdƒ‚dS(svAvoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined.t __getitem__N(tAttributeError(Rtix((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR &sN( t__name__t __module__t__doc__tNoneRR R R R (((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR s     tSAXParseExceptioncBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s#Encapsulate an XML parse error or warning. This exception will include information for locating the error in the original XML document. Note that although the application will receive a SAXParseException as the argument to the handlers in the ErrorHandler interface, the application is not actually required to raise the exception; instead, it can simply read the information in it and take a different action. Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception.cCsVtj|||ƒ||_|jjƒ|_|jjƒ|_|jjƒ|_dS(sECreates the exception. The exception parameter is allowed to be None.N( RRt_locatort getSystemIdt _systemIdtgetColumnNumbert_colnumt getLineNumbert_linenum(RRRtlocator((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR;s  cCs|jS(sNThe column number of the end of the text where the exception occurred.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRHscCs|jS(sDThe line number of the end of the text where the exception occurred.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRMscCs |jjƒS(sEGet the public identifier of the entity where the exception occurred.(Rt getPublicId(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRQscCs|jS(sEGet the system identifier of the entity where the exception occurred.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRUscCsz|jƒ}|dkr!d}n|jƒ}|dkrBd}n|jƒ}|dkrcd}nd||||jfS(s0Create a string representation of the exception.s t?s %s:%s:%s: %sN(RRRRR(Rtsysidtlinenumtcolnum((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR Ys         ( RRRRRRRRR (((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR.s     tSAXNotRecognizedExceptioncBseZdZRS(sìException class for an unrecognized identifier. An XMLReader will raise this exception when it is confronted with an unrecognized feature or property. SAX applications and extensions may use this class for similar purposes.(RRR(((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR!istSAXNotSupportedExceptioncBseZdZRS(sException class for an unsupported operation. An XMLReader will raise this exception when a service it cannot perform is requested (specifically setting a state or value). SAX applications and extensions may use this class for similar purposes.(RRR(((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR"sstSAXReaderNotAvailablecBseZdZRS(sException class for a missing driver. An XMLReader module (driver) should raise this exception when it is first imported, e.g. when a support module cannot be imported. It also may be raised during parsing, e.g. if executing an external program is not permitted.(RRR(((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR#}s( Rtsystplatformt java.langRRRR!R"R#(((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyts %;  PK:©ç\ßÃÝÃöösax/_exceptions.pyonu„[µü¤ó ›V~gc@s­dZddlZejd dkr8ddlmZn[defd„ƒYZdefd „ƒYZd efd „ƒYZd efd „ƒYZdefd„ƒYZ dS(s!Different kinds of SAX ExceptionsiÿÿÿÿNitjava(t Exceptiont SAXExceptioncBs>eZdZdd„Zd„Zd„Zd„Zd„ZRS(sÖEncapsulate an XML error or warning. This class can contain basic error or warning information from either the XML parser or the application: you can subclass it to provide additional functionality, or to add localization. Note that although you will receive a SAXException as the argument to the handlers in the ErrorHandler interface, you are not actually required to raise the exception; instead, you can simply read the information in it.cCs&||_||_tj||ƒdS(sUCreates an exception. The message is required, but the exception is optional.N(t_msgt _exceptionRt__init__(tselftmsgt exception((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRs  cCs|jS(s$Return a message for this exception.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyt getMessagescCs|jS(s9Return the embedded exception, or None if there was none.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyt getExceptionscCs|jS(s0Create a string representation of the exception.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyt__str__"scCstdƒ‚dS(svAvoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined.t __getitem__N(tAttributeError(Rtix((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR &sN( t__name__t __module__t__doc__tNoneRR R R R (((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR s     tSAXParseExceptioncBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s#Encapsulate an XML parse error or warning. This exception will include information for locating the error in the original XML document. Note that although the application will receive a SAXParseException as the argument to the handlers in the ErrorHandler interface, the application is not actually required to raise the exception; instead, it can simply read the information in it and take a different action. Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception.cCsVtj|||ƒ||_|jjƒ|_|jjƒ|_|jjƒ|_dS(sECreates the exception. The exception parameter is allowed to be None.N( RRt_locatort getSystemIdt _systemIdtgetColumnNumbert_colnumt getLineNumbert_linenum(RRRtlocator((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR;s  cCs|jS(sNThe column number of the end of the text where the exception occurred.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRHscCs|jS(sDThe line number of the end of the text where the exception occurred.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRMscCs |jjƒS(sEGet the public identifier of the entity where the exception occurred.(Rt getPublicId(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRQscCs|jS(sEGet the system identifier of the entity where the exception occurred.(R(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyRUscCsz|jƒ}|dkr!d}n|jƒ}|dkrBd}n|jƒ}|dkrcd}nd||||jfS(s0Create a string representation of the exception.s t?s %s:%s:%s: %sN(RRRRR(Rtsysidtlinenumtcolnum((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR Ys         ( RRRRRRRRR (((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR.s     tSAXNotRecognizedExceptioncBseZdZRS(sìException class for an unrecognized identifier. An XMLReader will raise this exception when it is confronted with an unrecognized feature or property. SAX applications and extensions may use this class for similar purposes.(RRR(((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR!istSAXNotSupportedExceptioncBseZdZRS(sException class for an unsupported operation. An XMLReader will raise this exception when a service it cannot perform is requested (specifically setting a state or value). SAX applications and extensions may use this class for similar purposes.(RRR(((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR"sstSAXReaderNotAvailablecBseZdZRS(sException class for a missing driver. An XMLReader module (driver) should raise this exception when it is first imported, e.g. when a support module cannot be imported. It also may be raised during parsing, e.g. if executing an external program is not permitted.(RRR(((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyR#}s( Rtsystplatformt java.langRRRR!R"R#(((s8/opt/alt/python27/lib64/python2.7/xml/sax/_exceptions.pyts %;  PK:©ç\~bÙÏÄ=Ä=sax/expatreader.pynu„[µü¤""" SAX driver for the pyexpat C module. This driver works with pyexpat.__version__ == '2.22'. """ version = "0.20" from xml.sax._exceptions import * from xml.sax.handler import feature_validation, feature_namespaces from xml.sax.handler import feature_namespace_prefixes from xml.sax.handler import feature_external_ges, feature_external_pes from xml.sax.handler import feature_string_interning from xml.sax.handler import property_xml_string, property_interning_dict # xml.parsers.expat does not raise ImportError in Jython import sys if sys.platform[:4] == "java": raise SAXReaderNotAvailable("expat not available in Java", None) del sys try: from xml.parsers import expat except ImportError: raise SAXReaderNotAvailable("expat not supported", None) else: if not hasattr(expat, "ParserCreate"): raise SAXReaderNotAvailable("expat not supported", None) from xml.sax import xmlreader, saxutils, handler AttributesImpl = xmlreader.AttributesImpl AttributesNSImpl = xmlreader.AttributesNSImpl # If we're using a sufficiently recent version of Python, we can use # weak references to avoid cycles between the parser and content # handler, otherwise we'll just have to pretend. try: import _weakref except ImportError: def _mkproxy(o): return o else: import weakref _mkproxy = weakref.proxy del weakref, _weakref class _ClosedParser: pass # --- ExpatLocator class ExpatLocator(xmlreader.Locator): """Locator for use with the ExpatParser class. This uses a weak reference to the parser object to avoid creating a circular reference between the parser and the content handler. """ def __init__(self, parser): self._ref = _mkproxy(parser) def getColumnNumber(self): parser = self._ref if parser._parser is None: return None return parser._parser.ErrorColumnNumber def getLineNumber(self): parser = self._ref if parser._parser is None: return 1 return parser._parser.ErrorLineNumber def getPublicId(self): parser = self._ref if parser is None: return None return parser._source.getPublicId() def getSystemId(self): parser = self._ref if parser is None: return None return parser._source.getSystemId() # --- ExpatParser class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): """SAX driver for the pyexpat C module.""" def __init__(self, namespaceHandling=0, bufsize=2**16-20): xmlreader.IncrementalParser.__init__(self, bufsize) self._source = xmlreader.InputSource() self._parser = None self._namespaces = namespaceHandling self._lex_handler_prop = None self._parsing = 0 self._entity_stack = [] self._external_ges = 1 self._interning = None # XMLReader methods def parse(self, source): "Parse an XML document from a URL or an InputSource." source = saxutils.prepare_input_source(source) self._source = source try: self.reset() self._cont_handler.setDocumentLocator(ExpatLocator(self)) xmlreader.IncrementalParser.parse(self, source) except: # bpo-30264: Close the source on error to not leak resources: # xml.sax.parse() doesn't give access to the underlying parser # to the caller self._close_source() raise def prepareParser(self, source): if source.getSystemId() is not None: base = source.getSystemId() if isinstance(base, unicode): base = base.encode('utf-8') self._parser.SetBase(base) # Redefined setContentHandler to allow changing handlers during parsing def setContentHandler(self, handler): xmlreader.IncrementalParser.setContentHandler(self, handler) if self._parsing: self._reset_cont_handler() def getFeature(self, name): if name == feature_namespaces: return self._namespaces elif name == feature_string_interning: return self._interning is not None elif name in (feature_validation, feature_external_pes, feature_namespace_prefixes): return 0 elif name == feature_external_ges: return self._external_ges raise SAXNotRecognizedException("Feature '%s' not recognized" % name) def setFeature(self, name, state): if self._parsing: raise SAXNotSupportedException("Cannot set features while parsing") if name == feature_namespaces: self._namespaces = state elif name == feature_external_ges: self._external_ges = state elif name == feature_string_interning: if state: if self._interning is None: self._interning = {} else: self._interning = None elif name == feature_validation: if state: raise SAXNotSupportedException( "expat does not support validation") elif name == feature_external_pes: if state: raise SAXNotSupportedException( "expat does not read external parameter entities") elif name == feature_namespace_prefixes: if state: raise SAXNotSupportedException( "expat does not report namespace prefixes") else: raise SAXNotRecognizedException( "Feature '%s' not recognized" % name) def getProperty(self, name): if name == handler.property_lexical_handler: return self._lex_handler_prop elif name == property_interning_dict: return self._interning elif name == property_xml_string: if self._parser: if hasattr(self._parser, "GetInputContext"): return self._parser.GetInputContext() else: raise SAXNotRecognizedException( "This version of expat does not support getting" " the XML string") else: raise SAXNotSupportedException( "XML string cannot be returned when not parsing") raise SAXNotRecognizedException("Property '%s' not recognized" % name) def setProperty(self, name, value): if name == handler.property_lexical_handler: self._lex_handler_prop = value if self._parsing: self._reset_lex_handler_prop() elif name == property_interning_dict: self._interning = value elif name == property_xml_string: raise SAXNotSupportedException("Property '%s' cannot be set" % name) else: raise SAXNotRecognizedException("Property '%s' not recognized" % name) # IncrementalParser methods def feed(self, data, isFinal = 0): if not self._parsing: self.reset() self._parsing = 1 self._cont_handler.startDocument() try: # The isFinal parameter is internal to the expat reader. # If it is set to true, expat will check validity of the entire # document. When feeding chunks, they are not normally final - # except when invoked from close. self._parser.Parse(data, isFinal) except expat.error, e: exc = SAXParseException(expat.ErrorString(e.code), e, self) # FIXME: when to invoke error()? self._err_handler.fatalError(exc) def _close_source(self): source = self._source try: file = source.getCharacterStream() if file is not None: file.close() finally: file = source.getByteStream() if file is not None: file.close() def close(self): if (self._entity_stack or self._parser is None or isinstance(self._parser, _ClosedParser)): # If we are completing an external entity, do nothing here return try: self.feed("", isFinal = 1) self._cont_handler.endDocument() self._parsing = 0 # break cycle created by expat handlers pointing to our methods self._parser = None finally: self._parsing = 0 if self._parser is not None: # Keep ErrorColumnNumber and ErrorLineNumber after closing. parser = _ClosedParser() parser.ErrorColumnNumber = self._parser.ErrorColumnNumber parser.ErrorLineNumber = self._parser.ErrorLineNumber self._parser = parser self._close_source() def _reset_cont_handler(self): self._parser.ProcessingInstructionHandler = \ self._cont_handler.processingInstruction self._parser.CharacterDataHandler = self._cont_handler.characters def _reset_lex_handler_prop(self): lex = self._lex_handler_prop parser = self._parser if lex is None: parser.CommentHandler = None parser.StartCdataSectionHandler = None parser.EndCdataSectionHandler = None parser.StartDoctypeDeclHandler = None parser.EndDoctypeDeclHandler = None else: parser.CommentHandler = lex.comment parser.StartCdataSectionHandler = lex.startCDATA parser.EndCdataSectionHandler = lex.endCDATA parser.StartDoctypeDeclHandler = self.start_doctype_decl parser.EndDoctypeDeclHandler = lex.endDTD def reset(self): if self._namespaces: self._parser = expat.ParserCreate(self._source.getEncoding(), " ", intern=self._interning) self._parser.namespace_prefixes = 1 self._parser.StartElementHandler = self.start_element_ns self._parser.EndElementHandler = self.end_element_ns else: self._parser = expat.ParserCreate(self._source.getEncoding(), intern = self._interning) self._parser.StartElementHandler = self.start_element self._parser.EndElementHandler = self.end_element self._reset_cont_handler() self._parser.UnparsedEntityDeclHandler = self.unparsed_entity_decl self._parser.NotationDeclHandler = self.notation_decl self._parser.StartNamespaceDeclHandler = self.start_namespace_decl self._parser.EndNamespaceDeclHandler = self.end_namespace_decl self._decl_handler_prop = None if self._lex_handler_prop: self._reset_lex_handler_prop() # self._parser.DefaultHandler = # self._parser.DefaultHandlerExpand = # self._parser.NotStandaloneHandler = self._parser.ExternalEntityRefHandler = self.external_entity_ref try: self._parser.SkippedEntityHandler = self.skipped_entity_handler except AttributeError: # This pyexpat does not support SkippedEntity pass self._parser.SetParamEntityParsing( expat.XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) self._parsing = 0 self._entity_stack = [] # Locator methods def getColumnNumber(self): if self._parser is None: return None return self._parser.ErrorColumnNumber def getLineNumber(self): if self._parser is None: return 1 return self._parser.ErrorLineNumber def getPublicId(self): return self._source.getPublicId() def getSystemId(self): return self._source.getSystemId() # event handlers def start_element(self, name, attrs): self._cont_handler.startElement(name, AttributesImpl(attrs)) def end_element(self, name): self._cont_handler.endElement(name) def start_element_ns(self, name, attrs): pair = name.split() if len(pair) == 1: # no namespace pair = (None, name) elif len(pair) == 3: pair = pair[0], pair[1] else: # default namespace pair = tuple(pair) newattrs = {} qnames = {} for (aname, value) in attrs.items(): parts = aname.split() length = len(parts) if length == 1: # no namespace qname = aname apair = (None, aname) elif length == 3: qname = "%s:%s" % (parts[2], parts[1]) apair = parts[0], parts[1] else: # default namespace qname = parts[1] apair = tuple(parts) newattrs[apair] = value qnames[apair] = qname self._cont_handler.startElementNS(pair, None, AttributesNSImpl(newattrs, qnames)) def end_element_ns(self, name): pair = name.split() if len(pair) == 1: pair = (None, name) elif len(pair) == 3: pair = pair[0], pair[1] else: pair = tuple(pair) self._cont_handler.endElementNS(pair, None) # this is not used (call directly to ContentHandler) def processing_instruction(self, target, data): self._cont_handler.processingInstruction(target, data) # this is not used (call directly to ContentHandler) def character_data(self, data): self._cont_handler.characters(data) def start_namespace_decl(self, prefix, uri): self._cont_handler.startPrefixMapping(prefix, uri) def end_namespace_decl(self, prefix): self._cont_handler.endPrefixMapping(prefix) def start_doctype_decl(self, name, sysid, pubid, has_internal_subset): self._lex_handler_prop.startDTD(name, pubid, sysid) def unparsed_entity_decl(self, name, base, sysid, pubid, notation_name): self._dtd_handler.unparsedEntityDecl(name, pubid, sysid, notation_name) def notation_decl(self, name, base, sysid, pubid): self._dtd_handler.notationDecl(name, pubid, sysid) def external_entity_ref(self, context, base, sysid, pubid): if not self._external_ges: return 1 source = self._ent_handler.resolveEntity(pubid, sysid) source = saxutils.prepare_input_source(source, self._source.getSystemId() or "") self._entity_stack.append((self._parser, self._source)) self._parser = self._parser.ExternalEntityParserCreate(context) self._source = source try: xmlreader.IncrementalParser.parse(self, source) except: return 0 # FIXME: save error info here? (self._parser, self._source) = self._entity_stack[-1] del self._entity_stack[-1] return 1 def skipped_entity_handler(self, name, is_pe): if is_pe: # The SAX spec requires to report skipped PEs with a '%' name = '%'+name self._cont_handler.skippedEntity(name) # --- def create_parser(*args, **kwargs): return ExpatParser(*args, **kwargs) # --- if __name__ == "__main__": import xml.sax.saxutils p = create_parser() p.setContentHandler(xml.sax.saxutils.XMLGenerator()) p.setErrorHandler(xml.sax.ErrorHandler()) p.parse("http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml") PK:©ç\WÖ‰¹g=g=sax/expatreader.pycnu„[µü¤ó ›V~gc@s3dZdZddlTddlmZmZddlmZddlmZmZddlm Z ddlm Z m Z dd l Z e j d d kr©ed eƒ‚n[ ydd lmZWn ek râedeƒ‚n#Xeedƒ redeƒ‚nddlmZmZmZejZejZydd lZWnek r_d„ZnXdd lZejZ[[dfd„ƒYZdejfd„ƒYZ dej!ejfd„ƒYZ"d„Z#e$dkr/dd l%Z&e#ƒZ'e'j(e&j)jj*ƒƒe'j+e&j)j,ƒƒe'j-dƒnd S(s] SAX driver for the pyexpat C module. This driver works with pyexpat.__version__ == '2.22'. s0.20iÿÿÿÿ(t*(tfeature_validationtfeature_namespaces(tfeature_namespace_prefixes(tfeature_external_gestfeature_external_pes(tfeature_string_interning(tproperty_xml_stringtproperty_interning_dictNitjavasexpat not available in Java(texpatsexpat not supportedt ParserCreate(t xmlreadertsaxutilsthandlercCs|S(N((to((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt_mkproxy'st _ClosedParsercBseZRS((t__name__t __module__(((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR.st ExpatLocatorcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(s¼Locator for use with the ExpatParser class. This uses a weak reference to the parser object to avoid creating a circular reference between the parser and the content handler. cCst|ƒ|_dS(N(Rt_ref(tselftparser((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt__init__9scCs&|j}|jdkrdS|jjS(N(Rt_parsertNonetErrorColumnNumber(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytgetColumnNumber<s cCs&|j}|jdkrdS|jjS(Ni(RRRtErrorLineNumber(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt getLineNumberBs cCs&|j}|dkrdS|jjƒS(N(RRt_sourcet getPublicId(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR Hs  cCs&|j}|dkrdS|jjƒS(N(RRRt getSystemId(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR!Ns  (RRt__doc__RRRR R!(((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR3s     t ExpatParsercBs.eZdZdd%d„Zd„Zd„Zd„Zd „Zd „Zd „Z d „Z dd „Z d„Z d„Z d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd „Zd!„Zd"„Z d#„Z!RS(&s$SAX driver for the pyexpat C module.iiiicCsetjj||ƒtjƒ|_d|_||_d|_d|_ g|_ d|_ d|_ dS(Nii( R tIncrementalParserRt InputSourceRRRt _namespacest_lex_handler_propt_parsingt _entity_stackt _external_gest _interning(RtnamespaceHandlingtbufsize((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRZs      cCsjtj|ƒ}||_y7|jƒ|jjt|ƒƒtjj ||ƒWn|j ƒ‚nXdS(s3Parse an XML document from a URL or an InputSource.N( R tprepare_input_sourceRtresett _cont_handlertsetDocumentLocatorRR R$tparset _close_source(Rtsource((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR2gs   cCsV|jƒdk rR|jƒ}t|tƒr?|jdƒ}n|jj|ƒndS(Nsutf-8(R!Rt isinstancetunicodetencodeRtSetBase(RR4tbase((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt prepareParserws  cCs-tjj||ƒ|jr)|jƒndS(N(R R$tsetContentHandlerR(t_reset_cont_handler(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR;€s cCsl|tkr|jS|tkr,|jdk S|tttfkrEdS|tkrX|j St d|ƒ‚dS(NisFeature '%s' not recognized( RR&RR+RRRRRR*tSAXNotRecognizedException(Rtname((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt getFeature…s      cCs|jrtdƒ‚n|tkr0||_nÐ|tkrH||_n¸|tkr„|rx|jdkr�i|_q�qd|_n||t kr¨|rtdƒ‚qnX|t krÌ|rtdƒ‚qn4|t krð|rtdƒ‚qnt d|ƒ‚dS(Ns!Cannot set features while parsings!expat does not support validations/expat does not read external parameter entitiess(expat does not report namespace prefixessFeature '%s' not recognized( R(tSAXNotSupportedExceptionRR&RR*RR+RRRRR=(RR>tstate((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt setFeature‘s2          cCs�|tjkr|jS|tkr)|jS|tkr{|jrlt|jdƒr]|jjƒSt dƒ‚q{t dƒ‚nt d|ƒ‚dS(NtGetInputContexts=This version of expat does not support getting the XML strings.XML string cannot be returned when not parsingsProperty '%s' not recognized( Rtproperty_lexical_handlerR'RR+RRthasattrRCR=R@(RR>((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt getProperty¯s      cCs||tjkr1||_|jrx|jƒqxnG|tkrI||_n/|tkrhtd|ƒ‚nt d|ƒ‚dS(NsProperty '%s' cannot be setsProperty '%s' not recognized( RRDR'R(t_reset_lex_handler_propRR+RR@R=(RR>tvalue((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt setPropertyÁs      cCsŽ|js,|jƒd|_|jjƒny|jj||ƒWnDtjk r‰}ttj |j ƒ||ƒ}|j j |ƒnXdS(Ni( R(R/R0t startDocumentRtParseR terrortSAXParseExceptiont ErrorStringtcodet _err_handlert fatalError(RtdatatisFinaltetexc((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytfeedÑs   cCs_|j}z)|jƒ}|dk r1|jƒnWd|jƒ}|dk rZ|jƒnXdS(N(RtgetCharacterStreamRtcloset getByteStream(RR4tfile((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR3âs     cCsÁ|js*|jdks*t|jtƒr.dSz6|jdddƒ|jjƒd|_d|_Wdd|_|jdk r²tƒ}|jj |_ |jj |_ ||_n|j ƒXdS(NtRSii( R)RRR5RRVR0t endDocumentR(RRR3(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRXís      cCs(|jj|j_|jj|j_dS(N(R0tprocessingInstructionRtProcessingInstructionHandlert characterstCharacterDataHandler(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR<scCsŽ|j}|j}|dkrNd|_d|_d|_d|_d|_n<|j|_|j |_|j |_|j |_|j |_dS(N( R'RRtCommentHandlertStartCdataSectionHandlertEndCdataSectionHandlertStartDoctypeDeclHandlertEndDoctypeDeclHandlertcommentt startCDATAtendCDATAtstart_doctype_decltendDTD(RtlexR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRGs            cCsc|jr]tj|jjƒdd|jƒ|_d|j_|j|j_ |j |j_ nBtj|jjƒd|jƒ|_|j |j_ |j |j_ |jƒ|j|j_|j|j_|j|j_|j|j_d|_|jr|jƒn|j|j_y|j|j_Wntk r9nX|jj tj!ƒd|_"g|_#dS(Nt tinternii($R&R R Rt getEncodingR+Rtnamespace_prefixeststart_element_nstStartElementHandlertend_element_nstEndElementHandlert start_elementt end_elementR<tunparsed_entity_decltUnparsedEntityDeclHandlert notation_decltNotationDeclHandlertstart_namespace_decltStartNamespaceDeclHandlertend_namespace_decltEndNamespaceDeclHandlerRt_decl_handler_propR'RGtexternal_entity_reftExternalEntityRefHandlertskipped_entity_handlertSkippedEntityHandlertAttributeErrortSetParamEntityParsingt*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONER(R)(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR/s6          cCs|jdkrdS|jjS(N(RRR(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR>scCs|jdkrdS|jjS(Ni(RRR(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRCscCs |jjƒS(N(RR (R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR HscCs |jjƒS(N(RR!(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR!KscCs|jj|t|ƒƒdS(N(R0t startElementtAttributesImpl(RR>tattrs((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRtOscCs|jj|ƒdS(N(R0t endElement(RR>((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRuRsc CsL|jƒ}t|ƒdkr-d|f}n5t|ƒdkrV|d|df}n t|ƒ}i}i}x¸|jƒD]ª\}}|jƒ}t|ƒ} | dkrÀ|} d|f} nQ| dkrûd|d|df} |d|df} n|d} t|ƒ} ||| <| || RˆtpairtnewattrstqnamestanameRHtpartstlengthtqnametapair((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRpUs.         cCsy|jƒ}t|ƒdkr-d|f}n5t|ƒdkrV|d|df}n t|ƒ}|jj|dƒdS(Niii(RŠR‹RRŒR0t endElementNS(RR>R�((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRrws  cCs|jj||ƒdS(N(R0R](RttargetRR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytprocessing_instructionƒscCs|jj|ƒdS(N(R0R_(RRR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytcharacter_data‡scCs|jj||ƒdS(N(R0tstartPrefixMapping(Rtprefixturi((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRzŠscCs|jj|ƒdS(N(R0tendPrefixMapping(RR�((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR|�scCs|jj|||ƒdS(N(R'tstartDTD(RR>tsysidtpubidthas_internal_subset((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRi�scCs|jj||||ƒdS(N(t _dtd_handlertunparsedEntityDecl(RR>R9R¡R¢t notation_name((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRv“scCs|jj|||ƒdS(N(R¤t notationDecl(RR>R9R¡R¢((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRx–scCsÆ|js dS|jj||ƒ}tj||jjƒp=dƒ}|jj|j |jfƒ|j j |ƒ|_ ||_yt j j ||ƒWndSX|jd\|_ |_|jd=dS(NiR[iiÿÿÿÿ(R*t _ent_handlert resolveEntityR R.RR!R)tappendRtExternalEntityParserCreateR R$R2(RtcontextR9R¡R¢R4((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR™s      cCs'|rd|}n|jj|ƒdS(Nt%(R0t skippedEntity(RR>tis_pe((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR�¯s iiìÿ("RRR"RR2R:R;R?RBRFRIRVR3RXR<RGR/RRR R!RtRuRpRrRšR›RzR|RiRvRxRR�(((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR#Ws@          '       "        cOs t||ŽS(N(R#(targstkwargs((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt create_parser·st__main__s:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml(.R"tversiontxml.sax._exceptionstxml.sax.handlerRRRRRRRRtsystplatformtSAXReaderNotAvailableRt xml.parsersR t ImportErrorREtxml.saxR R RR‡R�t_weakrefRtweakreftproxyRtLocatorRR$R#R²Rtxml.sax.saxutilstxmltpR;tsaxt XMLGeneratortsetErrorHandlert ErrorHandlerR2(((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytsL         $ÿa    PK:©ç\WÖ‰¹g=g=sax/expatreader.pyonu„[µü¤ó ›V~gc@s3dZdZddlTddlmZmZddlmZddlmZmZddlm Z ddlm Z m Z dd l Z e j d d kr©ed eƒ‚n[ ydd lmZWn ek râedeƒ‚n#Xeedƒ redeƒ‚nddlmZmZmZejZejZydd lZWnek r_d„ZnXdd lZejZ[[dfd„ƒYZdejfd„ƒYZ dej!ejfd„ƒYZ"d„Z#e$dkr/dd l%Z&e#ƒZ'e'j(e&j)jj*ƒƒe'j+e&j)j,ƒƒe'j-dƒnd S(s] SAX driver for the pyexpat C module. This driver works with pyexpat.__version__ == '2.22'. s0.20iÿÿÿÿ(t*(tfeature_validationtfeature_namespaces(tfeature_namespace_prefixes(tfeature_external_gestfeature_external_pes(tfeature_string_interning(tproperty_xml_stringtproperty_interning_dictNitjavasexpat not available in Java(texpatsexpat not supportedt ParserCreate(t xmlreadertsaxutilsthandlercCs|S(N((to((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt_mkproxy'st _ClosedParsercBseZRS((t__name__t __module__(((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR.st ExpatLocatorcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(s¼Locator for use with the ExpatParser class. This uses a weak reference to the parser object to avoid creating a circular reference between the parser and the content handler. cCst|ƒ|_dS(N(Rt_ref(tselftparser((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt__init__9scCs&|j}|jdkrdS|jjS(N(Rt_parsertNonetErrorColumnNumber(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytgetColumnNumber<s cCs&|j}|jdkrdS|jjS(Ni(RRRtErrorLineNumber(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt getLineNumberBs cCs&|j}|dkrdS|jjƒS(N(RRt_sourcet getPublicId(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR Hs  cCs&|j}|dkrdS|jjƒS(N(RRRt getSystemId(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR!Ns  (RRt__doc__RRRR R!(((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR3s     t ExpatParsercBs.eZdZdd%d„Zd„Zd„Zd„Zd „Zd „Zd „Z d „Z dd „Z d„Z d„Z d„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd „Zd!„Zd"„Z d#„Z!RS(&s$SAX driver for the pyexpat C module.iiiicCsetjj||ƒtjƒ|_d|_||_d|_d|_ g|_ d|_ d|_ dS(Nii( R tIncrementalParserRt InputSourceRRRt _namespacest_lex_handler_propt_parsingt _entity_stackt _external_gest _interning(RtnamespaceHandlingtbufsize((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRZs      cCsjtj|ƒ}||_y7|jƒ|jjt|ƒƒtjj ||ƒWn|j ƒ‚nXdS(s3Parse an XML document from a URL or an InputSource.N( R tprepare_input_sourceRtresett _cont_handlertsetDocumentLocatorRR R$tparset _close_source(Rtsource((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR2gs   cCsV|jƒdk rR|jƒ}t|tƒr?|jdƒ}n|jj|ƒndS(Nsutf-8(R!Rt isinstancetunicodetencodeRtSetBase(RR4tbase((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt prepareParserws  cCs-tjj||ƒ|jr)|jƒndS(N(R R$tsetContentHandlerR(t_reset_cont_handler(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR;€s cCsl|tkr|jS|tkr,|jdk S|tttfkrEdS|tkrX|j St d|ƒ‚dS(NisFeature '%s' not recognized( RR&RR+RRRRRR*tSAXNotRecognizedException(Rtname((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt getFeature…s      cCs|jrtdƒ‚n|tkr0||_nÐ|tkrH||_n¸|tkr„|rx|jdkr�i|_q�qd|_n||t kr¨|rtdƒ‚qnX|t krÌ|rtdƒ‚qn4|t krð|rtdƒ‚qnt d|ƒ‚dS(Ns!Cannot set features while parsings!expat does not support validations/expat does not read external parameter entitiess(expat does not report namespace prefixessFeature '%s' not recognized( R(tSAXNotSupportedExceptionRR&RR*RR+RRRRR=(RR>tstate((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt setFeature‘s2          cCs�|tjkr|jS|tkr)|jS|tkr{|jrlt|jdƒr]|jjƒSt dƒ‚q{t dƒ‚nt d|ƒ‚dS(NtGetInputContexts=This version of expat does not support getting the XML strings.XML string cannot be returned when not parsingsProperty '%s' not recognized( Rtproperty_lexical_handlerR'RR+RRthasattrRCR=R@(RR>((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt getProperty¯s      cCs||tjkr1||_|jrx|jƒqxnG|tkrI||_n/|tkrhtd|ƒ‚nt d|ƒ‚dS(NsProperty '%s' cannot be setsProperty '%s' not recognized( RRDR'R(t_reset_lex_handler_propRR+RR@R=(RR>tvalue((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt setPropertyÁs      cCsŽ|js,|jƒd|_|jjƒny|jj||ƒWnDtjk r‰}ttj |j ƒ||ƒ}|j j |ƒnXdS(Ni( R(R/R0t startDocumentRtParseR terrortSAXParseExceptiont ErrorStringtcodet _err_handlert fatalError(RtdatatisFinaltetexc((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytfeedÑs   cCs_|j}z)|jƒ}|dk r1|jƒnWd|jƒ}|dk rZ|jƒnXdS(N(RtgetCharacterStreamRtcloset getByteStream(RR4tfile((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR3âs     cCsÁ|js*|jdks*t|jtƒr.dSz6|jdddƒ|jjƒd|_d|_Wdd|_|jdk r²tƒ}|jj |_ |jj |_ ||_n|j ƒXdS(NtRSii( R)RRR5RRVR0t endDocumentR(RRR3(RR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRXís      cCs(|jj|j_|jj|j_dS(N(R0tprocessingInstructionRtProcessingInstructionHandlert characterstCharacterDataHandler(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR<scCsŽ|j}|j}|dkrNd|_d|_d|_d|_d|_n<|j|_|j |_|j |_|j |_|j |_dS(N( R'RRtCommentHandlertStartCdataSectionHandlertEndCdataSectionHandlertStartDoctypeDeclHandlertEndDoctypeDeclHandlertcommentt startCDATAtendCDATAtstart_doctype_decltendDTD(RtlexR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRGs            cCsc|jr]tj|jjƒdd|jƒ|_d|j_|j|j_ |j |j_ nBtj|jjƒd|jƒ|_|j |j_ |j |j_ |jƒ|j|j_|j|j_|j|j_|j|j_d|_|jr|jƒn|j|j_y|j|j_Wntk r9nX|jj tj!ƒd|_"g|_#dS(Nt tinternii($R&R R Rt getEncodingR+Rtnamespace_prefixeststart_element_nstStartElementHandlertend_element_nstEndElementHandlert start_elementt end_elementR<tunparsed_entity_decltUnparsedEntityDeclHandlert notation_decltNotationDeclHandlertstart_namespace_decltStartNamespaceDeclHandlertend_namespace_decltEndNamespaceDeclHandlerRt_decl_handler_propR'RGtexternal_entity_reftExternalEntityRefHandlertskipped_entity_handlertSkippedEntityHandlertAttributeErrortSetParamEntityParsingt*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONER(R)(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR/s6          cCs|jdkrdS|jjS(N(RRR(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR>scCs|jdkrdS|jjS(Ni(RRR(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRCscCs |jjƒS(N(RR (R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR HscCs |jjƒS(N(RR!(R((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR!KscCs|jj|t|ƒƒdS(N(R0t startElementtAttributesImpl(RR>tattrs((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRtOscCs|jj|ƒdS(N(R0t endElement(RR>((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRuRsc CsL|jƒ}t|ƒdkr-d|f}n5t|ƒdkrV|d|df}n t|ƒ}i}i}x¸|jƒD]ª\}}|jƒ}t|ƒ} | dkrÀ|} d|f} nQ| dkrûd|d|df} |d|df} n|d} t|ƒ} ||| <| || RˆtpairtnewattrstqnamestanameRHtpartstlengthtqnametapair((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRpUs.         cCsy|jƒ}t|ƒdkr-d|f}n5t|ƒdkrV|d|df}n t|ƒ}|jj|dƒdS(Niii(RŠR‹RRŒR0t endElementNS(RR>R�((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRrws  cCs|jj||ƒdS(N(R0R](RttargetRR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytprocessing_instructionƒscCs|jj|ƒdS(N(R0R_(RRR((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytcharacter_data‡scCs|jj||ƒdS(N(R0tstartPrefixMapping(Rtprefixturi((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRzŠscCs|jj|ƒdS(N(R0tendPrefixMapping(RR�((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR|�scCs|jj|||ƒdS(N(R'tstartDTD(RR>tsysidtpubidthas_internal_subset((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRi�scCs|jj||||ƒdS(N(t _dtd_handlertunparsedEntityDecl(RR>R9R¡R¢t notation_name((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRv“scCs|jj|||ƒdS(N(R¤t notationDecl(RR>R9R¡R¢((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyRx–scCsÆ|js dS|jj||ƒ}tj||jjƒp=dƒ}|jj|j |jfƒ|j j |ƒ|_ ||_yt j j ||ƒWndSX|jd\|_ |_|jd=dS(NiR[iiÿÿÿÿ(R*t _ent_handlert resolveEntityR R.RR!R)tappendRtExternalEntityParserCreateR R$R2(RtcontextR9R¡R¢R4((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR™s      cCs'|rd|}n|jj|ƒdS(Nt%(R0t skippedEntity(RR>tis_pe((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR�¯s iiìÿ("RRR"RR2R:R;R?RBRFRIRVR3RXR<RGR/RRR R!RtRuRpRrRšR›RzR|RiRvRxRR�(((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyR#Ws@          '       "        cOs t||ŽS(N(R#(targstkwargs((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pyt create_parser·st__main__s:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml(.R"tversiontxml.sax._exceptionstxml.sax.handlerRRRRRRRRtsystplatformtSAXReaderNotAvailableRt xml.parsersR t ImportErrorREtxml.saxR R RR‡R�t_weakrefRtweakreftproxyRtLocatorRR$R#R²Rtxml.sax.saxutilstxmltpR;tsaxt XMLGeneratortsetErrorHandlert ErrorHandlerR2(((s8/opt/alt/python27/lib64/python2.7/xml/sax/expatreader.pytsL         $ÿa    PK:©ç\sE(Áa6a6sax/handler.pynu„[µü¤""" This module contains the core classes of version 2.0 of SAX for Python. This file provides only default classes with absolutely minimum functionality, from which drivers and applications can be subclassed. Many of these classes are empty and are included only as documentation of the interfaces. $Id$ """ version = '2.0beta' #============================================================================ # # HANDLER INTERFACES # #============================================================================ # ===== ERRORHANDLER ===== class ErrorHandler: """Basic interface for SAX error handlers. If you create an object that implements this interface, then register the object with your XMLReader, the parser will call the methods in your object to report all warnings and errors. There are three levels of errors available: warnings, (possibly) recoverable errors, and unrecoverable errors. All methods take a SAXParseException as the only parameter.""" def error(self, exception): "Handle a recoverable error." raise exception def fatalError(self, exception): "Handle a non-recoverable error." raise exception def warning(self, exception): "Handle a warning." print exception # ===== CONTENTHANDLER ===== class ContentHandler: """Interface for receiving logical document content events. This is the main callback interface in SAX, and the one most important to applications. The order of events in this interface mirrors the order of the information in the document.""" def __init__(self): self._locator = None def setDocumentLocator(self, locator): """Called by the parser to give the application a locator for locating the origin of document events. SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface. The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine. Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.""" self._locator = locator def startDocument(self): """Receive notification of the beginning of a document. The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).""" def endDocument(self): """Receive notification of the end of a document. The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.""" def startPrefixMapping(self, prefix, uri): """Begin the scope of a prefix-URI Namespace mapping. The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default). There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary. Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.""" def endPrefixMapping(self, prefix): """End the scope of a prefix-URI mapping. See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.""" def startElement(self, name, attrs): """Signals the start of an element in non-namespace mode. The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.""" def endElement(self, name): """Signals the end of an element in non-namespace mode. The name parameter contains the name of the element type, just as with the startElement event.""" def startElementNS(self, name, qname, attrs): """Signals the start of an element in namespace mode. The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element. The uri part of the name tuple is None for elements which have no namespace.""" def endElementNS(self, name, qname): """Signals the end of an element in namespace mode. The name parameter contains the name of the element type, just as with the startElementNS event.""" def characters(self, content): """Receive notification of character data. The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.""" def ignorableWhitespace(self, whitespace): """Receive notification of ignorable whitespace in element content. Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models. SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.""" def processingInstruction(self, target, data): """Receive notification of a processing instruction. The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element. A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.""" def skippedEntity(self, name): """Receive notification of a skipped entity. The Parser will invoke this method once for each entity skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.""" # ===== DTDHandler ===== class DTDHandler: """Handle DTD events. This interface specifies only those DTD events required for basic parsing (unparsed entities and attributes).""" def notationDecl(self, name, publicId, systemId): "Handle a notation declaration event." def unparsedEntityDecl(self, name, publicId, systemId, ndata): "Handle an unparsed entity declaration event." # ===== ENTITYRESOLVER ===== class EntityResolver: """Basic interface for resolving entities. If you create an object implementing this interface, then register the object with your Parser, the parser will call the method in your object to resolve all external entities. Note that DefaultHandler implements this interface with the default behaviour.""" def resolveEntity(self, publicId, systemId): """Resolve the system identifier of an entity and return either the system identifier to read from as a string, or an InputSource to read from.""" return systemId #============================================================================ # # CORE FEATURES # #============================================================================ feature_namespaces = "http://xml.org/sax/features/namespaces" # true: Perform Namespace processing (default). # false: Optionally do not perform Namespace processing # (implies namespace-prefixes). # access: (parsing) read-only; (not parsing) read/write feature_namespace_prefixes = "http://xml.org/sax/features/namespace-prefixes" # true: Report the original prefixed names and attributes used for Namespace # declarations. # false: Do not report attributes used for Namespace declarations, and # optionally do not report original prefixed names (default). # access: (parsing) read-only; (not parsing) read/write feature_string_interning = "http://xml.org/sax/features/string-interning" # true: All element names, prefixes, attribute names, Namespace URIs, and # local names are interned using the built-in intern function. # false: Names are not necessarily interned, although they may be (default). # access: (parsing) read-only; (not parsing) read/write feature_validation = "http://xml.org/sax/features/validation" # true: Report all validation errors (implies external-general-entities and # external-parameter-entities). # false: Do not report validation errors. # access: (parsing) read-only; (not parsing) read/write feature_external_ges = "http://xml.org/sax/features/external-general-entities" # true: Include all external general (text) entities. # false: Do not include external general entities. # access: (parsing) read-only; (not parsing) read/write feature_external_pes = "http://xml.org/sax/features/external-parameter-entities" # true: Include all external parameter entities, including the external # DTD subset. # false: Do not include any external parameter entities, even the external # DTD subset. # access: (parsing) read-only; (not parsing) read/write all_features = [feature_namespaces, feature_namespace_prefixes, feature_string_interning, feature_validation, feature_external_ges, feature_external_pes] #============================================================================ # # CORE PROPERTIES # #============================================================================ property_lexical_handler = "http://xml.org/sax/properties/lexical-handler" # data type: xml.sax.sax2lib.LexicalHandler # description: An optional extension handler for lexical events like comments. # access: read/write property_declaration_handler = "http://xml.org/sax/properties/declaration-handler" # data type: xml.sax.sax2lib.DeclHandler # description: An optional extension handler for DTD-related events other # than notations and unparsed entities. # access: read/write property_dom_node = "http://xml.org/sax/properties/dom-node" # data type: org.w3c.dom.Node # description: When parsing, the current DOM node being visited if this is # a DOM iterator; when not parsing, the root DOM node for # iteration. # access: (parsing) read-only; (not parsing) read/write property_xml_string = "http://xml.org/sax/properties/xml-string" # data type: String # description: The literal string of characters that was the source for # the current event. # access: read-only property_encoding = "http://www.python.org/sax/properties/encoding" # data type: String # description: The name of the encoding to assume for input data. # access: write: set the encoding, e.g. established by a higher-level # protocol. May change during parsing (e.g. after # processing a META tag) # read: return the current encoding (possibly established through # auto-detection. # initial value: UTF-8 # property_interning_dict = "http://www.python.org/sax/properties/interning-dict" # data type: Dictionary # description: The dictionary used to intern common strings in the document # access: write: Request that the parser uses a specific dictionary, to # allow interning across different documents # read: return the current interning dictionary, or None # all_properties = [property_lexical_handler, property_dom_node, property_declaration_handler, property_xml_string, property_encoding, property_interning_dict] PK:©ç\0gd+)4)4sax/handler.pycnu„[µü¤ó ›V~gc@sÔdZdZddd„ƒYZddd„ƒYZddd„ƒYZddd „ƒYZd Zd Zd Zd Z dZ dZ eeee e e gZ dZ dZdZdZdZdZe eeeeegZdS(s0 This module contains the core classes of version 2.0 of SAX for Python. This file provides only default classes with absolutely minimum functionality, from which drivers and applications can be subclassed. Many of these classes are empty and are included only as documentation of the interfaces. $Id$ s2.0betat ErrorHandlercBs)eZdZd„Zd„Zd„ZRS(s¤Basic interface for SAX error handlers. If you create an object that implements this interface, then register the object with your XMLReader, the parser will call the methods in your object to report all warnings and errors. There are three levels of errors available: warnings, (possibly) recoverable errors, and unrecoverable errors. All methods take a SAXParseException as the only parameter.cCs |‚dS(sHandle a recoverable error.N((tselft exception((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyterror scCs |‚dS(sHandle a non-recoverable error.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt fatalError$scCs |GHdS(sHandle a warning.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytwarning(s(t__name__t __module__t__doc__RRR(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyRs  tContentHandlercBsŒeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„ZRS(sùInterface for receiving logical document content events. This is the main callback interface in SAX, and the one most important to applications. The order of events in this interface mirrors the order of the information in the document.cCs d|_dS(N(tNonet_locator(R((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt__init__6scCs ||_dS(s#Called by the parser to give the application a locator for locating the origin of document events. SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface. The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine. Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.N(R (Rtlocator((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytsetDocumentLocator9scCsdS(sÜReceive notification of the beginning of a document. The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).N((R((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt startDocumentPtcCsdS(sQReceive notification of the end of a document. The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.N((R((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt endDocumentWRcCsdS(sBegin the scope of a prefix-URI Namespace mapping. The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default). There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary. Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.N((Rtprefixturi((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytstartPrefixMapping`RcCsdS(sðEnd the scope of a prefix-URI mapping. See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytendPrefixMappingwRcCsdS(sSignals the start of an element in non-namespace mode. The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.N((Rtnametattrs((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt startElement~RcCsdS(s¤Signals the end of an element in non-namespace mode. The name parameter contains the name of the element type, just as with the startElement event.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt endElement†RcCsdS(sÁSignals the start of an element in namespace mode. The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element. The uri part of the name tuple is None for elements which have no namespace.N((RRtqnameR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytstartElementNSŒRcCsdS(s¢Signals the end of an element in namespace mode. The name parameter contains the name of the element type, just as with the startElementNS event.N((RRR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt endElementNS˜RcCsdS(sŸReceive notification of character data. The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.N((Rtcontent((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt charactersžRcCsdS(swReceive notification of ignorable whitespace in element content. Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models. SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.N((Rt whitespace((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytignorableWhitespace¨RcCsdS(s–Receive notification of a processing instruction. The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element. A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.N((Rttargettdata((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytprocessingInstruction¶RcCsdS(sReceive notification of a skipped entity. The Parser will invoke this method once for each entity skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt skippedEntityÁR(RRRR RRRRRRRRRRR R#R$(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyR /s          t DTDHandlercBs eZdZd„Zd„ZRS(s‰Handle DTD events. This interface specifies only those DTD events required for basic parsing (unparsed entities and attributes).cCsdS(s$Handle a notation declaration event.N((RRtpublicIdtsystemId((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt notationDeclÖRcCsdS(s,Handle an unparsed entity declaration event.N((RRR&R'tndata((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytunparsedEntityDeclÙR(RRRR(R*(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyR%Ðs tEntityResolvercBseZdZd„ZRS(s7Basic interface for resolving entities. If you create an object implementing this interface, then register the object with your Parser, the parser will call the method in your object to resolve all external entities. Note that DefaultHandler implements this interface with the default behaviour.cCs|S(sœResolve the system identifier of an entity and return either the system identifier to read from as a string, or an InputSource to read from.((RR&R'((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt resolveEntityæs(RRRR,(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyR+ßss&http://xml.org/sax/features/namespacess.http://xml.org/sax/features/namespace-prefixess,http://xml.org/sax/features/string-internings&http://xml.org/sax/features/validations5http://xml.org/sax/features/external-general-entitiess7http://xml.org/sax/features/external-parameter-entitiess-http://xml.org/sax/properties/lexical-handlers1http://xml.org/sax/properties/declaration-handlers&http://xml.org/sax/properties/dom-nodes(http://xml.org/sax/properties/xml-strings-http://www.python.org/sax/properties/encodings3http://www.python.org/sax/properties/interning-dictN(((((RtversionRR R%R+tfeature_namespacestfeature_namespace_prefixestfeature_string_interningtfeature_validationtfeature_external_gestfeature_external_pest all_featurestproperty_lexical_handlertproperty_declaration_handlertproperty_dom_nodetproperty_xml_stringtproperty_encodingtproperty_interning_dicttall_properties(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt s: ¡  PK:©ç\0gd+)4)4sax/handler.pyonu„[µü¤ó ›V~gc@sÔdZdZddd„ƒYZddd„ƒYZddd„ƒYZddd „ƒYZd Zd Zd Zd Z dZ dZ eeee e e gZ dZ dZdZdZdZdZe eeeeegZdS(s0 This module contains the core classes of version 2.0 of SAX for Python. This file provides only default classes with absolutely minimum functionality, from which drivers and applications can be subclassed. Many of these classes are empty and are included only as documentation of the interfaces. $Id$ s2.0betat ErrorHandlercBs)eZdZd„Zd„Zd„ZRS(s¤Basic interface for SAX error handlers. If you create an object that implements this interface, then register the object with your XMLReader, the parser will call the methods in your object to report all warnings and errors. There are three levels of errors available: warnings, (possibly) recoverable errors, and unrecoverable errors. All methods take a SAXParseException as the only parameter.cCs |‚dS(sHandle a recoverable error.N((tselft exception((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyterror scCs |‚dS(sHandle a non-recoverable error.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt fatalError$scCs |GHdS(sHandle a warning.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytwarning(s(t__name__t __module__t__doc__RRR(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyRs  tContentHandlercBsŒeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„ZRS(sùInterface for receiving logical document content events. This is the main callback interface in SAX, and the one most important to applications. The order of events in this interface mirrors the order of the information in the document.cCs d|_dS(N(tNonet_locator(R((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt__init__6scCs ||_dS(s#Called by the parser to give the application a locator for locating the origin of document events. SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface. The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine. Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.N(R (Rtlocator((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytsetDocumentLocator9scCsdS(sÜReceive notification of the beginning of a document. The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).N((R((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt startDocumentPtcCsdS(sQReceive notification of the end of a document. The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.N((R((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt endDocumentWRcCsdS(sBegin the scope of a prefix-URI Namespace mapping. The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default). There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary. Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.N((Rtprefixturi((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytstartPrefixMapping`RcCsdS(sðEnd the scope of a prefix-URI mapping. See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytendPrefixMappingwRcCsdS(sSignals the start of an element in non-namespace mode. The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.N((Rtnametattrs((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt startElement~RcCsdS(s¤Signals the end of an element in non-namespace mode. The name parameter contains the name of the element type, just as with the startElement event.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt endElement†RcCsdS(sÁSignals the start of an element in namespace mode. The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element. The uri part of the name tuple is None for elements which have no namespace.N((RRtqnameR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytstartElementNSŒRcCsdS(s¢Signals the end of an element in namespace mode. The name parameter contains the name of the element type, just as with the startElementNS event.N((RRR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt endElementNS˜RcCsdS(sŸReceive notification of character data. The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.N((Rtcontent((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt charactersžRcCsdS(swReceive notification of ignorable whitespace in element content. Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models. SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.N((Rt whitespace((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytignorableWhitespace¨RcCsdS(s–Receive notification of a processing instruction. The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element. A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.N((Rttargettdata((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytprocessingInstruction¶RcCsdS(sReceive notification of a skipped entity. The Parser will invoke this method once for each entity skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.N((RR((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt skippedEntityÁR(RRRR RRRRRRRRRRR R#R$(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyR /s          t DTDHandlercBs eZdZd„Zd„ZRS(s‰Handle DTD events. This interface specifies only those DTD events required for basic parsing (unparsed entities and attributes).cCsdS(s$Handle a notation declaration event.N((RRtpublicIdtsystemId((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt notationDeclÖRcCsdS(s,Handle an unparsed entity declaration event.N((RRR&R'tndata((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pytunparsedEntityDeclÙR(RRRR(R*(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyR%Ðs tEntityResolvercBseZdZd„ZRS(s7Basic interface for resolving entities. If you create an object implementing this interface, then register the object with your Parser, the parser will call the method in your object to resolve all external entities. Note that DefaultHandler implements this interface with the default behaviour.cCs|S(sœResolve the system identifier of an entity and return either the system identifier to read from as a string, or an InputSource to read from.((RR&R'((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt resolveEntityæs(RRRR,(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyR+ßss&http://xml.org/sax/features/namespacess.http://xml.org/sax/features/namespace-prefixess,http://xml.org/sax/features/string-internings&http://xml.org/sax/features/validations5http://xml.org/sax/features/external-general-entitiess7http://xml.org/sax/features/external-parameter-entitiess-http://xml.org/sax/properties/lexical-handlers1http://xml.org/sax/properties/declaration-handlers&http://xml.org/sax/properties/dom-nodes(http://xml.org/sax/properties/xml-strings-http://www.python.org/sax/properties/encodings3http://www.python.org/sax/properties/interning-dictN(((((RtversionRR R%R+tfeature_namespacestfeature_namespace_prefixestfeature_string_interningtfeature_validationtfeature_external_gestfeature_external_pest all_featurestproperty_lexical_handlertproperty_declaration_handlertproperty_dom_nodetproperty_xml_stringtproperty_encodingtproperty_interning_dicttall_properties(((s4/opt/alt/python27/lib64/python2.7/xml/sax/handler.pyt s: ¡  PK:©ç\÷b’B$-$-sax/saxutils.pynu„[µü¤"""\ A library of useful helper classes to the SAX classes, for the convenience of application and driver writers. """ import os, urlparse, urllib, types import io import sys import handler import xmlreader try: _StringTypes = [types.StringType, types.UnicodeType] except AttributeError: _StringTypes = [types.StringType] def __dict_replace(s, d): """Replace substrings of a string using a dictionary.""" for key, value in d.items(): s = s.replace(key, value) return s def escape(data, entities={}): """Escape &, <, and > in a string of data. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. """ # must do ampersand first data = data.replace("&", "&") data = data.replace(">", ">") data = data.replace("<", "<") if entities: data = __dict_replace(data, entities) return data def unescape(data, entities={}): """Unescape &, <, and > in a string of data. You can unescape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. """ data = data.replace("<", "<") data = data.replace(">", ">") if entities: data = __dict_replace(data, entities) # must do ampersand last return data.replace("&", "&") def quoteattr(data, entities={}): """Escape and quote an attribute value. Escape &, <, and > in a string of data, then quote it for use as an attribute value. The \" character will be escaped as well, if necessary. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. """ entities = entities.copy() entities.update({'\n': ' ', '\r': ' ', '\t':' '}) data = escape(data, entities) if '"' in data: if "'" in data: data = '"%s"' % data.replace('"', """) else: data = "'%s'" % data else: data = '"%s"' % data return data def _gettextwriter(out, encoding): if out is None: import sys out = sys.stdout if isinstance(out, io.RawIOBase): buffer = io.BufferedIOBase(out) # Keep the original file open when the TextIOWrapper is # destroyed buffer.close = lambda: None else: # This is to handle passed objects that aren't in the # IOBase hierarchy, but just have a write method buffer = io.BufferedIOBase() buffer.writable = lambda: True buffer.write = out.write try: # TextIOWrapper uses this methods to determine # if BOM (for UTF-16, etc) should be added buffer.seekable = out.seekable buffer.tell = out.tell except AttributeError: pass # wrap a binary writer with TextIOWrapper return _UnbufferedTextIOWrapper(buffer, encoding=encoding, errors='xmlcharrefreplace', newline='\n') class _UnbufferedTextIOWrapper(io.TextIOWrapper): def write(self, s): super(_UnbufferedTextIOWrapper, self).write(s) self.flush() class XMLGenerator(handler.ContentHandler): def __init__(self, out=None, encoding="iso-8859-1"): handler.ContentHandler.__init__(self) out = _gettextwriter(out, encoding) self._write = out.write self._flush = out.flush self._ns_contexts = [{}] # contains uri -> prefix dicts self._current_context = self._ns_contexts[-1] self._undeclared_ns_maps = [] self._encoding = encoding def _qname(self, name): """Builds a qualified name from a (ns_url, localname) pair""" if name[0]: # Per http://www.w3.org/XML/1998/namespace, The 'xml' prefix is # bound by definition to http://www.w3.org/XML/1998/namespace. It # does not need to be declared and will not usually be found in # self._current_context. if 'http://www.w3.org/XML/1998/namespace' == name[0]: return 'xml:' + name[1] # The name is in a non-empty namespace prefix = self._current_context[name[0]] if prefix: # If it is not the default namespace, prepend the prefix return prefix + ":" + name[1] # Return the unqualified name return name[1] # ContentHandler methods def startDocument(self): self._write(u'\n' % self._encoding) def endDocument(self): self._flush() def startPrefixMapping(self, prefix, uri): self._ns_contexts.append(self._current_context.copy()) self._current_context[uri] = prefix self._undeclared_ns_maps.append((prefix, uri)) def endPrefixMapping(self, prefix): self._current_context = self._ns_contexts[-1] del self._ns_contexts[-1] def startElement(self, name, attrs): self._write(u'<' + name) for (name, value) in attrs.items(): self._write(u' %s=%s' % (name, quoteattr(value))) self._write(u'>') def endElement(self, name): self._write(u'' % name) def startElementNS(self, name, qname, attrs): self._write(u'<' + self._qname(name)) for prefix, uri in self._undeclared_ns_maps: if prefix: self._write(u' xmlns:%s="%s"' % (prefix, uri)) else: self._write(u' xmlns="%s"' % uri) self._undeclared_ns_maps = [] for (name, value) in attrs.items(): self._write(u' %s=%s' % (self._qname(name), quoteattr(value))) self._write(u'>') def endElementNS(self, name, qname): self._write(u'' % self._qname(name)) def characters(self, content): if not isinstance(content, unicode): content = unicode(content, self._encoding) self._write(escape(content)) def ignorableWhitespace(self, content): if not isinstance(content, unicode): content = unicode(content, self._encoding) self._write(content) def processingInstruction(self, target, data): self._write(u'' % (target, data)) class XMLFilterBase(xmlreader.XMLReader): """This class is designed to sit between an XMLReader and the client application's event handlers. By default, it does nothing but pass requests up to the reader and events on to the handlers unmodified, but subclasses can override specific methods to modify the event stream or the configuration requests as they pass through.""" def __init__(self, parent = None): xmlreader.XMLReader.__init__(self) self._parent = parent # ErrorHandler methods def error(self, exception): self._err_handler.error(exception) def fatalError(self, exception): self._err_handler.fatalError(exception) def warning(self, exception): self._err_handler.warning(exception) # ContentHandler methods def setDocumentLocator(self, locator): self._cont_handler.setDocumentLocator(locator) def startDocument(self): self._cont_handler.startDocument() def endDocument(self): self._cont_handler.endDocument() def startPrefixMapping(self, prefix, uri): self._cont_handler.startPrefixMapping(prefix, uri) def endPrefixMapping(self, prefix): self._cont_handler.endPrefixMapping(prefix) def startElement(self, name, attrs): self._cont_handler.startElement(name, attrs) def endElement(self, name): self._cont_handler.endElement(name) def startElementNS(self, name, qname, attrs): self._cont_handler.startElementNS(name, qname, attrs) def endElementNS(self, name, qname): self._cont_handler.endElementNS(name, qname) def characters(self, content): self._cont_handler.characters(content) def ignorableWhitespace(self, chars): self._cont_handler.ignorableWhitespace(chars) def processingInstruction(self, target, data): self._cont_handler.processingInstruction(target, data) def skippedEntity(self, name): self._cont_handler.skippedEntity(name) # DTDHandler methods def notationDecl(self, name, publicId, systemId): self._dtd_handler.notationDecl(name, publicId, systemId) def unparsedEntityDecl(self, name, publicId, systemId, ndata): self._dtd_handler.unparsedEntityDecl(name, publicId, systemId, ndata) # EntityResolver methods def resolveEntity(self, publicId, systemId): return self._ent_handler.resolveEntity(publicId, systemId) # XMLReader methods def parse(self, source): self._parent.setContentHandler(self) self._parent.setErrorHandler(self) self._parent.setEntityResolver(self) self._parent.setDTDHandler(self) self._parent.parse(source) def setLocale(self, locale): self._parent.setLocale(locale) def getFeature(self, name): return self._parent.getFeature(name) def setFeature(self, name, state): self._parent.setFeature(name, state) def getProperty(self, name): return self._parent.getProperty(name) def setProperty(self, name, value): self._parent.setProperty(name, value) # XMLFilter methods def getParent(self): return self._parent def setParent(self, parent): self._parent = parent # --- Utility functions def prepare_input_source(source, base = ""): """This function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.""" if type(source) in _StringTypes: source = xmlreader.InputSource(source) elif hasattr(source, "read"): f = source source = xmlreader.InputSource() source.setByteStream(f) if hasattr(f, "name"): source.setSystemId(f.name) if source.getByteStream() is None: try: sysid = source.getSystemId() basehead = os.path.dirname(os.path.normpath(base)) encoding = sys.getfilesystemencoding() if isinstance(sysid, unicode): if not isinstance(basehead, unicode): try: basehead = basehead.decode(encoding) except UnicodeDecodeError: sysid = sysid.encode(encoding) else: if isinstance(basehead, unicode): try: sysid = sysid.decode(encoding) except UnicodeDecodeError: basehead = basehead.encode(encoding) sysidfilename = os.path.join(basehead, sysid) isfile = os.path.isfile(sysidfilename) except UnicodeError: isfile = False if isfile: source.setSystemId(sysidfilename) f = open(sysidfilename, "rb") else: source.setSystemId(urlparse.urljoin(base, source.getSystemId())) f = urllib.urlopen(source.getSystemId()) source.setByteStream(f) return source PK:©ç\¨2…,�<�<sax/saxutils.pycnu„[µü¤ó ›V~gc@s-dZddlZddlZddlZddlZddlZddlZddlZddlZyej ej gZ Wne k r›ej gZ nXd„Z id„Zid„Zid„Zd„Zdejfd „ƒYZd ejfd „ƒYZd ejfd „ƒYZdd„ZdS(snA library of useful helper classes to the SAX classes, for the convenience of application and driver writers. iÿÿÿÿNcCs3x,|jƒD]\}}|j||ƒ}q W|S(s2Replace substrings of a string using a dictionary.(titemstreplace(tstdtkeytvalue((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt__dict_replacescCsR|jddƒ}|jddƒ}|jddƒ}|rNt||ƒ}n|S(süEscape &, <, and > in a string of data. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. t&s&t>s>t in a string of data, then quote it for use as an attribute value. The " character will be escaped as well, if necessary. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. s s s s s s t"t's"%s"s"s'%s'(tcopytupdateR R(R R ((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt quoteattr5s "    cCsÄ|dkr$ddl}|j}nt|tjƒrTtj|ƒ}d„|_nTtjƒ}d„|_|j |_ y|j |_ |j |_ Wnt k r§nXt |d|ddddƒS( NiÿÿÿÿcSsdS(N(tNone(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytVtcSstS(N(tTrue(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR[Rtencodingterrorstxmlcharrefreplacetnewlines (Rtsyststdoutt isinstancetiot RawIOBasetBufferedIOBasetclosetwritabletwritetseekablettelltAttributeErrort_UnbufferedTextIOWrapper(toutRRtbuffer((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt_gettextwriterMs"        R'cBseZd„ZRS(cCs$tt|ƒj|ƒ|jƒdS(N(tsuperR'R#tflush(tselfR((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR#ks(t__name__t __module__R#(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR'jst XMLGeneratorcBsƒeZddd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „ZRS(s iso-8859-1cCsitjj|ƒt||ƒ}|j|_|j|_ig|_|jd|_ g|_ ||_ dS(Niÿÿÿÿ( thandlertContentHandlert__init__R*R#t_writeR,t_flusht _ns_contextst_current_contextt_undeclared_ns_mapst _encoding(R-R(R((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR3rs    cCsX|drPd|dkr&d|dS|j|d}|rP|d|dSn|dS(s7Builds a qualified name from a (ns_url, localname) pairis$http://www.w3.org/XML/1998/namespacesxml:it:(R7(R-tnametprefix((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt_qname|s  cCs|jd|jƒdS(Nu$ (R4R9(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt startDocument�s cCs|jƒdS(N(R5(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt endDocument“scCs@|jj|jjƒƒ||j|<|jj||fƒdS(N(R6tappendR7RR8(R-R<turi((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytstartPrefixMapping–s cCs|jd|_|jd=dS(Niÿÿÿÿ(R6R7(R-R<((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytendPrefixMapping›scCs\|jd|ƒx7|jƒD])\}}|jd|t|ƒfƒqW|jdƒdS(Nu(R4RR(R-R;tattrsR((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt startElementŸs!cCs|jd|ƒdS(Nu(R4(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt endElement¥scCsÂ|jd|j|ƒƒxH|jD]=\}}|rP|jd||fƒq$|jd|ƒq$Wg|_x@|jƒD]2\}}|jd|j|ƒt|ƒfƒq{W|jdƒdS(Nu(R4R=R8RR(R-R;tqnameRDR<RAR((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytstartElementNS¨s *cCs|jd|j|ƒƒdS(Nu(R4R=(R-R;RG((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt endElementNS¶scCs;t|tƒs$t||jƒ}n|jt|ƒƒdS(N(RtunicodeR9R4R (R-tcontent((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt characters¹scCs5t|tƒs$t||jƒ}n|j|ƒdS(N(RRJR9R4(R-RK((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytignorableWhitespace¾scCs|jd||fƒdS(Nu (R4(R-ttargetR ((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytprocessingInstructionÃsN(R.R/RR3R=R>R?RBRCRERFRHRIRLRMRO(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR0ps           t XMLFilterBasecBs eZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(sYThis class is designed to sit between an XMLReader and the client application's event handlers. By default, it does nothing but pass requests up to the reader and events on to the handlers unmodified, but subclasses can override specific methods to modify the event stream or the configuration requests as they pass through.cCstjj|ƒ||_dS(N(t xmlreadert XMLReaderR3t_parent(R-tparent((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR3ÏscCs|jj|ƒdS(N(t _err_handlerterror(R-t exception((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRVÕscCs|jj|ƒdS(N(RUt fatalError(R-RW((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRXØscCs|jj|ƒdS(N(RUtwarning(R-RW((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRYÛscCs|jj|ƒdS(N(t _cont_handlertsetDocumentLocator(R-tlocator((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR[àscCs|jjƒdS(N(RZR>(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR>ãscCs|jjƒdS(N(RZR?(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR?æscCs|jj||ƒdS(N(RZRB(R-R<RA((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRBéscCs|jj|ƒdS(N(RZRC(R-R<((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRCìscCs|jj||ƒdS(N(RZRE(R-R;RD((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyREïscCs|jj|ƒdS(N(RZRF(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRFòscCs|jj|||ƒdS(N(RZRH(R-R;RGRD((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRHõscCs|jj||ƒdS(N(RZRI(R-R;RG((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRIøscCs|jj|ƒdS(N(RZRL(R-RK((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRLûscCs|jj|ƒdS(N(RZRM(R-tchars((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRMþscCs|jj||ƒdS(N(RZRO(R-RNR ((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyROscCs|jj|ƒdS(N(RZt skippedEntity(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR^scCs|jj|||ƒdS(N(t _dtd_handlert notationDecl(R-R;tpublicIdtsystemId((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR` scCs|jj||||ƒdS(N(R_tunparsedEntityDecl(R-R;RaRbtndata((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRc scCs|jj||ƒS(N(t _ent_handlert resolveEntity(R-RaRb((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRfscCsT|jj|ƒ|jj|ƒ|jj|ƒ|jj|ƒ|jj|ƒdS(N(RStsetContentHandlertsetErrorHandlertsetEntityResolvert setDTDHandlertparse(R-tsource((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRks cCs|jj|ƒdS(N(RSt setLocale(R-tlocale((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRmscCs|jj|ƒS(N(RSt getFeature(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRo scCs|jj||ƒdS(N(RSt setFeature(R-R;tstate((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRp#scCs|jj|ƒS(N(RSt getProperty(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRr&scCs|jj||ƒdS(N(RSt setProperty(R-R;R((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRs)scCs|jS(N(RS(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt getParent.scCs ||_dS(N(RS(R-RT((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt setParent1sN( R.R/t__doc__RR3RVRXRYR[R>R?RBRCRERFRHRIRLRMROR^R`RcRfRkRmRoRpRrRsRtRu(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRPÇs:                           RcCst|ƒtkr$tj|ƒ}nSt|dƒrw|}tjƒ}|j|ƒt|dƒrw|j|jƒqwn|jƒdkry|j ƒ}t j j t j j|ƒƒ}tjƒ}t|tƒrt|tƒsdy|j|ƒ}Wqtk r|j|ƒ}qXqdnHt|tƒrdy|j|ƒ}Wqdtk r`|j|ƒ}qdXnt j j||ƒ}t j j|ƒ}Wntk r¥t}nX|rË|j|ƒt|dƒ}n4|jtj||j ƒƒƒtj|j ƒƒ}|j|ƒn|S(s‚This function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.treadR;trbN(ttypet _StringTypesRQt InputSourcethasattrt setByteStreamt setSystemIdR;t getByteStreamRt getSystemIdtostpathtdirnametnormpathRtgetfilesystemencodingRRJtdecodetUnicodeDecodeErrortencodetjointisfilet UnicodeErrortFalsetopenturlparseturljointurllibturlopen(RltbasetftsysidtbaseheadRt sysidfilenameRŠ((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytprepare_input_source6sF         (RvR�RŽR�ttypesRRR1RQt StringTypet UnicodeTypeRzR&RR R RR*t TextIOWrapperR'R2R0RRRPR—(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyts$0          WoPK:©ç\¨2…,�<�<sax/saxutils.pyonu„[µü¤ó ›V~gc@s-dZddlZddlZddlZddlZddlZddlZddlZddlZyej ej gZ Wne k r›ej gZ nXd„Z id„Zid„Zid„Zd„Zdejfd „ƒYZd ejfd „ƒYZd ejfd „ƒYZdd„ZdS(snA library of useful helper classes to the SAX classes, for the convenience of application and driver writers. iÿÿÿÿNcCs3x,|jƒD]\}}|j||ƒ}q W|S(s2Replace substrings of a string using a dictionary.(titemstreplace(tstdtkeytvalue((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt__dict_replacescCsR|jddƒ}|jddƒ}|jddƒ}|rNt||ƒ}n|S(süEscape &, <, and > in a string of data. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. t&s&t>s>t in a string of data, then quote it for use as an attribute value. The " character will be escaped as well, if necessary. You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. s s s s s s t"t's"%s"s"s'%s'(tcopytupdateR R(R R ((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt quoteattr5s "    cCsÄ|dkr$ddl}|j}nt|tjƒrTtj|ƒ}d„|_nTtjƒ}d„|_|j |_ y|j |_ |j |_ Wnt k r§nXt |d|ddddƒS( NiÿÿÿÿcSsdS(N(tNone(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytVtcSstS(N(tTrue(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR[Rtencodingterrorstxmlcharrefreplacetnewlines (Rtsyststdoutt isinstancetiot RawIOBasetBufferedIOBasetclosetwritabletwritetseekablettelltAttributeErrort_UnbufferedTextIOWrapper(toutRRtbuffer((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt_gettextwriterMs"        R'cBseZd„ZRS(cCs$tt|ƒj|ƒ|jƒdS(N(tsuperR'R#tflush(tselfR((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR#ks(t__name__t __module__R#(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR'jst XMLGeneratorcBsƒeZddd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „ZRS(s iso-8859-1cCsitjj|ƒt||ƒ}|j|_|j|_ig|_|jd|_ g|_ ||_ dS(Niÿÿÿÿ( thandlertContentHandlert__init__R*R#t_writeR,t_flusht _ns_contextst_current_contextt_undeclared_ns_mapst _encoding(R-R(R((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR3rs    cCsX|drPd|dkr&d|dS|j|d}|rP|d|dSn|dS(s7Builds a qualified name from a (ns_url, localname) pairis$http://www.w3.org/XML/1998/namespacesxml:it:(R7(R-tnametprefix((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt_qname|s  cCs|jd|jƒdS(Nu$ (R4R9(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt startDocument�s cCs|jƒdS(N(R5(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt endDocument“scCs@|jj|jjƒƒ||j|<|jj||fƒdS(N(R6tappendR7RR8(R-R<turi((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytstartPrefixMapping–s cCs|jd|_|jd=dS(Niÿÿÿÿ(R6R7(R-R<((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytendPrefixMapping›scCs\|jd|ƒx7|jƒD])\}}|jd|t|ƒfƒqW|jdƒdS(Nu(R4RR(R-R;tattrsR((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt startElementŸs!cCs|jd|ƒdS(Nu(R4(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt endElement¥scCsÂ|jd|j|ƒƒxH|jD]=\}}|rP|jd||fƒq$|jd|ƒq$Wg|_x@|jƒD]2\}}|jd|j|ƒt|ƒfƒq{W|jdƒdS(Nu(R4R=R8RR(R-R;tqnameRDR<RAR((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytstartElementNS¨s *cCs|jd|j|ƒƒdS(Nu(R4R=(R-R;RG((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt endElementNS¶scCs;t|tƒs$t||jƒ}n|jt|ƒƒdS(N(RtunicodeR9R4R (R-tcontent((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt characters¹scCs5t|tƒs$t||jƒ}n|j|ƒdS(N(RRJR9R4(R-RK((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytignorableWhitespace¾scCs|jd||fƒdS(Nu (R4(R-ttargetR ((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytprocessingInstructionÃsN(R.R/RR3R=R>R?RBRCRERFRHRIRLRMRO(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR0ps           t XMLFilterBasecBs eZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(sYThis class is designed to sit between an XMLReader and the client application's event handlers. By default, it does nothing but pass requests up to the reader and events on to the handlers unmodified, but subclasses can override specific methods to modify the event stream or the configuration requests as they pass through.cCstjj|ƒ||_dS(N(t xmlreadert XMLReaderR3t_parent(R-tparent((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR3ÏscCs|jj|ƒdS(N(t _err_handlerterror(R-t exception((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRVÕscCs|jj|ƒdS(N(RUt fatalError(R-RW((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRXØscCs|jj|ƒdS(N(RUtwarning(R-RW((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRYÛscCs|jj|ƒdS(N(t _cont_handlertsetDocumentLocator(R-tlocator((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR[àscCs|jjƒdS(N(RZR>(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR>ãscCs|jjƒdS(N(RZR?(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR?æscCs|jj||ƒdS(N(RZRB(R-R<RA((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRBéscCs|jj|ƒdS(N(RZRC(R-R<((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRCìscCs|jj||ƒdS(N(RZRE(R-R;RD((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyREïscCs|jj|ƒdS(N(RZRF(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRFòscCs|jj|||ƒdS(N(RZRH(R-R;RGRD((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRHõscCs|jj||ƒdS(N(RZRI(R-R;RG((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRIøscCs|jj|ƒdS(N(RZRL(R-RK((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRLûscCs|jj|ƒdS(N(RZRM(R-tchars((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRMþscCs|jj||ƒdS(N(RZRO(R-RNR ((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyROscCs|jj|ƒdS(N(RZt skippedEntity(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR^scCs|jj|||ƒdS(N(t _dtd_handlert notationDecl(R-R;tpublicIdtsystemId((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyR` scCs|jj||||ƒdS(N(R_tunparsedEntityDecl(R-R;RaRbtndata((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRc scCs|jj||ƒS(N(t _ent_handlert resolveEntity(R-RaRb((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRfscCsT|jj|ƒ|jj|ƒ|jj|ƒ|jj|ƒ|jj|ƒdS(N(RStsetContentHandlertsetErrorHandlertsetEntityResolvert setDTDHandlertparse(R-tsource((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRks cCs|jj|ƒdS(N(RSt setLocale(R-tlocale((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRmscCs|jj|ƒS(N(RSt getFeature(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRo scCs|jj||ƒdS(N(RSt setFeature(R-R;tstate((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRp#scCs|jj|ƒS(N(RSt getProperty(R-R;((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRr&scCs|jj||ƒdS(N(RSt setProperty(R-R;R((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRs)scCs|jS(N(RS(R-((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt getParent.scCs ||_dS(N(RS(R-RT((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyt setParent1sN( R.R/t__doc__RR3RVRXRYR[R>R?RBRCRERFRHRIRLRMROR^R`RcRfRkRmRoRpRrRsRtRu(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyRPÇs:                           RcCst|ƒtkr$tj|ƒ}nSt|dƒrw|}tjƒ}|j|ƒt|dƒrw|j|jƒqwn|jƒdkry|j ƒ}t j j t j j|ƒƒ}tjƒ}t|tƒrt|tƒsdy|j|ƒ}Wqtk r|j|ƒ}qXqdnHt|tƒrdy|j|ƒ}Wqdtk r`|j|ƒ}qdXnt j j||ƒ}t j j|ƒ}Wntk r¥t}nX|rË|j|ƒt|dƒ}n4|jtj||j ƒƒƒtj|j ƒƒ}|j|ƒn|S(s‚This function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.treadR;trbN(ttypet _StringTypesRQt InputSourcethasattrt setByteStreamt setSystemIdR;t getByteStreamRt getSystemIdtostpathtdirnametnormpathRtgetfilesystemencodingRRJtdecodetUnicodeDecodeErrortencodetjointisfilet UnicodeErrortFalsetopenturlparseturljointurllibturlopen(RltbasetftsysidtbaseheadRt sysidfilenameRŠ((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pytprepare_input_source6sF         (RvR�RŽR�ttypesRRR1RQt StringTypet UnicodeTypeRzR&RR R RR*t TextIOWrapperR'R2R0RRRPR—(((s5/opt/alt/python27/lib64/python2.7/xml/sax/saxutils.pyts$0          WoPK:©ç\ <bX1X1sax/xmlreader.pynu„[µü¤"""An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. """ import handler from _exceptions import SAXNotSupportedException, SAXNotRecognizedException # ===== XMLREADER ===== class XMLReader: """Interface for reading an XML document using callbacks. XMLReader is the interface that an XML parser's SAX2 driver must implement. This interface allows an application to set and query features and properties in the parser, to register event handlers for document processing, and to initiate a document parse. All SAX interfaces are assumed to be synchronous: the parse methods must not return until parsing is complete, and readers must wait for an event-handler callback to return before reporting the next event.""" def __init__(self): self._cont_handler = handler.ContentHandler() self._dtd_handler = handler.DTDHandler() self._ent_handler = handler.EntityResolver() self._err_handler = handler.ErrorHandler() def parse(self, source): "Parse an XML document from a system identifier or an InputSource." raise NotImplementedError("This method must be implemented!") def getContentHandler(self): "Returns the current ContentHandler." return self._cont_handler def setContentHandler(self, handler): "Registers a new object to receive document content events." self._cont_handler = handler def getDTDHandler(self): "Returns the current DTD handler." return self._dtd_handler def setDTDHandler(self, handler): "Register an object to receive basic DTD-related events." self._dtd_handler = handler def getEntityResolver(self): "Returns the current EntityResolver." return self._ent_handler def setEntityResolver(self, resolver): "Register an object to resolve external entities." self._ent_handler = resolver def getErrorHandler(self): "Returns the current ErrorHandler." return self._err_handler def setErrorHandler(self, handler): "Register an object to receive error-message events." self._err_handler = handler def setLocale(self, locale): """Allow an application to set the locale for errors and warnings. SAX parsers are not required to provide localization for errors and warnings; if they cannot support the requested locale, however, they must raise a SAX exception. Applications may request a locale change in the middle of a parse.""" raise SAXNotSupportedException("Locale support not implemented") def getFeature(self, name): "Looks up and returns the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) def setFeature(self, name, state): "Sets the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) def getProperty(self, name): "Looks up and returns the value of a SAX2 property." raise SAXNotRecognizedException("Property '%s' not recognized" % name) def setProperty(self, name, value): "Sets the value of a SAX2 property." raise SAXNotRecognizedException("Property '%s' not recognized" % name) class IncrementalParser(XMLReader): """This interface adds three extra methods to the XMLReader interface that allow XML parsers to support incremental parsing. Support for this interface is optional, since not all underlying XML parsers support this functionality. When the parser is instantiated it is ready to begin accepting data from the feed method immediately. After parsing has been finished with a call to close the reset method must be called to make the parser ready to accept new data, either from feed or using the parse method. Note that these methods must _not_ be called during parsing, that is, after parse has been called and before it returns. By default, the class also implements the parse method of the XMLReader interface using the feed, close and reset methods of the IncrementalParser interface as a convenience to SAX 2.0 driver writers.""" def __init__(self, bufsize=2**16): self._bufsize = bufsize XMLReader.__init__(self) def parse(self, source): import saxutils source = saxutils.prepare_input_source(source) self.prepareParser(source) file = source.getByteStream() buffer = file.read(self._bufsize) while buffer != "": self.feed(buffer) buffer = file.read(self._bufsize) self.close() def feed(self, data): """This method gives the raw XML data in the data parameter to the parser and makes it parse the data, emitting the corresponding events. It is allowed for XML constructs to be split across several calls to feed. feed may raise SAXException.""" raise NotImplementedError("This method must be implemented!") def prepareParser(self, source): """This method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.""" raise NotImplementedError("prepareParser must be overridden!") def close(self): """This method is called when the entire XML document has been passed to the parser through the feed method, to notify the parser that there are no more data. This allows the parser to do the final checks on the document and empty the internal data buffer. The parser will not be ready to parse another document until the reset method has been called. close may raise SAXException.""" raise NotImplementedError("This method must be implemented!") def reset(self): """This method is called after close has been called to reset the parser so that it is ready to parse new documents. The results of calling parse or feed after close without calling reset are undefined.""" raise NotImplementedError("This method must be implemented!") # ===== LOCATOR ===== class Locator: """Interface for associating a SAX event with a document location. A locator object will return valid results only during calls to DocumentHandler methods; at any other time, the results are unpredictable.""" def getColumnNumber(self): "Return the column number where the current event ends." return -1 def getLineNumber(self): "Return the line number where the current event ends." return -1 def getPublicId(self): "Return the public identifier for the current event." return None def getSystemId(self): "Return the system identifier for the current event." return None # ===== INPUTSOURCE ===== class InputSource: """Encapsulation of the information needed by the XMLReader to read entities. This class may include information about the public identifier, system identifier, byte stream (possibly with character encoding information) and/or the character stream of an entity. Applications will create objects of this class for use in the XMLReader.parse method and for returning from EntityResolver.resolveEntity. An InputSource belongs to the application, the XMLReader is not allowed to modify InputSource objects passed to it from the application, although it may make copies and modify those.""" def __init__(self, system_id = None): self.__system_id = system_id self.__public_id = None self.__encoding = None self.__bytefile = None self.__charfile = None def setPublicId(self, public_id): "Sets the public identifier of this InputSource." self.__public_id = public_id def getPublicId(self): "Returns the public identifier of this InputSource." return self.__public_id def setSystemId(self, system_id): "Sets the system identifier of this InputSource." self.__system_id = system_id def getSystemId(self): "Returns the system identifier of this InputSource." return self.__system_id def setEncoding(self, encoding): """Sets the character encoding of this InputSource. The encoding must be a string acceptable for an XML encoding declaration (see section 4.3.3 of the XML recommendation). The encoding attribute of the InputSource is ignored if the InputSource also contains a character stream.""" self.__encoding = encoding def getEncoding(self): "Get the character encoding of this InputSource." return self.__encoding def setByteStream(self, bytefile): """Set the byte stream (a Python file-like object which does not perform byte-to-character conversion) for this input source. The SAX parser will ignore this if there is also a character stream specified, but it will use a byte stream in preference to opening a URI connection itself. If the application knows the character encoding of the byte stream, it should set it with the setEncoding method.""" self.__bytefile = bytefile def getByteStream(self): """Get the byte stream for this input source. The getEncoding method will return the character encoding for this byte stream, or None if unknown.""" return self.__bytefile def setCharacterStream(self, charfile): """Set the character stream for this input source. (The stream must be a Python 2.0 Unicode-wrapped file-like that performs conversion to Unicode strings.) If there is a character stream specified, the SAX parser will ignore any byte stream and will not attempt to open a URI connection to the system identifier.""" self.__charfile = charfile def getCharacterStream(self): "Get the character stream for this input source." return self.__charfile # ===== ATTRIBUTESIMPL ===== class AttributesImpl: def __init__(self, attrs): """Non-NS-aware implementation. attrs should be of the form {name : value}.""" self._attrs = attrs def getLength(self): return len(self._attrs) def getType(self, name): return "CDATA" def getValue(self, name): return self._attrs[name] def getValueByQName(self, name): return self._attrs[name] def getNameByQName(self, name): if not name in self._attrs: raise KeyError, name return name def getQNameByName(self, name): if not name in self._attrs: raise KeyError, name return name def getNames(self): return self._attrs.keys() def getQNames(self): return self._attrs.keys() def __len__(self): return len(self._attrs) def __getitem__(self, name): return self._attrs[name] def keys(self): return self._attrs.keys() def has_key(self, name): return name in self._attrs def __contains__(self, name): return name in self._attrs def get(self, name, alternative=None): return self._attrs.get(name, alternative) def copy(self): return self.__class__(self._attrs) def items(self): return self._attrs.items() def values(self): return self._attrs.values() # ===== ATTRIBUTESNSIMPL ===== class AttributesNSImpl(AttributesImpl): def __init__(self, attrs, qnames): """NS-aware implementation. attrs should be of the form {(ns_uri, lname): value, ...}. qnames of the form {(ns_uri, lname): qname, ...}.""" self._attrs = attrs self._qnames = qnames def getValueByQName(self, name): for (nsname, qname) in self._qnames.items(): if qname == name: return self._attrs[nsname] raise KeyError, name def getNameByQName(self, name): for (nsname, qname) in self._qnames.items(): if qname == name: return nsname raise KeyError, name def getQNameByName(self, name): return self._qnames[name] def getQNames(self): return self._qnames.values() def copy(self): return self.__class__(self._attrs, self._qnames) def _test(): XMLReader() IncrementalParser() Locator() if __name__ == "__main__": _test() PK:©ç\€ø4"ŠNŠNsax/xmlreader.pycnu„[µü¤ó ›V~gc@sÃdZddlZddlmZmZddd„ƒYZdefd„ƒYZddd „ƒYZd dd „ƒYZd dd „ƒYZ de fd„ƒYZ d„Z e dkr¿e ƒndS(s]An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. iÿÿÿÿN(tSAXNotSupportedExceptiontSAXNotRecognizedExceptiont XMLReadercBs•eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„ZRS(s%Interface for reading an XML document using callbacks. XMLReader is the interface that an XML parser's SAX2 driver must implement. This interface allows an application to set and query features and properties in the parser, to register event handlers for document processing, and to initiate a document parse. All SAX interfaces are assumed to be synchronous: the parse methods must not return until parsing is complete, and readers must wait for an event-handler callback to return before reporting the next event.cCs@tjƒ|_tjƒ|_tjƒ|_tjƒ|_dS(N( thandlertContentHandlert _cont_handlert DTDHandlert _dtd_handlertEntityResolvert _ent_handlert ErrorHandlert _err_handler(tself((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt__init__scCstdƒ‚dS(sAParse an XML document from a system identifier or an InputSource.s This method must be implemented!N(tNotImplementedError(R tsource((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytparsescCs|jS(s#Returns the current ContentHandler.(R(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetContentHandler"scCs ||_dS(s:Registers a new object to receive document content events.N(R(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytsetContentHandler&scCs|jS(s Returns the current DTD handler.(R(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getDTDHandler*scCs ||_dS(s7Register an object to receive basic DTD-related events.N(R(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setDTDHandler.scCs|jS(s#Returns the current EntityResolver.(R (R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetEntityResolver2scCs ||_dS(s0Register an object to resolve external entities.N(R (R tresolver((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytsetEntityResolver6scCs|jS(s!Returns the current ErrorHandler.(R (R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetErrorHandler:scCs ||_dS(s3Register an object to receive error-message events.N(R (R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytsetErrorHandler>scCstdƒ‚dS(sHAllow an application to set the locale for errors and warnings. SAX parsers are not required to provide localization for errors and warnings; if they cannot support the requested locale, however, they must raise a SAX exception. Applications may request a locale change in the middle of a parse.sLocale support not implementedN(R(R tlocale((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setLocaleBscCstd|ƒ‚dS(s1Looks up and returns the state of a SAX2 feature.sFeature '%s' not recognizedN(R(R tname((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getFeatureKscCstd|ƒ‚dS(s!Sets the state of a SAX2 feature.sFeature '%s' not recognizedN(R(R Rtstate((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setFeatureOscCstd|ƒ‚dS(s2Looks up and returns the value of a SAX2 property.sProperty '%s' not recognizedN(R(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getPropertySscCstd|ƒ‚dS(s"Sets the value of a SAX2 property.sProperty '%s' not recognizedN(R(R Rtvalue((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setPropertyWs(t__name__t __module__t__doc__R RRRRRRRRRRRRR R"(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR s               tIncrementalParsercBsGeZdZd d„Zd„Zd„Zd„Zd„Zd„ZRS( ssThis interface adds three extra methods to the XMLReader interface that allow XML parsers to support incremental parsing. Support for this interface is optional, since not all underlying XML parsers support this functionality. When the parser is instantiated it is ready to begin accepting data from the feed method immediately. After parsing has been finished with a call to close the reset method must be called to make the parser ready to accept new data, either from feed or using the parse method. Note that these methods must _not_ be called during parsing, that is, after parse has been called and before it returns. By default, the class also implements the parse method of the XMLReader interface using the feed, close and reset methods of the IncrementalParser interface as a convenience to SAX 2.0 driver writers.iicCs||_tj|ƒdS(N(t_bufsizeRR (R tbufsize((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR os cCs†ddl}|j|ƒ}|j|ƒ|jƒ}|j|jƒ}x/|dkrw|j|ƒ|j|jƒ}qIW|jƒdS(Niÿÿÿÿt(tsaxutilstprepare_input_sourcet prepareParsert getByteStreamtreadR'tfeedtclose(R RR*tfiletbuffer((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRss    cCstdƒ‚dS(sThis method gives the raw XML data in the data parameter to the parser and makes it parse the data, emitting the corresponding events. It is allowed for XML constructs to be split across several calls to feed. feed may raise SAXException.s This method must be implemented!N(R(R tdata((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR/scCstdƒ‚dS(stThis method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.s!prepareParser must be overridden!N(R(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR,ˆscCstdƒ‚dS(s´This method is called when the entire XML document has been passed to the parser through the feed method, to notify the parser that there are no more data. This allows the parser to do the final checks on the document and empty the internal data buffer. The parser will not be ready to parse another document until the reset method has been called. close may raise SAXException.s This method must be implemented!N(R(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR0�s cCstdƒ‚dS(sßThis method is called after close has been called to reset the parser so that it is ready to parse new documents. The results of calling parse or feed after close without calling reset are undefined.s This method must be implemented!N(R(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytresetšsi( R#R$R%R RR/R,R0R4(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR&[s   tLocatorcBs2eZdZd„Zd„Zd„Zd„ZRS(sÖInterface for associating a SAX event with a document location. A locator object will return valid results only during calls to DocumentHandler methods; at any other time, the results are unpredictable.cCsdS(s6Return the column number where the current event ends.iÿÿÿÿ((R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetColumnNumber©scCsdS(s4Return the line number where the current event ends.iÿÿÿÿ((R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getLineNumber­scCsdS(s3Return the public identifier for the current event.N(tNone(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getPublicId±scCsdS(s3Return the system identifier for the current event.N(R8(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getSystemIdµs(R#R$R%R6R7R9R:(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR5£s    t InputSourcecBsteZdZd d„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „ZRS( snEncapsulation of the information needed by the XMLReader to read entities. This class may include information about the public identifier, system identifier, byte stream (possibly with character encoding information) and/or the character stream of an entity. Applications will create objects of this class for use in the XMLReader.parse method and for returning from EntityResolver.resolveEntity. An InputSource belongs to the application, the XMLReader is not allowed to modify InputSource objects passed to it from the application, although it may make copies and modify those.cCs1||_d|_d|_d|_d|_dS(N(t_InputSource__system_idR8t_InputSource__public_idt_InputSource__encodingt_InputSource__bytefilet_InputSource__charfile(R t system_id((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR Ës     cCs ||_dS(s/Sets the public identifier of this InputSource.N(R=(R t public_id((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setPublicIdÒscCs|jS(s2Returns the public identifier of this InputSource.(R=(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR9ÖscCs ||_dS(s/Sets the system identifier of this InputSource.N(R<(R RA((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setSystemIdÚscCs|jS(s2Returns the system identifier of this InputSource.(R<(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR:ÞscCs ||_dS(s4Sets the character encoding of this InputSource. The encoding must be a string acceptable for an XML encoding declaration (see section 4.3.3 of the XML recommendation). The encoding attribute of the InputSource is ignored if the InputSource also contains a character stream.N(R>(R tencoding((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setEncodingâscCs|jS(s/Get the character encoding of this InputSource.(R>(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getEncodingìscCs ||_dS(sÅSet the byte stream (a Python file-like object which does not perform byte-to-character conversion) for this input source. The SAX parser will ignore this if there is also a character stream specified, but it will use a byte stream in preference to opening a URI connection itself. If the application knows the character encoding of the byte stream, it should set it with the setEncoding method.N(R?(R tbytefile((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setByteStreamðs cCs|jS(sŸGet the byte stream for this input source. The getEncoding method will return the character encoding for this byte stream, or None if unknown.(R?(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR-ýscCs ||_dS(s^Set the character stream for this input source. (The stream must be a Python 2.0 Unicode-wrapped file-like that performs conversion to Unicode strings.) If there is a character stream specified, the SAX parser will ignore any byte stream and will not attempt to open a URI connection to the system identifier.N(R@(R tcharfile((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytsetCharacterStreamscCs|jS(s/Get the character stream for this input source.(R@(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetCharacterStreamsN(R#R$R%R8R RCR9RDR:RFRGRIR-RKRL(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR;»s        tAttributesImplcBs­eZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zdd„Zd„Zd„Zd„ZRS(cCs ||_dS(sQNon-NS-aware implementation. attrs should be of the form {name : value}.N(t_attrs(R tattrs((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR scCs t|jƒS(N(tlenRN(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getLengthscCsdS(NtCDATA((R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetTypescCs |j|S(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetValue"scCs |j|S(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetValueByQName%scCs||jkrt|‚n|S(N(RNtKeyError(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetNameByQName(s cCs||jkrt|‚n|S(N(RNRV(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetQNameByName-s cCs |jjƒS(N(RNtkeys(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetNames2scCs |jjƒS(N(RNRY(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getQNames5scCs t|jƒS(N(RPRN(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt__len__8scCs |j|S(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt __getitem__;scCs |jjƒS(N(RNRY(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRY>scCs ||jkS(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pythas_keyAscCs ||jkS(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt __contains__DscCs|jj||ƒS(N(RNtget(R Rt alternative((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR`GscCs|j|jƒS(N(t __class__RN(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytcopyJscCs |jjƒS(N(RNtitems(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRdMscCs |jjƒS(N(RNtvalues(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRePsN(R#R$R RQRSRTRURWRXRZR[R\R]RYR^R_R8R`RcRdRe(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRMs$                 tAttributesNSImplcBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs||_||_dS(s–NS-aware implementation. attrs should be of the form {(ns_uri, lname): value, ...}. qnames of the form {(ns_uri, lname): qname, ...}.N(RNt_qnames(R ROtqnames((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR Ws cCsDx4|jjƒD]#\}}||kr|j|SqWt|‚dS(N(RgRdRNRV(R Rtnsnametqname((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRU_s cCs=x-|jjƒD]\}}||kr|SqWt|‚dS(N(RgRdRV(R RRiRj((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRWfs cCs |j|S(N(Rg(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRXmscCs |jjƒS(N(RgRe(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR[pscCs|j|j|jƒS(N(RbRNRg(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRcss(R#R$R RURWRXR[Rc(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRfUs      cCstƒtƒtƒdS(N(RR&R5(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt_testwst__main__((((( R%Rt _exceptionsRRRR&R5R;RMRfRkR#(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyts PHYA"  PK:©ç\€ø4"ŠNŠNsax/xmlreader.pyonu„[µü¤ó ›V~gc@sÃdZddlZddlmZmZddd„ƒYZdefd„ƒYZddd „ƒYZd dd „ƒYZd dd „ƒYZ de fd„ƒYZ d„Z e dkr¿e ƒndS(s]An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. iÿÿÿÿN(tSAXNotSupportedExceptiontSAXNotRecognizedExceptiont XMLReadercBs•eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„ZRS(s%Interface for reading an XML document using callbacks. XMLReader is the interface that an XML parser's SAX2 driver must implement. This interface allows an application to set and query features and properties in the parser, to register event handlers for document processing, and to initiate a document parse. All SAX interfaces are assumed to be synchronous: the parse methods must not return until parsing is complete, and readers must wait for an event-handler callback to return before reporting the next event.cCs@tjƒ|_tjƒ|_tjƒ|_tjƒ|_dS(N( thandlertContentHandlert _cont_handlert DTDHandlert _dtd_handlertEntityResolvert _ent_handlert ErrorHandlert _err_handler(tself((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt__init__scCstdƒ‚dS(sAParse an XML document from a system identifier or an InputSource.s This method must be implemented!N(tNotImplementedError(R tsource((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytparsescCs|jS(s#Returns the current ContentHandler.(R(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetContentHandler"scCs ||_dS(s:Registers a new object to receive document content events.N(R(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytsetContentHandler&scCs|jS(s Returns the current DTD handler.(R(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getDTDHandler*scCs ||_dS(s7Register an object to receive basic DTD-related events.N(R(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setDTDHandler.scCs|jS(s#Returns the current EntityResolver.(R (R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetEntityResolver2scCs ||_dS(s0Register an object to resolve external entities.N(R (R tresolver((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytsetEntityResolver6scCs|jS(s!Returns the current ErrorHandler.(R (R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetErrorHandler:scCs ||_dS(s3Register an object to receive error-message events.N(R (R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytsetErrorHandler>scCstdƒ‚dS(sHAllow an application to set the locale for errors and warnings. SAX parsers are not required to provide localization for errors and warnings; if they cannot support the requested locale, however, they must raise a SAX exception. Applications may request a locale change in the middle of a parse.sLocale support not implementedN(R(R tlocale((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setLocaleBscCstd|ƒ‚dS(s1Looks up and returns the state of a SAX2 feature.sFeature '%s' not recognizedN(R(R tname((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getFeatureKscCstd|ƒ‚dS(s!Sets the state of a SAX2 feature.sFeature '%s' not recognizedN(R(R Rtstate((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setFeatureOscCstd|ƒ‚dS(s2Looks up and returns the value of a SAX2 property.sProperty '%s' not recognizedN(R(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getPropertySscCstd|ƒ‚dS(s"Sets the value of a SAX2 property.sProperty '%s' not recognizedN(R(R Rtvalue((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setPropertyWs(t__name__t __module__t__doc__R RRRRRRRRRRRRR R"(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR s               tIncrementalParsercBsGeZdZd d„Zd„Zd„Zd„Zd„Zd„ZRS( ssThis interface adds three extra methods to the XMLReader interface that allow XML parsers to support incremental parsing. Support for this interface is optional, since not all underlying XML parsers support this functionality. When the parser is instantiated it is ready to begin accepting data from the feed method immediately. After parsing has been finished with a call to close the reset method must be called to make the parser ready to accept new data, either from feed or using the parse method. Note that these methods must _not_ be called during parsing, that is, after parse has been called and before it returns. By default, the class also implements the parse method of the XMLReader interface using the feed, close and reset methods of the IncrementalParser interface as a convenience to SAX 2.0 driver writers.iicCs||_tj|ƒdS(N(t_bufsizeRR (R tbufsize((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR os cCs†ddl}|j|ƒ}|j|ƒ|jƒ}|j|jƒ}x/|dkrw|j|ƒ|j|jƒ}qIW|jƒdS(Niÿÿÿÿt(tsaxutilstprepare_input_sourcet prepareParsert getByteStreamtreadR'tfeedtclose(R RR*tfiletbuffer((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRss    cCstdƒ‚dS(sThis method gives the raw XML data in the data parameter to the parser and makes it parse the data, emitting the corresponding events. It is allowed for XML constructs to be split across several calls to feed. feed may raise SAXException.s This method must be implemented!N(R(R tdata((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR/scCstdƒ‚dS(stThis method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.s!prepareParser must be overridden!N(R(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR,ˆscCstdƒ‚dS(s´This method is called when the entire XML document has been passed to the parser through the feed method, to notify the parser that there are no more data. This allows the parser to do the final checks on the document and empty the internal data buffer. The parser will not be ready to parse another document until the reset method has been called. close may raise SAXException.s This method must be implemented!N(R(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR0�s cCstdƒ‚dS(sßThis method is called after close has been called to reset the parser so that it is ready to parse new documents. The results of calling parse or feed after close without calling reset are undefined.s This method must be implemented!N(R(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytresetšsi( R#R$R%R RR/R,R0R4(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR&[s   tLocatorcBs2eZdZd„Zd„Zd„Zd„ZRS(sÖInterface for associating a SAX event with a document location. A locator object will return valid results only during calls to DocumentHandler methods; at any other time, the results are unpredictable.cCsdS(s6Return the column number where the current event ends.iÿÿÿÿ((R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetColumnNumber©scCsdS(s4Return the line number where the current event ends.iÿÿÿÿ((R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getLineNumber­scCsdS(s3Return the public identifier for the current event.N(tNone(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getPublicId±scCsdS(s3Return the system identifier for the current event.N(R8(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getSystemIdµs(R#R$R%R6R7R9R:(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR5£s    t InputSourcecBsteZdZd d„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „ZRS( snEncapsulation of the information needed by the XMLReader to read entities. This class may include information about the public identifier, system identifier, byte stream (possibly with character encoding information) and/or the character stream of an entity. Applications will create objects of this class for use in the XMLReader.parse method and for returning from EntityResolver.resolveEntity. An InputSource belongs to the application, the XMLReader is not allowed to modify InputSource objects passed to it from the application, although it may make copies and modify those.cCs1||_d|_d|_d|_d|_dS(N(t_InputSource__system_idR8t_InputSource__public_idt_InputSource__encodingt_InputSource__bytefilet_InputSource__charfile(R t system_id((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR Ës     cCs ||_dS(s/Sets the public identifier of this InputSource.N(R=(R t public_id((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setPublicIdÒscCs|jS(s2Returns the public identifier of this InputSource.(R=(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR9ÖscCs ||_dS(s/Sets the system identifier of this InputSource.N(R<(R RA((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setSystemIdÚscCs|jS(s2Returns the system identifier of this InputSource.(R<(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR:ÞscCs ||_dS(s4Sets the character encoding of this InputSource. The encoding must be a string acceptable for an XML encoding declaration (see section 4.3.3 of the XML recommendation). The encoding attribute of the InputSource is ignored if the InputSource also contains a character stream.N(R>(R tencoding((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setEncodingâscCs|jS(s/Get the character encoding of this InputSource.(R>(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getEncodingìscCs ||_dS(sÅSet the byte stream (a Python file-like object which does not perform byte-to-character conversion) for this input source. The SAX parser will ignore this if there is also a character stream specified, but it will use a byte stream in preference to opening a URI connection itself. If the application knows the character encoding of the byte stream, it should set it with the setEncoding method.N(R?(R tbytefile((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt setByteStreamðs cCs|jS(sŸGet the byte stream for this input source. The getEncoding method will return the character encoding for this byte stream, or None if unknown.(R?(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR-ýscCs ||_dS(s^Set the character stream for this input source. (The stream must be a Python 2.0 Unicode-wrapped file-like that performs conversion to Unicode strings.) If there is a character stream specified, the SAX parser will ignore any byte stream and will not attempt to open a URI connection to the system identifier.N(R@(R tcharfile((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytsetCharacterStreamscCs|jS(s/Get the character stream for this input source.(R@(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetCharacterStreamsN(R#R$R%R8R RCR9RDR:RFRGRIR-RKRL(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR;»s        tAttributesImplcBs­eZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zdd„Zd„Zd„Zd„ZRS(cCs ||_dS(sQNon-NS-aware implementation. attrs should be of the form {name : value}.N(t_attrs(R tattrs((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR scCs t|jƒS(N(tlenRN(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getLengthscCsdS(NtCDATA((R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetTypescCs |j|S(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetValue"scCs |j|S(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetValueByQName%scCs||jkrt|‚n|S(N(RNtKeyError(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetNameByQName(s cCs||jkrt|‚n|S(N(RNRV(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetQNameByName-s cCs |jjƒS(N(RNtkeys(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytgetNames2scCs |jjƒS(N(RNRY(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt getQNames5scCs t|jƒS(N(RPRN(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt__len__8scCs |j|S(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt __getitem__;scCs |jjƒS(N(RNRY(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRY>scCs ||jkS(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pythas_keyAscCs ||jkS(N(RN(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt __contains__DscCs|jj||ƒS(N(RNtget(R Rt alternative((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR`GscCs|j|jƒS(N(t __class__RN(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pytcopyJscCs |jjƒS(N(RNtitems(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRdMscCs |jjƒS(N(RNtvalues(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRePsN(R#R$R RQRSRTRURWRXRZR[R\R]RYR^R_R8R`RcRdRe(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRMs$                 tAttributesNSImplcBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs||_||_dS(s–NS-aware implementation. attrs should be of the form {(ns_uri, lname): value, ...}. qnames of the form {(ns_uri, lname): qname, ...}.N(RNt_qnames(R ROtqnames((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR Ws cCsDx4|jjƒD]#\}}||kr|j|SqWt|‚dS(N(RgRdRNRV(R Rtnsnametqname((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRU_s cCs=x-|jjƒD]\}}||kr|SqWt|‚dS(N(RgRdRV(R RRiRj((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRWfs cCs |j|S(N(Rg(R R((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRXmscCs |jjƒS(N(RgRe(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyR[pscCs|j|j|jƒS(N(RbRNRg(R ((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRcss(R#R$R RURWRXR[Rc(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyRfUs      cCstƒtƒtƒdS(N(RR&R5(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyt_testwst__main__((((( R%Rt _exceptionsRRRR&R5R;RMRfRkR#(((s6/opt/alt/python27/lib64/python2.7/xml/sax/xmlreader.pyts PHYA"  PK:©ç\16ºÔÔ __init__.pynu„[µü¤"""Core XML support for Python. This package contains four sub-packages: dom -- The W3C Document Object Model. This supports DOM Level 1 + Namespaces. parsers -- Python wrappers for XML parsers (currently only supports Expat). sax -- The Simple API for XML, developed by XML-Dev, led by David Megginson and ported to Python by Lars Marius Garshol. This supports the SAX 2 API. etree -- The ElementTree XML library. This is a subset of the full ElementTree XML release. """ __all__ = ["dom", "parsers", "sax", "etree"] _MINIMUM_XMLPLUS_VERSION = (0, 8, 4) try: import _xmlplus except ImportError: pass else: try: v = _xmlplus.version_info except AttributeError: # _xmlplus is too old; ignore it pass else: if v >= _MINIMUM_XMLPLUS_VERSION: import sys _xmlplus.__path__.extend(__path__) sys.modules[__name__] = _xmlplus else: del v PK:©ç\%ÓcCC __init__.pycnu„[µü¤ó ›V~gc@s¢dZddddgZd Zydd lZWnek rAn]Xy ejZWnek rbn<Xeekr›dd lZej j e ƒeej e s     PK:©ç\%ÓcCC __init__.pyonu„[µü¤ó ›V~gc@s¢dZddddgZd Zydd lZWnek rAn]Xy ejZWnek rbn<Xeekr›dd lZej j e ƒeej e s     PK:©ç\ÖCc©©dom/NodeFilter.pynu„[µü¤PK:©ç\Nz/��êdom/NodeFilter.pycnu„[µü¤PK:©ç\Nz/��¹dom/NodeFilter.pyonu„[µü¤PK:©ç\XBžžˆ dom/__init__.pynu„[µü¤PK:©ç\}VBÊmmedom/__init__.pycnu„[µü¤PK:©ç\}VBÊmm8dom/__init__.pyonu„[µü¤PK:©ç\„CxrÇ Ç ¿Rdom/domreg.pynu„[µü¤PK:©ç\M`j®y y Ã`dom/domreg.pycnu„[µü¤PK:©ç\M`j®y y zndom/domreg.pyonu„[µü¤PK:©ç\˜”CpŽŽ1|dom/expatbuilder.pynu„[µü¤PK:©ç\X£¿@i…i…“ dom/expatbuilder.pycnu„[µü¤PK:©ç\›«Æ,æ‚æ‚@�dom/expatbuilder.pyonu„[µü¤PK:©ç\©);˜  jdom/minicompat.pynu„[µü¤PK:©ç\áz#È dom/minicompat.pycnu„[µü¤PK:©ç\Š?,d¬ ¬ &/dom/minicompat.pyonu„[µü¤PK:©ç\‹dfãã=dom/minidom.pynu„[µü¤PK:©ç\tÕm3Ù Ù 5@dom/minidom.pycnu„[µü¤PK:©ç\eðiÂU U MLdom/minidom.pyonu„[µü¤PK:©ç\`ÖÙÆ.Æ.áWdom/pulldom.pynu„[µü¤PK:©ç\hH–é8585å†dom/pulldom.pycnu„[µü¤PK:©ç\hH–é8585\¼dom/pulldom.pyonu„[µü¤PK:©ç\l$Å„1010Óñdom/xmlbuilder.pynu„[µü¤PK:©ç\2+Æ·>·>E"dom/xmlbuilder.pycnu„[µü¤PK:©ç\/Ú1‹>‹>>adom/xmlbuilder.pyonu„[µü¤PK:©ç\ÎïÔÔ  etree/ElementInclude.pynu„[µü¤PK:©ç\\¦‹ãã&´etree/ElementInclude.pycnu„[µü¤PK:©ç\\¦‹ããQ¼etree/ElementInclude.pyonu„[µü¤PK:©ç\E¢²g%%|Äetree/ElementPath.pynu„[µü¤PK:©ç\w¶ËÃéetree/ElementPath.pycnu„[µü¤PK:©ç\w¶Ë etree/ElementPath.pyonu„[µü¤PK:©ç\Õ"/¤ÈÞÈÞ[(etree/ElementTree.pynu„[µü¤PK:©ç\̹éµ��getree/ElementTree.pycnu„[µü¤PK:©ç\­‚ܤ�¤�Ë–etree/ElementTree.pyonu„[µü¤PK:©ç\W€ZµDD´$ etree/__init__.pynu„[µü¤PK:©ç\lˆZŽŽ9+ etree/__init__.pycnu„[µü¤PK:©ç\lˆZŽŽ , etree/__init__.pyonu„[µü¤PK:©ç\ð>)>>Ù, etree/cElementTree.pynu„[µü¤PK:©ç\"Š£’½½\- etree/cElementTree.pycnu„[µü¤PK:©ç\"Š£’½½_. etree/cElementTree.pyonu„[µü¤PK:©ç\;Ý|¹§§b/ parsers/__init__.pynu„[µü¤PK:©ç\Áš“GGL0 parsers/__init__.pycnu„[µü¤PK:©ç\Áš“GG×1 parsers/__init__.pyonu„[µü¤PK:©ç\¹vÙÏrrb3 parsers/expat.pynu„[µü¤PK:©ç\�¥g,,4 parsers/expat.pycnu„[µü¤PK:©ç\�¥g,,�5 parsers/expat.pyonu„[µü¤PK:©ç\,†•ÿ""î6 sax/__init__.pynu„[µü¤PK:©ç\3•z‘ïïOE sax/__init__.pycnu„[µü¤PK:©ç\3•z‘ïï~T sax/__init__.pyonu„[µü¤PK:©ç\}F¾¾±±­c sax/_exceptions.pynu„[µü¤PK:©ç\ßÃÝÃöö v sax/_exceptions.pycnu„[µü¤PK:©ç\ßÃÝÃööÙ� sax/_exceptions.pyonu„[µü¤PK:©ç\~bÙÏÄ=Ä=© sax/expatreader.pynu„[µü¤PK:©ç\WÖ‰¹g=g=ç sax/expatreader.pycnu„[µü¤PK:©ç\WÖ‰¹g=g=Â$ sax/expatreader.pyonu„[µü¤PK:©ç\sE(Áa6a6lb sax/handler.pynu„[µü¤PK:©ç\0gd+)4)4 ™ sax/handler.pycnu„[µü¤PK:©ç\0gd+)4)4sÍ sax/handler.pyonu„[µü¤PK:©ç\÷b’B$-$-Û sax/saxutils.pynu„[µü¤PK:©ç\¨2…,�<�<>/ sax/saxutils.pycnu„[µü¤PK:©ç\¨2…,�<�< l sax/saxutils.pyonu„[µü¤PK:©ç\ <bX1X1ܨ sax/xmlreader.pynu„[µü¤PK:©ç\€ø4"ŠNŠNtÚ sax/xmlreader.pycnu„[µü¤PK:©ç\€ø4"ŠNŠN?) sax/xmlreader.pyonu„[µü¤PK:©ç\16ºÔÔ  x __init__.pynu„[µü¤PK:©ç\%ÓcCC | __init__.pycnu„[µü¤PK:©ç\%ÓcCC ˜€ __init__.pyonu„[µü¤PKBBÿ…