fD1c@sdZddlmZddlmZmZGdddZGdddeZGdd d ZGd d d Z Gd d d Z Gddde Z ddZ e dkre ndS(u]An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. i(uhandler(uSAXNotSupportedExceptionuSAXNotRecognizedExceptioncBs|EeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd S(!u XMLReaderu%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( uhandleruContentHandleru _cont_handleru DTDHandleru _dtd_handleruEntityResolveru _ent_handleru ErrorHandleru _err_handler(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu__init__suXMLReader.__init__cCstddS(uAParse an XML document from a system identifier or an InputSource.u This method must be implemented!N(uNotImplementedError(uselfusource((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuparsesuXMLReader.parsecCs|jS(u#Returns the current ContentHandler.(u _cont_handler(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetContentHandler"suXMLReader.getContentHandlercCs ||_dS(u:Registers a new object to receive document content events.N(u _cont_handler(uselfuhandler((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyusetContentHandler&suXMLReader.setContentHandlercCs|jS(u Returns the current DTD handler.(u _dtd_handler(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getDTDHandler*suXMLReader.getDTDHandlercCs ||_dS(u7Register an object to receive basic DTD-related events.N(u _dtd_handler(uselfuhandler((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu setDTDHandler.suXMLReader.setDTDHandlercCs|jS(u#Returns the current EntityResolver.(u _ent_handler(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetEntityResolver2suXMLReader.getEntityResolvercCs ||_dS(u0Register an object to resolve external entities.N(u _ent_handler(uselfuresolver((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyusetEntityResolver6suXMLReader.setEntityResolvercCs|jS(u!Returns the current ErrorHandler.(u _err_handler(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetErrorHandler:suXMLReader.getErrorHandlercCs ||_dS(u3Register an object to receive error-message events.N(u _err_handler(uselfuhandler((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyusetErrorHandler>suXMLReader.setErrorHandlercCstddS(uHAllow 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.uLocale support not implementedN(uSAXNotSupportedException(uselfulocale((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu setLocaleBsuXMLReader.setLocalecCstd|dS(u1Looks up and returns the state of a SAX2 feature.uFeature '%s' not recognizedN(uSAXNotRecognizedException(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getFeatureKsuXMLReader.getFeaturecCstd|dS(u!Sets the state of a SAX2 feature.uFeature '%s' not recognizedN(uSAXNotRecognizedException(uselfunameustate((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu setFeatureOsuXMLReader.setFeaturecCstd|dS(u2Looks up and returns the value of a SAX2 property.uProperty '%s' not recognizedN(uSAXNotRecognizedException(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getPropertySsuXMLReader.getPropertycCstd|dS(u"Sets the value of a SAX2 property.uProperty '%s' not recognizedN(uSAXNotRecognizedException(uselfunameuvalue((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu setPropertyWsuXMLReader.setPropertyN(u__name__u __module__u __qualname__u__doc__u__init__uparseugetContentHandlerusetContentHandleru getDTDHandleru setDTDHandlerugetEntityResolverusetEntityResolverugetErrorHandlerusetErrorHandleru setLocaleu getFeatureu setFeatureu getPropertyu setProperty(u __locals__((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu XMLReader s               u XMLReadercBse|EeZdZdZdddZddZdd Zd d Zd d ZddZ dS(uIncrementalParserusThis 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(u_bufsizeu XMLReaderu__init__(uselfubufsize((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu__init__os uIncrementalParser.__init__cCsddlm}|j|}|j||j}|j|j}x)|ru|j||j|j}qMW|jdS(Ni(usaxutils( uusaxutilsuprepare_input_sourceu prepareParseru getByteStreamureadu_bufsizeufeeduclose(uselfusourceusaxutilsufileubuffer((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuparsess    uIncrementalParser.parsecCstddS(uThis 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.u This method must be implemented!N(uNotImplementedError(uselfudata((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyufeedsuIncrementalParser.feedcCstddS(utThis method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.u!prepareParser must be overridden!N(uNotImplementedError(uselfusource((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu prepareParsersuIncrementalParser.prepareParsercCstddS(uThis 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.u This method must be implemented!N(uNotImplementedError(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyucloses uIncrementalParser.closecCstddS(uThis 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.u This method must be implemented!N(uNotImplementedError(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuresetsuIncrementalParser.resetNi( u__name__u __module__u __qualname__u__doc__u__init__uparseufeedu prepareParserucloseureset(u __locals__((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuIncrementalParser[s  uIncrementalParsercBsJ|EeZdZdZddZddZddZdd Zd S( uLocatoruInterface 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(u6Return the column number where the current event ends.ii((uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetColumnNumbersuLocator.getColumnNumbercCsdS(u4Return the line number where the current event ends.ii((uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getLineNumbersuLocator.getLineNumbercCsdS(u3Return the public identifier for the current event.N(uNone(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getPublicIdsuLocator.getPublicIdcCsdS(u3Return the system identifier for the current event.N(uNone(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getSystemIdsuLocator.getSystemIdN(u__name__u __module__u __qualname__u__doc__ugetColumnNumberu getLineNumberu getPublicIdu getSystemId(u __locals__((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuLocators    uLocatorcBs|EeZdZdZdddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZdS(u InputSourceunEncapsulation 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(u_InputSource__system_iduNoneu_InputSource__public_idu_InputSource__encodingu_InputSource__bytefileu_InputSource__charfile(uselfu system_id((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu__init__s     uInputSource.__init__cCs ||_dS(u/Sets the public identifier of this InputSource.N(u_InputSource__public_id(uselfu public_id((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu setPublicIdsuInputSource.setPublicIdcCs|jS(u2Returns the public identifier of this InputSource.(u_InputSource__public_id(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getPublicIdsuInputSource.getPublicIdcCs ||_dS(u/Sets the system identifier of this InputSource.N(u_InputSource__system_id(uselfu system_id((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu setSystemIdsuInputSource.setSystemIdcCs|jS(u2Returns the system identifier of this InputSource.(u_InputSource__system_id(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getSystemIdsuInputSource.getSystemIdcCs ||_dS(u4Sets 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(u_InputSource__encoding(uselfuencoding((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu setEncodingsuInputSource.setEncodingcCs|jS(u/Get the character encoding of this InputSource.(u_InputSource__encoding(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getEncodingsuInputSource.getEncodingcCs ||_dS(uSet 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(u_InputSource__bytefile(uselfubytefile((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu setByteStreams uInputSource.setByteStreamcCs|jS(uGet the byte stream for this input source. The getEncoding method will return the character encoding for this byte stream, or None if unknown.(u_InputSource__bytefile(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getByteStreamsuInputSource.getByteStreamcCs ||_dS(u^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(u_InputSource__charfile(uselfucharfile((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyusetCharacterStreamsuInputSource.setCharacterStreamcCs|jS(u/Get the character stream for this input source.(u_InputSource__charfile(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetCharacterStreamsuInputSource.getCharacterStreamN(u__name__u __module__u __qualname__u__doc__uNoneu__init__u setPublicIdu getPublicIdu setSystemIdu getSystemIdu setEncodingu getEncodingu setByteStreamu getByteStreamusetCharacterStreamugetCharacterStream(u __locals__((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu InputSources       u InputSourcecBs|EeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZd#ddZddZdd Zd!d"Zd#S($uAttributesImplcCs ||_dS(uQNon-NS-aware implementation. attrs should be of the form {name : value}.N(u_attrs(uselfuattrs((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu__init__suAttributesImpl.__init__cCs t|jS(N(ulenu_attrs(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getLengthsuAttributesImpl.getLengthcCsdS(NuCDATA((uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetTypesuAttributesImpl.getTypecCs |j|S(N(u_attrs(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetValue"suAttributesImpl.getValuecCs |j|S(N(u_attrs(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetValueByQName%suAttributesImpl.getValueByQNamecCs"||jkrt|n|S(N(u_attrsuKeyError(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetNameByQName(suAttributesImpl.getNameByQNamecCs"||jkrt|n|S(N(u_attrsuKeyError(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetQNameByName-suAttributesImpl.getQNameByNamecCst|jjS(N(ulistu_attrsukeys(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetNames2suAttributesImpl.getNamescCst|jjS(N(ulistu_attrsukeys(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getQNames5suAttributesImpl.getQNamescCs t|jS(N(ulenu_attrs(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu__len__8suAttributesImpl.__len__cCs |j|S(N(u_attrs(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu __getitem__;suAttributesImpl.__getitem__cCst|jjS(N(ulistu_attrsukeys(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyukeys>suAttributesImpl.keyscCs ||jkS(N(u_attrs(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu __contains__AsuAttributesImpl.__contains__cCs|jj||S(N(u_attrsuget(uselfunameu alternative((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetDsuAttributesImpl.getcCs|j|jS(N(u __class__u_attrs(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyucopyGsuAttributesImpl.copycCst|jjS(N(ulistu_attrsuitems(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuitemsJsuAttributesImpl.itemscCst|jjS(N(ulistu_attrsuvalues(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuvaluesMsuAttributesImpl.valuesN(u__name__u __module__u __qualname__u__init__u getLengthugetTypeugetValueugetValueByQNameugetNameByQNameugetQNameByNameugetNamesu getQNamesu__len__u __getitem__ukeysu __contains__uNoneugetucopyuitemsuvalues(u __locals__((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuAttributesImpls"               uAttributesImplcBs\|EeZdZddZddZddZddZd d Zd d Zd S(uAttributesNSImplcCs||_||_dS(uNS-aware implementation. attrs should be of the form {(ns_uri, lname): value, ...}. qnames of the form {(ns_uri, lname): qname, ...}.N(u_attrsu_qnames(uselfuattrsuqnames((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu__init__Ts uAttributesNSImpl.__init__cCsGx4|jjD]#\}}||kr|j|SqWt|dS(N(u_qnamesuitemsu_attrsuKeyError(uselfunameunsnameuqname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetValueByQName\s u AttributesNSImpl.getValueByQNamecCs@x-|jjD]\}}||kr|SqWt|dS(N(u_qnamesuitemsuKeyError(uselfunameunsnameuqname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetNameByQNamecs uAttributesNSImpl.getNameByQNamecCs |j|S(N(u_qnames(uselfuname((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyugetQNameByNamejsuAttributesNSImpl.getQNameByNamecCst|jjS(N(ulistu_qnamesuvalues(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu getQNamesmsuAttributesNSImpl.getQNamescCs|j|j|jS(N(u __class__u_attrsu_qnames(uself((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyucopypsuAttributesNSImpl.copyN( u__name__u __module__u __qualname__u__init__ugetValueByQNameugetNameByQNameugetQNameByNameu getQNamesucopy(u __locals__((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyuAttributesNSImplRs      uAttributesNSImplcCstttdS(N(u XMLReaderuIncrementalParseruLocator(((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyu_testtsu_testu__main__N(u__doc__uuhandleru _exceptionsuSAXNotSupportedExceptionuSAXNotRecognizedExceptionu XMLReaderuIncrementalParseruLocatoru InputSourceuAttributesImpluAttributesNSImplu_testu__name__(((u6/opt/alt/python33/lib64/python3.3/xml/sax/xmlreader.pyusPHY>"