�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!_exceptions.py000064400000011261152527036000007437 0ustar00"""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.""" xmlreader.pyo000064400000045426152527036000007273 0ustar00 {fc@sdZddlZddlmZmZdddYZdefdYZddd YZd dd YZd dd YZ de fdYZ dZ e dkre ndS(s]An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. iN(tSAXNotSupportedExceptiontSAXNotRecognizedExceptiont XMLReadercBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZRS(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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt__init__scCstddS(sAParse an XML document from a system identifier or an InputSource.s This method must be implemented!N(tNotImplementedError(R tsource((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytparsescCs|jS(s#Returns the current ContentHandler.(R(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetContentHandler"scCs ||_dS(s:Registers a new object to receive document content events.N(R(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytsetContentHandler&scCs|jS(s Returns the current DTD handler.(R(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getDTDHandler*scCs ||_dS(s7Register an object to receive basic DTD-related events.N(R(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setDTDHandler.scCs|jS(s#Returns the current EntityResolver.(R (R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetEntityResolver2scCs ||_dS(s0Register an object to resolve external entities.N(R (R tresolver((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytsetEntityResolver6scCs|jS(s!Returns the current ErrorHandler.(R (R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetErrorHandler:scCs ||_dS(s3Register an object to receive error-message events.N(R (R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytsetErrorHandler>scCstddS(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((s)/usr/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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getFeatureKscCstd|dS(s!Sets the state of a SAX2 feature.sFeature '%s' not recognizedN(R(R Rtstate((s)/usr/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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getPropertySscCstd|dS(s"Sets the value of a SAX2 property.sProperty '%s' not recognizedN(R(R Rtvalue((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setPropertyWs(t__name__t __module__t__doc__R RRRRRRRRRRRRR R"(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR s               tIncrementalParsercBsGeZdZd dZdZdZdZdZdZRS( 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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR os cCsddl}|j|}|j||j}|j|j}x/|dkrw|j||j|j}qIW|jdS(Nit(tsaxutilstprepare_input_sourcet prepareParsert getByteStreamtreadR'tfeedtclose(R RR*tfiletbuffer((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRss    cCstddS(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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR/scCstddS(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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR,scCstddS(sThis 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 ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR0s cCstddS(sThis 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 ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytresetsi( R#R$R%R RR/R,R0R4(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR&[s   tLocatorcBs2eZdZdZdZdZdZRS(sInterface 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 ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetColumnNumberscCsdS(s4Return the line number where the current event ends.i((R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getLineNumberscCsdS(s3Return the public identifier for the current event.N(tNone(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getPublicIdscCsdS(s3Return the system identifier for the current event.N(R8(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getSystemIds(R#R$R%R6R7R9R:(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR5s    t InputSourcecBsteZdZd dZdZdZdZdZdZ dZ dZ 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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR s     cCs ||_dS(s/Sets the public identifier of this InputSource.N(R=(R t public_id((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setPublicIdscCs|jS(s2Returns the public identifier of this InputSource.(R=(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR9scCs ||_dS(s/Sets the system identifier of this InputSource.N(R<(R RA((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setSystemIdscCs|jS(s2Returns the system identifier of this InputSource.(R<(R ((s)/usr/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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setEncodingscCs|jS(s/Get the character encoding of this InputSource.(R>(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getEncodingscCs ||_dS(sSet 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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setByteStreams cCs|jS(sGet 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 ((s)/usr/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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytsetCharacterStreamscCs|jS(s/Get the character stream for this input source.(R@(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetCharacterStreamsN(R#R$R%R8R RCR9RDR:RFRGRIR-RKRL(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR;s        tAttributesImplcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZddZdZdZdZRS(cCs ||_dS(sQNon-NS-aware implementation. attrs should be of the form {name : value}.N(t_attrs(R tattrs((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR scCs t|jS(N(tlenRN(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getLengthscCsdS(NtCDATA((R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetTypescCs |j|S(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetValue"scCs |j|S(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetValueByQName%scCs||jkrt|n|S(N(RNtKeyError(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetNameByQName(s cCs||jkrt|n|S(N(RNRV(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetQNameByName-s cCs |jjS(N(RNtkeys(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetNames2scCs |jjS(N(RNRY(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getQNames5scCs t|jS(N(RPRN(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt__len__8scCs |j|S(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt __getitem__;scCs |jjS(N(RNRY(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRY>scCs ||jkS(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pythas_keyAscCs ||jkS(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt __contains__DscCs|jj||S(N(RNtget(R Rt alternative((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR`GscCs|j|jS(N(t __class__RN(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytcopyJscCs |jjS(N(RNtitems(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRdMscCs |jjS(N(RNtvalues(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRePsN(R#R$R RQRSRTRURWRXRZR[R\R]RYR^R_R8R`RcRdRe(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRMs$                 tAttributesNSImplcBs>eZdZdZdZdZdZdZRS(cCs||_||_dS(sNS-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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR Ws cCsDx4|jjD]#\}}||kr|j|SqWt|dS(N(RgRdRNRV(R Rtnsnametqname((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRU_s cCs=x-|jjD]\}}||kr|SqWt|dS(N(RgRdRV(R RRiRj((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRWfs cCs |j|S(N(Rg(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRXmscCs |jjS(N(RgRe(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR[pscCs|j|j|jS(N(RbRNRg(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRcss(R#R$R RURWRXR[Rc(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRfUs      cCstttdS(N(RR&R5(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt_testwst__main__((((( R%Rt _exceptionsRRRR&R5R;RMRfRkR#(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyts PHYA"  saxutils.py000064400000027655152527036000007011 0ustar00"""\ A library of useful helper classes to the SAX classes, for the convenience of application and driver writers. """ import os, urllib.parse, urllib.request import io import codecs from . import handler from . import xmlreader 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 return sys.stdout if isinstance(out, io.TextIOBase): # use a text writer as is return out if isinstance(out, (codecs.StreamWriter, codecs.StreamReaderWriter)): # use a codecs stream writer as is return out # wrap a binary writer with TextIOWrapper if isinstance(out, io.RawIOBase): # Keep the original file open when the TextIOWrapper is # destroyed class _wrapper: __class__ = out.__class__ def __getattr__(self, name): return getattr(out, name) buffer = _wrapper() 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 return io.TextIOWrapper(buffer, encoding=encoding, errors='xmlcharrefreplace', newline='\n', write_through=True) class XMLGenerator(handler.ContentHandler): def __init__(self, out=None, encoding="iso-8859-1", short_empty_elements=False): 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 self._short_empty_elements = short_empty_elements self._pending_start_element = False 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] def _finish_pending_start_element(self,endElement=False): if self._pending_start_element: self._write('>') self._pending_start_element = False # ContentHandler methods def startDocument(self): self._write('\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._finish_pending_start_element() self._write('<' + name) for (name, value) in attrs.items(): self._write(' %s=%s' % (name, quoteattr(value))) if self._short_empty_elements: self._pending_start_element = True else: self._write(">") def endElement(self, name): if self._pending_start_element: self._write('/>') self._pending_start_element = False else: self._write('' % name) def startElementNS(self, name, qname, attrs): self._finish_pending_start_element() self._write('<' + self._qname(name)) for prefix, uri in self._undeclared_ns_maps: if prefix: self._write(' xmlns:%s="%s"' % (prefix, uri)) else: self._write(' xmlns="%s"' % uri) self._undeclared_ns_maps = [] for (name, value) in attrs.items(): self._write(' %s=%s' % (self._qname(name), quoteattr(value))) if self._short_empty_elements: self._pending_start_element = True else: self._write(">") def endElementNS(self, name, qname): if self._pending_start_element: self._write('/>') self._pending_start_element = False else: self._write('' % self._qname(name)) def characters(self, content): if content: self._finish_pending_start_element() if not isinstance(content, str): content = str(content, self._encoding) self._write(escape(content)) def ignorableWhitespace(self, content): if content: self._finish_pending_start_element() if not isinstance(content, str): content = str(content, self._encoding) self._write(content) def processingInstruction(self, target, data): self._finish_pending_start_element() self._write('' % (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 isinstance(source, str): source = xmlreader.InputSource(source) elif hasattr(source, "read"): f = source source = xmlreader.InputSource() if isinstance(f.read(0), str): source.setCharacterStream(f) else: source.setByteStream(f) if hasattr(f, "name") and isinstance(f.name, str): source.setSystemId(f.name) if source.getCharacterStream() is None and source.getByteStream() is None: sysid = source.getSystemId() basehead = os.path.dirname(os.path.normpath(base)) sysidfilename = os.path.join(basehead, sysid) if os.path.isfile(sysidfilename): source.setSystemId(sysidfilename) f = open(sysidfilename, "rb") else: source.setSystemId(urllib.parse.urljoin(base, sysid)) f = urllib.request.urlopen(source.getSystemId()) source.setByteStream(f) return source saxutils.pyo000064400000034721152527036000007160 0ustar00 {fc@s-dZddlZddlZddlZddlZddlZddlZddlZddlZyej ej gZ Wne k rej gZ nXdZ idZidZidZdZdejfd YZd ejfd YZd ejfd YZddZdS(snA library of useful helper classes to the SAX classes, for the convenience of application and driver writers. iNcCs3x,|jD]\}}|j||}q W|S(s2Replace substrings of a string using a dictionary.(titemstreplace(tstdtkeytvalue((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt__dict_replacescCsR|jdd}|jdd}|jdd}|rNt||}n|S(sEscape &, <, 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 ((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt quoteattr5s "    cCs|dkr$ddl}|j}nt|tjrTtj|}d|_nTtj}d|_|j |_ y|j |_ |j |_ Wnt k rnXt |d|ddddS( NicSsdS(N(tNone(((s(/usr/lib64/python2.7/xml/sax/saxutils.pytVtcSstS(N(tTrue(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR[Rtencodingterrorstxmlcharrefreplacetnewlines (Rtsyststdoutt isinstancetiot RawIOBasetBufferedIOBasetclosetwritabletwritetseekablettelltAttributeErrort_UnbufferedTextIOWrapper(toutRRtbuffer((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt_gettextwriterMs"        R'cBseZdZRS(cCs$tt|j||jdS(N(tsuperR'R#tflush(tselfR((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR#ks(t__name__t __module__R#(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR'jst XMLGeneratorcBseZdddZdZdZdZdZdZdZ dZ 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((s(/usr/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((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt_qname|s  cCs|jd|jdS(Nu$ (R4R9(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt startDocuments cCs|jdS(N(R5(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endDocumentscCs@|jj|jj||j|<|jj||fdS(N(R6tappendR7RR8(R-R<turi((s(/usr/lib64/python2.7/xml/sax/saxutils.pytstartPrefixMappings cCs|jd|_|jd=dS(Ni(R6R7(R-R<((s(/usr/lib64/python2.7/xml/sax/saxutils.pytendPrefixMappingscCs\|jd|x7|jD])\}}|jd|t|fqW|jddS(Nu(R4RR(R-R;tattrsR((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt startElements!cCs|jd|dS(Nu(R4(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endElementscCs|jd|j|xH|jD]=\}}|rP|jd||fq$|jd|q$Wg|_x@|jD]2\}}|jd|j|t|fq{W|jddS(Nu(R4R=R8RR(R-R;tqnameRDR<RAR((s(/usr/lib64/python2.7/xml/sax/saxutils.pytstartElementNSs *cCs|jd|j|dS(Nu(R4R=(R-R;RG((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endElementNSscCs;t|ts$t||j}n|jt|dS(N(RtunicodeR9R4R (R-tcontent((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt charactersscCs5t|ts$t||j}n|j|dS(N(RRJR9R4(R-RK((s(/usr/lib64/python2.7/xml/sax/saxutils.pytignorableWhitespacescCs|jd||fdS(Nu (R4(R-ttargetR ((s(/usr/lib64/python2.7/xml/sax/saxutils.pytprocessingInstructionsN(R.R/RR3R=R>R?RBRCRERFRHRIRLRMRO(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR0ps           t XMLFilterBasecBs eZdZddZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(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((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR3scCs|jj|dS(N(t _err_handlerterror(R-t exception((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRVscCs|jj|dS(N(RUt fatalError(R-RW((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRXscCs|jj|dS(N(RUtwarning(R-RW((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRYscCs|jj|dS(N(t _cont_handlertsetDocumentLocator(R-tlocator((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR[scCs|jjdS(N(RZR>(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR>scCs|jjdS(N(RZR?(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR?scCs|jj||dS(N(RZRB(R-R<RA((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRBscCs|jj|dS(N(RZRC(R-R<((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRCscCs|jj||dS(N(RZRE(R-R;RD((s(/usr/lib64/python2.7/xml/sax/saxutils.pyREscCs|jj|dS(N(RZRF(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRFscCs|jj|||dS(N(RZRH(R-R;RGRD((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRHscCs|jj||dS(N(RZRI(R-R;RG((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRIscCs|jj|dS(N(RZRL(R-RK((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRLscCs|jj|dS(N(RZRM(R-tchars((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRMscCs|jj||dS(N(RZRO(R-RNR ((s(/usr/lib64/python2.7/xml/sax/saxutils.pyROscCs|jj|dS(N(RZt skippedEntity(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR^scCs|jj|||dS(N(t _dtd_handlert notationDecl(R-R;tpublicIdtsystemId((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR` scCs|jj||||dS(N(R_tunparsedEntityDecl(R-R;RaRbtndata((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRc scCs|jj||S(N(t _ent_handlert resolveEntity(R-RaRb((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRfscCsT|jj||jj||jj||jj||jj|dS(N(RStsetContentHandlertsetErrorHandlertsetEntityResolvert setDTDHandlertparse(R-tsource((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRks cCs|jj|dS(N(RSt setLocale(R-tlocale((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRmscCs|jj|S(N(RSt getFeature(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRo scCs|jj||dS(N(RSt setFeature(R-R;tstate((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRp#scCs|jj|S(N(RSt getProperty(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRr&scCs|jj||dS(N(RSt setProperty(R-R;R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRs)scCs|jS(N(RS(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt getParent.scCs ||_dS(N(RS(R-RT((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt setParent1sN( R.R/t__doc__RR3RVRXRYR[R>R?RBRCRERFRHRIRLRMROR^R`RcRfRkRmRoRpRrRsRtRu(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRPs:                           RcCst|tkr$tj|}nSt|drw|}tj}|j|t|drw|j|jqwn|jdkry|j }t j j t j j|}tj}t|trt|tsdy|j|}Wqtk r|j|}qXqdnHt|trdy|j|}Wqdtk r`|j|}qdXnt j j||}t j j|}Wntk rt}nX|r|j|t|d}n4|jtj||j tj|j }|j|n|S(sThis 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((s(/usr/lib64/python2.7/xml/sax/saxutils.pytprepare_input_source6sF         (RvRRRttypesRRR1RQt StringTypet UnicodeTypeRzR&RR R RR*t TextIOWrapperR'R2R0RRRPR(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyts$0          Wohandler.pyo000064400000031344152527036000006717 0ustar00 {fc@sdZdZdddYZdddYZdddYZddd 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)eZdZdZdZdZRS(sBasic 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((s'/usr/lib64/python2.7/xml/sax/handler.pyterror scCs |dS(sHandle a non-recoverable error.N((RR((s'/usr/lib64/python2.7/xml/sax/handler.pyt fatalError$scCs |GHdS(sHandle a warning.N((RR((s'/usr/lib64/python2.7/xml/sax/handler.pytwarning(s(t__name__t __module__t__doc__RRR(((s'/usr/lib64/python2.7/xml/sax/handler.pyRs  tContentHandlercBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZRS(sInterface 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((s'/usr/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((s'/usr/lib64/python2.7/xml/sax/handler.pytsetDocumentLocator9scCsdS(sReceive 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((s'/usr/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((s'/usr/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((s'/usr/lib64/python2.7/xml/sax/handler.pytstartPrefixMapping`RcCsdS(sEnd 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((s'/usr/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((s'/usr/lib64/python2.7/xml/sax/handler.pyt startElement~RcCsdS(sSignals 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((s'/usr/lib64/python2.7/xml/sax/handler.pyt endElementRcCsdS(sSignals 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((s'/usr/lib64/python2.7/xml/sax/handler.pytstartElementNSRcCsdS(sSignals 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((s'/usr/lib64/python2.7/xml/sax/handler.pyt endElementNSRcCsdS(sReceive 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((s'/usr/lib64/python2.7/xml/sax/handler.pyt charactersRcCsdS(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((s'/usr/lib64/python2.7/xml/sax/handler.pytignorableWhitespaceRcCsdS(sReceive 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((s'/usr/lib64/python2.7/xml/sax/handler.pytprocessingInstructionRcCsdS(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((s'/usr/lib64/python2.7/xml/sax/handler.pyt skippedEntityR(RRRR RRRRRRRRRRR R#R$(((s'/usr/lib64/python2.7/xml/sax/handler.pyR /s          t DTDHandlercBs eZdZdZdZRS(sHandle 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((s'/usr/lib64/python2.7/xml/sax/handler.pyt notationDeclRcCsdS(s,Handle an unparsed entity declaration event.N((RRR&R'tndata((s'/usr/lib64/python2.7/xml/sax/handler.pytunparsedEntityDeclR(RRRR(R*(((s'/usr/lib64/python2.7/xml/sax/handler.pyR%s tEntityResolvercBseZdZdZRS(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(sResolve 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'((s'/usr/lib64/python2.7/xml/sax/handler.pyt resolveEntitys(RRRR,(((s'/usr/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(((s'/usr/lib64/python2.7/xml/sax/handler.pyt s:   handler.pyc000064400000031344152527036000006703 0ustar00 {fc@sdZdZdddYZdddYZdddYZddd 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)eZdZdZdZdZRS(sBasic 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((s'/usr/lib64/python2.7/xml/sax/handler.pyterror scCs |dS(sHandle a non-recoverable error.N((RR((s'/usr/lib64/python2.7/xml/sax/handler.pyt fatalError$scCs |GHdS(sHandle a warning.N((RR((s'/usr/lib64/python2.7/xml/sax/handler.pytwarning(s(t__name__t __module__t__doc__RRR(((s'/usr/lib64/python2.7/xml/sax/handler.pyRs  tContentHandlercBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZRS(sInterface 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((s'/usr/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((s'/usr/lib64/python2.7/xml/sax/handler.pytsetDocumentLocator9scCsdS(sReceive 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((s'/usr/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((s'/usr/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((s'/usr/lib64/python2.7/xml/sax/handler.pytstartPrefixMapping`RcCsdS(sEnd 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((s'/usr/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((s'/usr/lib64/python2.7/xml/sax/handler.pyt startElement~RcCsdS(sSignals 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((s'/usr/lib64/python2.7/xml/sax/handler.pyt endElementRcCsdS(sSignals 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((s'/usr/lib64/python2.7/xml/sax/handler.pytstartElementNSRcCsdS(sSignals 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((s'/usr/lib64/python2.7/xml/sax/handler.pyt endElementNSRcCsdS(sReceive 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((s'/usr/lib64/python2.7/xml/sax/handler.pyt charactersRcCsdS(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((s'/usr/lib64/python2.7/xml/sax/handler.pytignorableWhitespaceRcCsdS(sReceive 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((s'/usr/lib64/python2.7/xml/sax/handler.pytprocessingInstructionRcCsdS(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((s'/usr/lib64/python2.7/xml/sax/handler.pyt skippedEntityR(RRRR RRRRRRRRRRR R#R$(((s'/usr/lib64/python2.7/xml/sax/handler.pyR /s          t DTDHandlercBs eZdZdZdZRS(sHandle 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((s'/usr/lib64/python2.7/xml/sax/handler.pyt notationDeclRcCsdS(s,Handle an unparsed entity declaration event.N((RRR&R'tndata((s'/usr/lib64/python2.7/xml/sax/handler.pytunparsedEntityDeclR(RRRR(R*(((s'/usr/lib64/python2.7/xml/sax/handler.pyR%s tEntityResolvercBseZdZdZRS(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(sResolve 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'((s'/usr/lib64/python2.7/xml/sax/handler.pyt resolveEntitys(RRRR,(((s'/usr/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(((s'/usr/lib64/python2.7/xml/sax/handler.pyt s:   __init__.pyc000064400000007241152527036000007024 0ustar00 {fc@sjdZddlmZddlmZmZddlmZmZm Z m Z m Z edZ edZ dgZdZerdd lZndd lZdd lZejj rd ejkrejd jd Zn[d Zejd dkr/ejjer/ejjejd ZngdZejd dkrZdZn dZ[d S(sSimple 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((s(/usr/lib64/python2.7/xml/sax/__init__.pyR s   cCsyddlm}Wn!tk r7ddlm}nX|dkrPt}nt}|j||j|t}|j |||j |dS(Ni(tStringIO( t cStringIORt ImportErrortNoneRRR R Rt setByteStreamR (tstringR RRRtinpsrc((s(/usr/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}||jkrfqfq tk req Xq WtdddS(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.iNsNo parsers found(tdefault_parser_listt_create_parserRtsystmodulesRR(t parser_listt parser_nameteR((s(/usr/lib64/python2.7/xml/sax/__init__.pyRGs   cCs2ddlm}|j|dt}|jS(Ni(timpi(torg.python.coreR"t importNametglobalst create_parser(R R"t drv_module((s(/usr/lib64/python2.7/xml/sax/__init__.pyRbscCs"t|iidg}|jS(NR&(t __import__R&(R R'((s(/usr/lib64/python2.7/xml/sax/__init__.pyRhs(t__doc__t xmlreaderRR RRt _exceptionsRRRRRR RRt_falsetxml.sax.expatreadertxmltosRtflagstignore_environmenttenvirontsplitt_keytplatformtregistryt containsKeyt getPropertyRR(((s(/usr/lib64/python2.7/xml/sax/__init__.pyts*( %   handler.py000064400000033142152527036000006536 0ustar00""" 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] xmlreader.py000064400000030614152527036000007105 0ustar00"""An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. """ from . 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): from . import saxutils source = saxutils.prepare_input_source(source) self.prepareParser(source) file = source.getCharacterStream() if file is None: 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 name not in self._attrs: raise KeyError(name) return name def getQNameByName(self, name): if name not in self._attrs: raise KeyError(name) return name def getNames(self): return list(self._attrs.keys()) def getQNames(self): return list(self._attrs.keys()) def __len__(self): return len(self._attrs) def __getitem__(self, name): return self._attrs[name] def keys(self): return list(self._attrs.keys()) 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 list(self._attrs.items()) def values(self): return list(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 list(self._qnames.values()) def copy(self): return self.__class__(self._attrs, self._qnames) def _test(): XMLReader() IncrementalParser() Locator() if __name__ == "__main__": _test() expatreader.pyc000064400000035505152527036000007575 0ustar00 {fc@s3dZdZddlTddlmZmZddlmZddlmZmZddlm Z ddlm Z m Z dd l Z e j d d kred en[ ydd lmZWn ek reden#Xeed redenddlmZmZmZejZejZydd lZWnek r_dZnXdd lZejZ[[dfdYZdejfdYZ dej!ejfdYZ"dZ#e$dkr/dd l%Z&e#Z'e'j(e&j)jj*e'j+e&j)j,e'j-dnd 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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt_mkproxy'st _ClosedParsercBseZRS((t__name__t __module__(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR.st ExpatLocatorcBs;eZdZdZdZdZdZdZRS(sLocator 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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt__init__9scCs&|j}|jdkrdS|jjS(N(Rt_parsertNonetErrorColumnNumber(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytgetColumnNumber<s cCs&|j}|jdkrdS|jjS(Ni(RRRtErrorLineNumber(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getLineNumberBs cCs&|j}|dkrdS|jjS(N(RRt_sourcet getPublicId(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR Hs  cCs&|j}|dkrdS|jjS(N(RRRt getSystemId(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR!Ns  (RRt__doc__RRRR R!(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR3s     t ExpatParsercBs.eZdZdd%dZdZdZdZd Zd Zd Z d Z dd Z dZ dZ dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd 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((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR2gs   cCsV|jdk rR|j}t|tr?|jd}n|jj|ndS(Nsutf-8(R!Rt isinstancetunicodetencodeRtSetBase(RR4tbase((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt prepareParserws  cCs-tjj|||jr)|jndS(N(R R$tsetContentHandlerR(t_reset_cont_handler(RR((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getFeatures      cCs|jrtdn|tkr0||_n|tkrH||_n|tkr|rx|jdkri|_qqd|_n||t kr|rtdqnX|t kr|rtdqn4|t kr|rtdqnt 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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt setFeatures2          cCs|tjkr|jS|tkr)|jS|tkr{|jrlt|jdr]|jjSt dq{t dnt 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>((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getPropertys      cCs||tjkr1||_|jrx|jqxnG|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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt setPropertys      cCs|js,|jd|_|jjny|jj||WnDtjk r}ttj |j ||}|j j |nXdS(Ni( R(R/R0t startDocumentRtParseR terrortSAXParseExceptiont ErrorStringtcodet _err_handlert fatalError(RtdatatisFinaltetexc((s+/usr/lib64/python2.7/xml/sax/expatreader.pytfeeds   cCs_|j}z)|j}|dk r1|jnWd|j}|dk rZ|jnXdS(N(RtgetCharacterStreamRtcloset getByteStream(RR4tfile((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR3s     cCs|js*|jdks*t|jtr.dSz6|jddd|jjd|_d|_Wdd|_|jdk rt}|jj |_ |jj |_ ||_n|j XdS(NtRSii( R)RRR5RRVR0t endDocumentR(RRR3(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRXs      cCs(|jj|j_|jj|j_dS(N(R0tprocessingInstructionRtProcessingInstructionHandlert characterstCharacterDataHandler(R((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRGs            cCsc|jr]tj|jjdd|j|_d|j_|j|j_ |j |j_ nBtj|jjd|j|_|j |j_ |j |j_ |j|j|j_|j|j_|j|j_|j|j_d|_|jr|jn|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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR/s6          cCs|jdkrdS|jjS(N(RRR(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR>scCs|jdkrdS|jjS(Ni(RRR(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRCscCs |jjS(N(RR (R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR HscCs |jjS(N(RR!(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR!KscCs|jj|t|dS(N(R0t startElementtAttributesImpl(RR>tattrs((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRtOscCs|jj|dS(N(R0t endElement(RR>((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRuRsc CsL|j}t|dkr-d|f}n5t|dkrV|d|df}n t|}i}i}x|jD]\}}|j}t|} | dkr|} d|f} nQ| dkrd|d|df} |d|df} n|d} t|} ||| <| || RtpairtnewattrstqnamestanameRHtpartstlengthtqnametapair((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRpUs.         cCsy|j}t|dkr-d|f}n5t|dkrV|d|df}n t|}|jj|ddS(Niii(RRRRR0t endElementNS(RR>R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRrws  cCs|jj||dS(N(R0R](RttargetRR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytprocessing_instructionscCs|jj|dS(N(R0R_(RRR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytcharacter_datascCs|jj||dS(N(R0tstartPrefixMapping(Rtprefixturi((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRzscCs|jj|dS(N(R0tendPrefixMapping(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR|scCs|jj|||dS(N(R'tstartDTD(RR>tsysidtpubidthas_internal_subset((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRiscCs|jj||||dS(N(t _dtd_handlertunparsedEntityDecl(RR>R9RRt notation_name((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRvscCs|jj|||dS(N(Rt notationDecl(RR>R9RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRxscCs|js dS|jj||}tj||jjp=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(RtcontextR9RRR4((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRs      cCs'|rd|}n|jj|dS(Nt%(R0t skippedEntity(RR>tis_pe((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRs ii("RRR"RR2R:R;R?RBRFRIRVR3RXR<RGR/RRR R!RtRuRpRrRRRzR|RiRvRxRR(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR#Ws@          '       "        cOs t||S(N(R#(targstkwargs((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt create_parserst__main__s:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml(.R"tversiontxml.sax._exceptionstxml.sax.handlerRRRRRRRRtsystplatformtSAXReaderNotAvailableRt xml.parsersR t ImportErrorREtxml.saxR R RRRt_weakrefRtweakreftproxyRtLocatorRR$R#RRtxml.sax.saxutilstxmltpR;tsaxt XMLGeneratortsetErrorHandlert ErrorHandlerR2(((s+/usr/lib64/python2.7/xml/sax/expatreader.pytsL         $a    expatreader.pyo000064400000035505152527036000007611 0ustar00 {fc@s3dZdZddlTddlmZmZddlmZddlmZmZddlm Z ddlm Z m Z dd l Z e j d d kred en[ ydd lmZWn ek reden#Xeed redenddlmZmZmZejZejZydd lZWnek r_dZnXdd lZejZ[[dfdYZdejfdYZ dej!ejfdYZ"dZ#e$dkr/dd l%Z&e#Z'e'j(e&j)jj*e'j+e&j)j,e'j-dnd 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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt_mkproxy'st _ClosedParsercBseZRS((t__name__t __module__(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR.st ExpatLocatorcBs;eZdZdZdZdZdZdZRS(sLocator 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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt__init__9scCs&|j}|jdkrdS|jjS(N(Rt_parsertNonetErrorColumnNumber(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytgetColumnNumber<s cCs&|j}|jdkrdS|jjS(Ni(RRRtErrorLineNumber(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getLineNumberBs cCs&|j}|dkrdS|jjS(N(RRt_sourcet getPublicId(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR Hs  cCs&|j}|dkrdS|jjS(N(RRRt getSystemId(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR!Ns  (RRt__doc__RRRR R!(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR3s     t ExpatParsercBs.eZdZdd%dZdZdZdZd Zd Zd Z d Z dd Z dZ dZ dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd 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((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR2gs   cCsV|jdk rR|j}t|tr?|jd}n|jj|ndS(Nsutf-8(R!Rt isinstancetunicodetencodeRtSetBase(RR4tbase((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt prepareParserws  cCs-tjj|||jr)|jndS(N(R R$tsetContentHandlerR(t_reset_cont_handler(RR((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getFeatures      cCs|jrtdn|tkr0||_n|tkrH||_n|tkr|rx|jdkri|_qqd|_n||t kr|rtdqnX|t kr|rtdqn4|t kr|rtdqnt 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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt setFeatures2          cCs|tjkr|jS|tkr)|jS|tkr{|jrlt|jdr]|jjSt dq{t dnt 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>((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt getPropertys      cCs||tjkr1||_|jrx|jqxnG|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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt setPropertys      cCs|js,|jd|_|jjny|jj||WnDtjk r}ttj |j ||}|j j |nXdS(Ni( R(R/R0t startDocumentRtParseR terrortSAXParseExceptiont ErrorStringtcodet _err_handlert fatalError(RtdatatisFinaltetexc((s+/usr/lib64/python2.7/xml/sax/expatreader.pytfeeds   cCs_|j}z)|j}|dk r1|jnWd|j}|dk rZ|jnXdS(N(RtgetCharacterStreamRtcloset getByteStream(RR4tfile((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR3s     cCs|js*|jdks*t|jtr.dSz6|jddd|jjd|_d|_Wdd|_|jdk rt}|jj |_ |jj |_ ||_n|j XdS(NtRSii( R)RRR5RRVR0t endDocumentR(RRR3(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRXs      cCs(|jj|j_|jj|j_dS(N(R0tprocessingInstructionRtProcessingInstructionHandlert characterstCharacterDataHandler(R((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRGs            cCsc|jr]tj|jjdd|j|_d|j_|j|j_ |j |j_ nBtj|jjd|j|_|j |j_ |j |j_ |j|j|j_|j|j_|j|j_|j|j_d|_|jr|jn|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((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR/s6          cCs|jdkrdS|jjS(N(RRR(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR>scCs|jdkrdS|jjS(Ni(RRR(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRCscCs |jjS(N(RR (R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR HscCs |jjS(N(RR!(R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR!KscCs|jj|t|dS(N(R0t startElementtAttributesImpl(RR>tattrs((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRtOscCs|jj|dS(N(R0t endElement(RR>((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRuRsc CsL|j}t|dkr-d|f}n5t|dkrV|d|df}n t|}i}i}x|jD]\}}|j}t|} | dkr|} d|f} nQ| dkrd|d|df} |d|df} n|d} t|} ||| <| || RtpairtnewattrstqnamestanameRHtpartstlengthtqnametapair((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRpUs.         cCsy|j}t|dkr-d|f}n5t|dkrV|d|df}n t|}|jj|ddS(Niii(RRRRR0t endElementNS(RR>R((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRrws  cCs|jj||dS(N(R0R](RttargetRR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytprocessing_instructionscCs|jj|dS(N(R0R_(RRR((s+/usr/lib64/python2.7/xml/sax/expatreader.pytcharacter_datascCs|jj||dS(N(R0tstartPrefixMapping(Rtprefixturi((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRzscCs|jj|dS(N(R0tendPrefixMapping(RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR|scCs|jj|||dS(N(R'tstartDTD(RR>tsysidtpubidthas_internal_subset((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRiscCs|jj||||dS(N(t _dtd_handlertunparsedEntityDecl(RR>R9RRt notation_name((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRvscCs|jj|||dS(N(Rt notationDecl(RR>R9RR((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRxscCs|js dS|jj||}tj||jjp=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(RtcontextR9RRR4((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRs      cCs'|rd|}n|jj|dS(Nt%(R0t skippedEntity(RR>tis_pe((s+/usr/lib64/python2.7/xml/sax/expatreader.pyRs ii("RRR"RR2R:R;R?RBRFRIRVR3RXR<RGR/RRR R!RtRuRpRrRRRzR|RiRvRxRR(((s+/usr/lib64/python2.7/xml/sax/expatreader.pyR#Ws@          '       "        cOs t||S(N(R#(targstkwargs((s+/usr/lib64/python2.7/xml/sax/expatreader.pyt create_parserst__main__s:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml(.R"tversiontxml.sax._exceptionstxml.sax.handlerRRRRRRRRtsystplatformtSAXReaderNotAvailableRt xml.parsersR t ImportErrorREtxml.saxR R RRRt_weakrefRtweakreftproxyRtLocatorRR$R#RRtxml.sax.saxutilstxmltpR;tsaxt XMLGeneratortsetErrorHandlert ErrorHandlerR2(((s+/usr/lib64/python2.7/xml/sax/expatreader.pytsL         $a    __init__.pyo000064400000007241152527036000007040 0ustar00 {fc@sjdZddlmZddlmZmZddlmZmZm Z m Z m Z edZ edZ dgZdZerdd lZndd lZdd lZejj rd ejkrejd jd Zn[d Zejd dkr/ejjer/ejjejd ZngdZejd dkrZdZn dZ[d S(sSimple 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((s(/usr/lib64/python2.7/xml/sax/__init__.pyR s   cCsyddlm}Wn!tk r7ddlm}nX|dkrPt}nt}|j||j|t}|j |||j |dS(Ni(tStringIO( t cStringIORt ImportErrortNoneRRR R Rt setByteStreamR (tstringR RRRtinpsrc((s(/usr/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}||jkrfqfq tk req Xq WtdddS(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.iNsNo parsers found(tdefault_parser_listt_create_parserRtsystmodulesRR(t parser_listt parser_nameteR((s(/usr/lib64/python2.7/xml/sax/__init__.pyRGs   cCs2ddlm}|j|dt}|jS(Ni(timpi(torg.python.coreR"t importNametglobalst create_parser(R R"t drv_module((s(/usr/lib64/python2.7/xml/sax/__init__.pyRbscCs"t|iidg}|jS(NR&(t __import__R&(R R'((s(/usr/lib64/python2.7/xml/sax/__init__.pyRhs(t__doc__t xmlreaderRR RRt _exceptionsRRRRRR RRt_falsetxml.sax.expatreadertxmltosRtflagstignore_environmenttenvirontsplitt_keytplatformtregistryt containsKeyt getPropertyRR(((s(/usr/lib64/python2.7/xml/sax/__init__.pyts*( %   expatreader.py000064400000036530152527036000007431 0ustar00""" 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 = 0 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: self._parser.SetBase(source.getSystemId()) # 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 as 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") saxutils.pyc000064400000034721152527036000007144 0ustar00 {fc@s-dZddlZddlZddlZddlZddlZddlZddlZddlZyej ej gZ Wne k rej gZ nXdZ idZidZidZdZdejfd YZd ejfd YZd ejfd YZddZdS(snA library of useful helper classes to the SAX classes, for the convenience of application and driver writers. iNcCs3x,|jD]\}}|j||}q W|S(s2Replace substrings of a string using a dictionary.(titemstreplace(tstdtkeytvalue((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt__dict_replacescCsR|jdd}|jdd}|jdd}|rNt||}n|S(sEscape &, <, 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 ((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt quoteattr5s "    cCs|dkr$ddl}|j}nt|tjrTtj|}d|_nTtj}d|_|j |_ y|j |_ |j |_ Wnt k rnXt |d|ddddS( NicSsdS(N(tNone(((s(/usr/lib64/python2.7/xml/sax/saxutils.pytVtcSstS(N(tTrue(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR[Rtencodingterrorstxmlcharrefreplacetnewlines (Rtsyststdoutt isinstancetiot RawIOBasetBufferedIOBasetclosetwritabletwritetseekablettelltAttributeErrort_UnbufferedTextIOWrapper(toutRRtbuffer((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt_gettextwriterMs"        R'cBseZdZRS(cCs$tt|j||jdS(N(tsuperR'R#tflush(tselfR((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR#ks(t__name__t __module__R#(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR'jst XMLGeneratorcBseZdddZdZdZdZdZdZdZ dZ 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((s(/usr/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((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt_qname|s  cCs|jd|jdS(Nu$ (R4R9(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt startDocuments cCs|jdS(N(R5(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endDocumentscCs@|jj|jj||j|<|jj||fdS(N(R6tappendR7RR8(R-R<turi((s(/usr/lib64/python2.7/xml/sax/saxutils.pytstartPrefixMappings cCs|jd|_|jd=dS(Ni(R6R7(R-R<((s(/usr/lib64/python2.7/xml/sax/saxutils.pytendPrefixMappingscCs\|jd|x7|jD])\}}|jd|t|fqW|jddS(Nu(R4RR(R-R;tattrsR((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt startElements!cCs|jd|dS(Nu(R4(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endElementscCs|jd|j|xH|jD]=\}}|rP|jd||fq$|jd|q$Wg|_x@|jD]2\}}|jd|j|t|fq{W|jddS(Nu(R4R=R8RR(R-R;tqnameRDR<RAR((s(/usr/lib64/python2.7/xml/sax/saxutils.pytstartElementNSs *cCs|jd|j|dS(Nu(R4R=(R-R;RG((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt endElementNSscCs;t|ts$t||j}n|jt|dS(N(RtunicodeR9R4R (R-tcontent((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt charactersscCs5t|ts$t||j}n|j|dS(N(RRJR9R4(R-RK((s(/usr/lib64/python2.7/xml/sax/saxutils.pytignorableWhitespacescCs|jd||fdS(Nu (R4(R-ttargetR ((s(/usr/lib64/python2.7/xml/sax/saxutils.pytprocessingInstructionsN(R.R/RR3R=R>R?RBRCRERFRHRIRLRMRO(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR0ps           t XMLFilterBasecBs eZdZddZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(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((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR3scCs|jj|dS(N(t _err_handlerterror(R-t exception((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRVscCs|jj|dS(N(RUt fatalError(R-RW((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRXscCs|jj|dS(N(RUtwarning(R-RW((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRYscCs|jj|dS(N(t _cont_handlertsetDocumentLocator(R-tlocator((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR[scCs|jjdS(N(RZR>(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR>scCs|jjdS(N(RZR?(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR?scCs|jj||dS(N(RZRB(R-R<RA((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRBscCs|jj|dS(N(RZRC(R-R<((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRCscCs|jj||dS(N(RZRE(R-R;RD((s(/usr/lib64/python2.7/xml/sax/saxutils.pyREscCs|jj|dS(N(RZRF(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRFscCs|jj|||dS(N(RZRH(R-R;RGRD((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRHscCs|jj||dS(N(RZRI(R-R;RG((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRIscCs|jj|dS(N(RZRL(R-RK((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRLscCs|jj|dS(N(RZRM(R-tchars((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRMscCs|jj||dS(N(RZRO(R-RNR ((s(/usr/lib64/python2.7/xml/sax/saxutils.pyROscCs|jj|dS(N(RZt skippedEntity(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR^scCs|jj|||dS(N(t _dtd_handlert notationDecl(R-R;tpublicIdtsystemId((s(/usr/lib64/python2.7/xml/sax/saxutils.pyR` scCs|jj||||dS(N(R_tunparsedEntityDecl(R-R;RaRbtndata((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRc scCs|jj||S(N(t _ent_handlert resolveEntity(R-RaRb((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRfscCsT|jj||jj||jj||jj||jj|dS(N(RStsetContentHandlertsetErrorHandlertsetEntityResolvert setDTDHandlertparse(R-tsource((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRks cCs|jj|dS(N(RSt setLocale(R-tlocale((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRmscCs|jj|S(N(RSt getFeature(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRo scCs|jj||dS(N(RSt setFeature(R-R;tstate((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRp#scCs|jj|S(N(RSt getProperty(R-R;((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRr&scCs|jj||dS(N(RSt setProperty(R-R;R((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRs)scCs|jS(N(RS(R-((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt getParent.scCs ||_dS(N(RS(R-RT((s(/usr/lib64/python2.7/xml/sax/saxutils.pyt setParent1sN( R.R/t__doc__RR3RVRXRYR[R>R?RBRCRERFRHRIRLRMROR^R`RcRfRkRmRoRpRrRsRtRu(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyRPs:                           RcCst|tkr$tj|}nSt|drw|}tj}|j|t|drw|j|jqwn|jdkry|j }t j j t j j|}tj}t|trt|tsdy|j|}Wqtk r|j|}qXqdnHt|trdy|j|}Wqdtk r`|j|}qdXnt j j||}t j j|}Wntk rt}nX|r|j|t|d}n4|jtj||j tj|j }|j|n|S(sThis 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((s(/usr/lib64/python2.7/xml/sax/saxutils.pytprepare_input_source6sF         (RvRRRttypesRRR1RQt StringTypet UnicodeTypeRzR&RR R RR*t TextIOWrapperR'R2R0RRRPR(((s(/usr/lib64/python2.7/xml/sax/saxutils.pyts$0          Wo__init__.py000064400000007056152527036000006665 0ustar00"""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()): import io if errorHandler is None: errorHandler = ErrorHandler() parser = make_parser() parser.setContentHandler(handler) parser.setErrorHandler(errorHandler) inpsrc = InputSource() if isinstance(string, str): inpsrc.setCharacterStream(io.StringIO(string)) else: inpsrc.setByteStream(io.BytesIO(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 as 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 xmlreader.pyc000064400000045426152527036000007257 0ustar00 {fc@sdZddlZddlmZmZdddYZdefdYZddd YZd dd YZd dd YZ de fdYZ dZ e dkre ndS(s]An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. iN(tSAXNotSupportedExceptiontSAXNotRecognizedExceptiont XMLReadercBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZRS(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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt__init__scCstddS(sAParse an XML document from a system identifier or an InputSource.s This method must be implemented!N(tNotImplementedError(R tsource((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytparsescCs|jS(s#Returns the current ContentHandler.(R(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetContentHandler"scCs ||_dS(s:Registers a new object to receive document content events.N(R(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytsetContentHandler&scCs|jS(s Returns the current DTD handler.(R(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getDTDHandler*scCs ||_dS(s7Register an object to receive basic DTD-related events.N(R(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setDTDHandler.scCs|jS(s#Returns the current EntityResolver.(R (R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetEntityResolver2scCs ||_dS(s0Register an object to resolve external entities.N(R (R tresolver((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytsetEntityResolver6scCs|jS(s!Returns the current ErrorHandler.(R (R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetErrorHandler:scCs ||_dS(s3Register an object to receive error-message events.N(R (R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytsetErrorHandler>scCstddS(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((s)/usr/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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getFeatureKscCstd|dS(s!Sets the state of a SAX2 feature.sFeature '%s' not recognizedN(R(R Rtstate((s)/usr/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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getPropertySscCstd|dS(s"Sets the value of a SAX2 property.sProperty '%s' not recognizedN(R(R Rtvalue((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setPropertyWs(t__name__t __module__t__doc__R RRRRRRRRRRRRR R"(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR s               tIncrementalParsercBsGeZdZd dZdZdZdZdZdZRS( 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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR os cCsddl}|j|}|j||j}|j|j}x/|dkrw|j||j|j}qIW|jdS(Nit(tsaxutilstprepare_input_sourcet prepareParsert getByteStreamtreadR'tfeedtclose(R RR*tfiletbuffer((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRss    cCstddS(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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR/scCstddS(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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR,scCstddS(sThis 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 ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR0s cCstddS(sThis 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 ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytresetsi( R#R$R%R RR/R,R0R4(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR&[s   tLocatorcBs2eZdZdZdZdZdZRS(sInterface 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 ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetColumnNumberscCsdS(s4Return the line number where the current event ends.i((R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getLineNumberscCsdS(s3Return the public identifier for the current event.N(tNone(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getPublicIdscCsdS(s3Return the system identifier for the current event.N(R8(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getSystemIds(R#R$R%R6R7R9R:(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR5s    t InputSourcecBsteZdZd dZdZdZdZdZdZ dZ dZ 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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR s     cCs ||_dS(s/Sets the public identifier of this InputSource.N(R=(R t public_id((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setPublicIdscCs|jS(s2Returns the public identifier of this InputSource.(R=(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR9scCs ||_dS(s/Sets the system identifier of this InputSource.N(R<(R RA((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setSystemIdscCs|jS(s2Returns the system identifier of this InputSource.(R<(R ((s)/usr/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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setEncodingscCs|jS(s/Get the character encoding of this InputSource.(R>(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getEncodingscCs ||_dS(sSet 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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt setByteStreams cCs|jS(sGet 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 ((s)/usr/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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytsetCharacterStreamscCs|jS(s/Get the character stream for this input source.(R@(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetCharacterStreamsN(R#R$R%R8R RCR9RDR:RFRGRIR-RKRL(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR;s        tAttributesImplcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZddZdZdZdZRS(cCs ||_dS(sQNon-NS-aware implementation. attrs should be of the form {name : value}.N(t_attrs(R tattrs((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR scCs t|jS(N(tlenRN(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getLengthscCsdS(NtCDATA((R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetTypescCs |j|S(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetValue"scCs |j|S(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetValueByQName%scCs||jkrt|n|S(N(RNtKeyError(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetNameByQName(s cCs||jkrt|n|S(N(RNRV(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetQNameByName-s cCs |jjS(N(RNtkeys(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytgetNames2scCs |jjS(N(RNRY(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt getQNames5scCs t|jS(N(RPRN(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt__len__8scCs |j|S(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt __getitem__;scCs |jjS(N(RNRY(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRY>scCs ||jkS(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pythas_keyAscCs ||jkS(N(RN(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt __contains__DscCs|jj||S(N(RNtget(R Rt alternative((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR`GscCs|j|jS(N(t __class__RN(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pytcopyJscCs |jjS(N(RNtitems(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRdMscCs |jjS(N(RNtvalues(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRePsN(R#R$R RQRSRTRURWRXRZR[R\R]RYR^R_R8R`RcRdRe(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRMs$                 tAttributesNSImplcBs>eZdZdZdZdZdZdZRS(cCs||_||_dS(sNS-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((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR Ws cCsDx4|jjD]#\}}||kr|j|SqWt|dS(N(RgRdRNRV(R Rtnsnametqname((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRU_s cCs=x-|jjD]\}}||kr|SqWt|dS(N(RgRdRV(R RRiRj((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRWfs cCs |j|S(N(Rg(R R((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRXmscCs |jjS(N(RgRe(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyR[pscCs|j|j|jS(N(RbRNRg(R ((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRcss(R#R$R RURWRXR[Rc(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyRfUs      cCstttdS(N(RR&R5(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyt_testwst__main__((((( R%Rt _exceptionsRRRR&R5R;RMRfRkR#(((s)/usr/lib64/python2.7/xml/sax/xmlreader.pyts PHYA"  _exceptions.pyo000064400000014031152527036000007614 0ustar00 {fc@sdZddlZejd dkr8ddlmZn[defdYZdefd YZd efd YZd efd YZdefdYZ dS(s!Different kinds of SAX ExceptionsiNitjava(t Exceptiont SAXExceptioncBs>eZdZddZdZdZdZdZRS(sEncapsulate 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((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyRs  cCs|jS(s$Return a message for this exception.(R(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyt getMessagescCs|jS(s9Return the embedded exception, or None if there was none.(R(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyt getExceptionscCs|jS(s0Create a string representation of the exception.(R(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyt__str__"scCstddS(svAvoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined.t __getitem__N(tAttributeError(Rtix((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR &sN( t__name__t __module__t__doc__tNoneRR R R R (((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR s     tSAXParseExceptioncBsDeZdZdZdZdZdZdZdZRS(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((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyRHscCs|jS(sDThe line number of the end of the text where the exception occurred.(R(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyRMscCs |jjS(sEGet the public identifier of the entity where the exception occurred.(Rt getPublicId(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyRQscCs|jS(sEGet the system identifier of the entity where the exception occurred.(R(R((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR Ys         ( RRRRRRRRR (((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR.s     tSAXNotRecognizedExceptioncBseZdZRS(sException 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(((s+/usr/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(((s+/usr/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(((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR#}s( Rtsystplatformt java.langRRRR!R"R#(((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyts %;  _exceptions.pyc000064400000014031152527036000007600 0ustar00 {fc@sdZddlZejd dkr8ddlmZn[defdYZdefd YZd efd YZd efd YZdefdYZ dS(s!Different kinds of SAX ExceptionsiNitjava(t Exceptiont SAXExceptioncBs>eZdZddZdZdZdZdZRS(sEncapsulate 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((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyRs  cCs|jS(s$Return a message for this exception.(R(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyt getMessagescCs|jS(s9Return the embedded exception, or None if there was none.(R(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyt getExceptionscCs|jS(s0Create a string representation of the exception.(R(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyt__str__"scCstddS(svAvoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined.t __getitem__N(tAttributeError(Rtix((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR &sN( t__name__t __module__t__doc__tNoneRR R R R (((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR s     tSAXParseExceptioncBsDeZdZdZdZdZdZdZdZRS(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((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyRHscCs|jS(sDThe line number of the end of the text where the exception occurred.(R(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyRMscCs |jjS(sEGet the public identifier of the entity where the exception occurred.(Rt getPublicId(R((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyRQscCs|jS(sEGet the system identifier of the entity where the exception occurred.(R(R((s+/usr/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((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR Ys         ( RRRRRRRRR (((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR.s     tSAXNotRecognizedExceptioncBseZdZRS(sException 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(((s+/usr/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(((s+/usr/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(((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyR#}s( Rtsystplatformt java.langRRRR!R"R#(((s+/usr/lib64/python2.7/xml/sax/_exceptions.pyts %;  __pycache__/expatreader.cpython-36.pyc000064400000030153152527044710013717 0ustar003 \X=@sdZdZddlTddlmZmZddlmZddlmZmZddlm Z ddlm Z m Z dd l Z e j d d d kr|ed d [ ydd lmZWnek redd YnXeedsedd ddlmZmZmZejZejZy dd lZWnek r ddZYnXdd lZejZ[[GdddZGdddejZGdddej ejZ!ddZ"e#dkrdd l$Z%e"Z&e&j'e%j(jj)e&j*e%j(j+e&j,dd S)z] SAX driver for the pyexpat C module. This driver works with pyexpat.__version__ == '2.22'. z0.20)*)feature_validationfeature_namespaces)feature_namespace_prefixes)feature_external_gesfeature_external_pes)feature_string_interning)property_xml_stringproperty_interning_dictNjavazexpat not available in Java)expatzexpat not supported ParserCreate) xmlreadersaxutilshandlercCs|S)N)orr+/usr/lib64/python3.6/xml/sax/expatreader.py_mkproxy'src@s eZdZdS) _ClosedParserN)__name__ __module__ __qualname__rrrrr.src@s8eZdZdZddZddZddZdd Zd d Zd S) ExpatLocatorzLocator 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)r_ref)selfparserrrr__init__9szExpatLocator.__init__cCs|j}|jdkrdS|jjS)N)r_parserErrorColumnNumber)rrrrrgetColumnNumber<s zExpatLocator.getColumnNumbercCs|j}|jdkrdS|jjS)N)rrErrorLineNumber)rrrrr getLineNumberBs zExpatLocator.getLineNumbercCs|j}|dkrdS|jjS)N)r_source getPublicId)rrrrrr&HszExpatLocator.getPublicIdcCs|j}|dkrdS|jjS)N)rr% getSystemId)rrrrrr'NszExpatLocator.getSystemIdN) rrr__doc__rr!r$r&r'rrrrr3s rc@s eZdZdZdGddZdd Zd d Zd d ZddZddZ ddZ ddZ dHddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z d@dAZ!dBdCZ"dDS)I ExpatParserz$SAX driver for the pyexpat C module.rcCsFtjj||tj|_d|_||_d|_d|_g|_ d|_ d|_ dS)Nr) rIncrementalParserrZ InputSourcer%r _namespaces_lex_handler_prop_parsing _entity_stack _external_ges _interning)rZnamespaceHandlingbufsizerrrrZs zExpatParser.__init__c CsVtj|}||_y*|j|jjt|tjj ||Wn|j YnXdS)z3Parse an XML document from a URL or an InputSource.N) rprepare_input_sourcer%reset _cont_handlerZsetDocumentLocatorrrr-parse _close_source)rsourcerrrr8gs zExpatParser.parsecCs |jdk r|jj|jdS)N)r'rZSetBase)rr:rrr prepareParserws zExpatParser.prepareParsercCs tjj|||jr|jdS)N)rr-setContentHandlerr0_reset_cont_handler)rrrrrr<}szExpatParser.setContentHandlercCsP|tkr|jS|tkr |jdk S|tttfkr2dS|tkr@|jSt d|dS)NrzFeature '%s' not recognized) rr.rr3rrrrr2SAXNotRecognizedException)rnamerrr getFeatures zExpatParser.getFeaturecCs|jrtd|tkr||_n|tkr.||_nt|tkrT|rL|jdkrRi|_qd|_nN|tkrj|rtdn8|t kr|rtdn"|t kr|rtdn t d|dS)Nz!Cannot set features while parsingz!expat does not support validationz/expat does not read external parameter entitiesz(expat does not report namespace prefixeszFeature '%s' not recognized) r0SAXNotSupportedExceptionrr.rr2rr3rrrr>)rr?staterrr setFeatures2 zExpatParser.setFeaturecCsd|tjkr|jS|tkr|jS|tkrT|jrLt|jdrB|jjSt dnt dt d|dS)NGetInputContextz=This version of expat does not support getting the XML stringz.XML string cannot be returned when not parsingzProperty '%s' not recognized) rproperty_lexical_handlerr/r r3r rhasattrrDr>rA)rr?rrr getPropertys   zExpatParser.getPropertycCsV|tjkr ||_|jrR|jn2|tkr0||_n"|tkrFtd|n t d|dS)NzProperty '%s' cannot be setzProperty '%s' not recognized) rrEr/r0_reset_lex_handler_propr r3r rAr>)rr?valuerrr setPropertys   zExpatParser.setPropertycCsz|js|jd|_|jjy|jj||WnDtjk rt}z&ttj |j ||}|j j |WYdd}~XnXdS)Nr") r0r6r7Z startDocumentrZParser errorZSAXParseExceptionZ ErrorStringcodeZ _err_handlerZ fatalError)rdataisFinaleexcrrrfeeds zExpatParser.feedc CsB|j}z|j}|dk r |jWd|j}|dk r<|jXdS)N)r%ZgetCharacterStreamcloseZ getByteStream)rr:filerrrr9s zExpatParser._close_sourcec Cs|js|jdkst|jtr dSz(|jddd|jjd|_d|_Wdd|_|jdk rzt}|jj|_|jj |_ ||_|j XdS)Nr")rNr) r1r isinstancerrQr7Z endDocumentr0r r#r9)rrrrrrRs      zExpatParser.closecCs|jj|j_|jj|j_dS)N)r7processingInstructionrZProcessingInstructionHandler charactersZCharacterDataHandler)rrrrr=s zExpatParser._reset_cont_handlercCs`|j}|j}|dkr4d|_d|_d|_d|_d|_n(|j|_|j|_|j |_|j |_|j |_dS)N) r/rZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ startCDATAZendCDATAstart_doctype_declZendDTD)rZlexrrrrrHsz#ExpatParser._reset_lex_handler_propc Cs|jr>tj|jjd|jd|_d|j_|j|j_ |j |j_ n,tj|jj|jd|_|j |j_ |j |j_ |j|j|j_|j|j_|j|j_|j|j_d|_|jr|j|j|j_y|j|j_Wntk rYnX|jjtj d|_!g|_"dS)N )internr"r)#r.r rr%Z getEncodingr3rZnamespace_prefixesstart_element_nsZStartElementHandlerend_element_nsZEndElementHandler start_element end_elementr=unparsed_entity_declZUnparsedEntityDeclHandler notation_declZNotationDeclHandlerstart_namespace_declZStartNamespaceDeclHandlerend_namespace_declZEndNamespaceDeclHandlerZ_decl_handler_propr/rHexternal_entity_refZExternalEntityRefHandlerskipped_entity_handlerZSkippedEntityHandlerAttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr0r1)rrrrr6s6            zExpatParser.resetcCs|jdkrdS|jjS)N)rr )rrrrr!;s zExpatParser.getColumnNumbercCs|jdkrdS|jjS)Nr")rr#)rrrrr$@s zExpatParser.getLineNumbercCs |jjS)N)r%r&)rrrrr&EszExpatParser.getPublicIdcCs |jjS)N)r%r')rrrrr'HszExpatParser.getSystemIdcCs|jj|t|dS)N)r7Z startElementAttributesImpl)rr?attrsrrrr]LszExpatParser.start_elementcCs|jj|dS)N)r7Z endElement)rr?rrrr^OszExpatParser.end_elementc Cs|j}t|dkrd|f}n&t|dkr<|d|df}nt|}i}i}x|jD]|\}}|j}t|} | dkr|} d|f} n>| dkrd|d|df} |d|df} n|d} t|} ||| <| || <qVW|jj|dt||dS)Nr"rz%s:%sr*)splitlentupleitemsr7ZstartElementNSAttributesNSImpl) rr?rgpairZnewattrsZqnamesZanamerIpartsZlengthZqnameZapairrrrr[Rs.      zExpatParser.start_element_nscCsV|j}t|dkrd|f}n&t|dkr<|d|df}nt|}|jj|ddS)Nr"rhr)rirjrkr7Z endElementNS)rr?rnrrrr\ts   zExpatParser.end_element_nscCs|jj||dS)N)r7rV)rtargetrMrrrprocessing_instructionsz"ExpatParser.processing_instructioncCs|jj|dS)N)r7rW)rrMrrrcharacter_dataszExpatParser.character_datacCs|jj||dS)N)r7ZstartPrefixMapping)rprefixZurirrrrasz ExpatParser.start_namespace_declcCs|jj|dS)N)r7ZendPrefixMapping)rrsrrrrbszExpatParser.end_namespace_declcCs|jj|||dS)N)r/ZstartDTD)rr?sysidpubidZhas_internal_subsetrrrrXszExpatParser.start_doctype_declcCs|jj||||dS)N) _dtd_handlerZunparsedEntityDecl)rr?basertruZ notation_namerrrr_sz ExpatParser.unparsed_entity_declcCs|jj|||dS)N)rvZ notationDecl)rr?rwrtrurrrr`szExpatParser.notation_declc Cs|js dS|jj||}tj||jjp*d}|jj|j |jf|j j ||_ ||_yt j j ||Wn dS|jd\|_ |_|jd=dS)Nr"rTrrx)r2Z _ent_handlerZ resolveEntityrr5r%r'r1appendrZExternalEntityParserCreaterr-r8)rcontextrwrtrur:rrrrcs  zExpatParser.external_entity_refcCs|r d|}|jj|dS)N%)r7Z skippedEntity)rr?Zis_perrrrdsz"ExpatParser.skipped_entity_handlerNi)rr|)r)#rrrr(rr8r;r<r@rCrGrJrQr9rRr=rHr6r!r$r&r'r]r^r[r\rqrrrarbrXr_r`rcrdrrrrr)Ws@    '" r)cOs t||S)N)r))argskwargsrrr create_parsersr__main__z:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml)-r(versionZxml.sax._exceptionsZxml.sax.handlerrrrrrrr r sysplatformZSAXReaderNotAvailableZ xml.parsersr ImportErrorrFZxml.saxrrrrfrm_weakrefrweakrefproxyrZLocatorrr-r)rrZxml.sax.saxutilsZxmlpr<ZsaxZ XMLGeneratorZsetErrorHandlerZ ErrorHandlerr8rrrrsN      $_ __pycache__/_exceptions.cpython-36.pyc000064400000012533152527044710013735 0ustar003 \@sdZddlZejdddkr*ddlmZ[GdddeZGdd d eZGd d d eZGd d d eZGdddeZ dS)z!Different kinds of SAX ExceptionsNjava) Exceptionc@s:eZdZdZd ddZddZddZd d Zd d ZdS) SAXExceptionaEncapsulate 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.NcCs||_||_tj||dS)zUCreates an exception. The message is required, but the exception is optional.N)_msg _exceptionr__init__)selfmsg exceptionr +/usr/lib64/python3.6/xml/sax/_exceptions.pyrszSAXException.__init__cCs|jS)z$Return a message for this exception.)r)r r r r getMessageszSAXException.getMessagecCs|jS)z9Return the embedded exception, or None if there was none.)r)r r r r getExceptionszSAXException.getExceptioncCs|jS)z0Create a string representation of the exception.)r)r r r r __str__"szSAXException.__str__cCs tddS)zvAvoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined. __getitem__N)AttributeError)r Zixr r r r&szSAXException.__getitem__)N) __name__ __module__ __qualname____doc__rrrrrr r r r r s  rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)SAXParseExceptiona#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.cCs<tj|||||_|jj|_|jj|_|jj|_dS)zECreates the exception. The exception parameter is allowed to be None.N) rr_locator getSystemId _systemIdgetColumnNumber_colnum getLineNumber_linenum)r r r Zlocatorr r r r;s   zSAXParseException.__init__cCs|jS)zNThe column number of the end of the text where the exception occurred.)r)r r r r rHsz!SAXParseException.getColumnNumbercCs|jS)zDThe line number of the end of the text where the exception occurred.)r)r r r r rMszSAXParseException.getLineNumbercCs |jjS)zEGet the public identifier of the entity where the exception occurred.)r getPublicId)r r r r rQszSAXParseException.getPublicIdcCs|jS)zEGet the system identifier of the entity where the exception occurred.)r)r r r r rUszSAXParseException.getSystemIdcCsN|j}|dkrd}|j}|dkr(d}|j}|dkr?z %s:%s:%s: %s)rrrr)r ZsysidZlinenumZcolnumr r r rYszSAXParseException.__str__N) rrrrrrrrrrr r r r r.s  rc@seZdZdZdS)SAXNotRecognizedExceptionzException 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.N)rrrrr r r r r!isr!c@seZdZdZdS)SAXNotSupportedExceptionaException 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.N)rrrrr r r r r"ssr"c@seZdZdZdS)SAXReaderNotAvailableaException 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.N)rrrrr r r r r#}sr#) rsysplatformZ java.langrrrr!r"r#r r r r s %;  __pycache__/handler.cpython-36.pyc000064400000030033152527044710013025 0ustar003 \b6@sdZdZGdddZGdddZGdddZGdd d Zd Zd Zd Zd Z dZ dZ eeee e e gZ dZ dZdZdZdZdZe eeeeegZdS)a0 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$ z2.0betac@s(eZdZdZddZddZddZdS) ErrorHandleraBasic 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)zHandle a recoverable error.N)self exceptionrr'/usr/lib64/python3.6/xml/sax/handler.pyerror szErrorHandler.errorcCs|dS)zHandle a non-recoverable error.Nr)rrrrr fatalError$szErrorHandler.fatalErrorcCs t|dS)zHandle a warning.N)print)rrrrrwarning(szErrorHandler.warningN)__name__ __module__ __qualname____doc__rrr rrrrrsrc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZdS)ContentHandlerzInterface 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)_locator)rrrr__init__6szContentHandler.__init__cCs ||_dS)a#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)rZlocatorrrrsetDocumentLocator9sz!ContentHandler.setDocumentLocatorcCsdS)zReceive 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).Nr)rrrr startDocumentPszContentHandler.startDocumentcCsdS)aQReceive 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.Nr)rrrr endDocumentWszContentHandler.endDocumentcCsdS)aBegin 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.Nr)rprefixZurirrrstartPrefixMapping`sz!ContentHandler.startPrefixMappingcCsdS)zEnd 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.Nr)rrrrrendPrefixMappingwszContentHandler.endPrefixMappingcCsdS)aSignals 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.Nr)rnameattrsrrr startElement~szContentHandler.startElementcCsdS)zSignals 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.Nr)rrrrr endElementszContentHandler.endElementcCsdS)aSignals 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.Nr)rrqnamerrrrstartElementNSszContentHandler.startElementNScCsdS)zSignals the end of an element in namespace mode. The name parameter contains the name of the element type, just as with the startElementNS event.Nr)rrrrrr endElementNSszContentHandler.endElementNScCsdS)aReceive 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.Nr)rZcontentrrr charactersszContentHandler.characterscCsdS)awReceive 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.Nr)rZ whitespacerrrignorableWhitespacesz"ContentHandler.ignorableWhitespacecCsdS)aReceive 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.Nr)rtargetdatarrrprocessingInstructionsz$ContentHandler.processingInstructioncCsdS)aReceive 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.Nr)rrrrr skippedEntityszContentHandler.skippedEntityN)r r r r rrrrrrrrrrrrr"r#rrrrr/s    rc@s eZdZdZddZddZdS) DTDHandlerzHandle DTD events. This interface specifies only those DTD events required for basic parsing (unparsed entities and attributes).cCsdS)z$Handle a notation declaration event.Nr)rrpublicIdsystemIdrrr notationDeclszDTDHandler.notationDeclcCsdS)z,Handle an unparsed entity declaration event.Nr)rrr%r&ZndatarrrunparsedEntityDeclszDTDHandler.unparsedEntityDeclN)r r r r r'r(rrrrr$sr$c@seZdZdZddZdS)EntityResolvera7Basic 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)zResolve the system identifier of an entity and return either the system identifier to read from as a string, or an InputSource to read from.r)rr%r&rrr resolveEntityszEntityResolver.resolveEntityN)r r r r r*rrrrr)sr)z&http://xml.org/sax/features/namespacesz.http://xml.org/sax/features/namespace-prefixesz,http://xml.org/sax/features/string-interningz&http://xml.org/sax/features/validationz5http://xml.org/sax/features/external-general-entitiesz7http://xml.org/sax/features/external-parameter-entitiesz-http://xml.org/sax/properties/lexical-handlerz1http://xml.org/sax/properties/declaration-handlerz&http://xml.org/sax/properties/dom-nodez(http://xml.org/sax/properties/xml-stringz-http://www.python.org/sax/properties/encodingz3http://www.python.org/sax/properties/interning-dictN)r versionrrr$r)Zfeature_namespacesZfeature_namespace_prefixesZfeature_string_interningZfeature_validationZfeature_external_gesZfeature_external_pesZ all_featuresZproperty_lexical_handlerZproperty_declaration_handlerZproperty_dom_nodeZproperty_xml_stringZproperty_encodingZproperty_interning_dictZall_propertiesrrrr s< "  __pycache__/xmlreader.cpython-36.opt-2.pyc000064400000024335152527044710014343 0ustar003 \1@sddlmZddlmZmZGdddZGdddeZGdddZGd d d ZGd d d Z Gd dde Z ddZ e dkre dS))handler)SAXNotSupportedExceptionSAXNotRecognizedExceptionc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdS) XMLReadercCs,tj|_tj|_tj|_tj|_dS)N) rZContentHandler _cont_handlerZ DTDHandler _dtd_handlerZEntityResolver _ent_handlerZ ErrorHandler _err_handler)selfr )/usr/lib64/python3.6/xml/sax/xmlreader.py__init__s   zXMLReader.__init__cCs tddS)Nz This method must be implemented!)NotImplementedError)r sourcer r r parseszXMLReader.parsecCs|jS)N)r)r r r r getContentHandler"szXMLReader.getContentHandlercCs ||_dS)N)r)r rr r r setContentHandler&szXMLReader.setContentHandlercCs|jS)N)r)r r r r getDTDHandler*szXMLReader.getDTDHandlercCs ||_dS)N)r)r rr r r setDTDHandler.szXMLReader.setDTDHandlercCs|jS)N)r)r r r r getEntityResolver2szXMLReader.getEntityResolvercCs ||_dS)N)r)r Zresolverr r r setEntityResolver6szXMLReader.setEntityResolvercCs|jS)N)r )r r r r getErrorHandler:szXMLReader.getErrorHandlercCs ||_dS)N)r )r rr r r setErrorHandler>szXMLReader.setErrorHandlercCs tddS)NzLocale support not implemented)r)r Zlocaler r r setLocaleBszXMLReader.setLocalecCstd|dS)NzFeature '%s' not recognized)r)r namer r r getFeatureKszXMLReader.getFeaturecCstd|dS)NzFeature '%s' not recognized)r)r rstater r r setFeatureOszXMLReader.setFeaturecCstd|dS)NzProperty '%s' not recognized)r)r rr r r getPropertySszXMLReader.getPropertycCstd|dS)NzProperty '%s' not recognized)r)r rvaluer r r setPropertyWszXMLReader.setPropertyN)__name__ __module__ __qualname__r rrrrrrrrrrrrrr r r r r r s  rc@s>eZdZdddZddZddZd d Zd d Zd dZdS)IncrementalParsercCs||_tj|dS)N)_bufsizerr )r bufsizer r r r oszIncrementalParser.__init__cCspddlm}|j|}|j||j}|dkr8|j}|j|j}x|rb|j||j|j}qFW|j dS)Nr)saxutils) r)Zprepare_input_source prepareParsergetCharacterStream getByteStreamreadr'feedclose)r rr)filebufferr r r rss     zIncrementalParser.parsecCs tddS)Nz This method must be implemented!)r)r datar r r r/szIncrementalParser.feedcCs tddS)Nz!prepareParser must be overridden!)r)r rr r r r+szIncrementalParser.prepareParsercCs tddS)Nz This method must be implemented!)r)r r r r r0s zIncrementalParser.closecCs tddS)Nz This method must be implemented!)r)r r r r resetszIncrementalParser.resetN)r5) r!r"r#r rr/r+r0r4r r r r r$[s    r$c@s,eZdZddZddZddZddZd S) LocatorcCsdS)Nrr )r r r r getColumnNumberszLocator.getColumnNumbercCsdS)Nrr7r )r r r r getLineNumberszLocator.getLineNumbercCsdS)Nr )r r r r getPublicIdszLocator.getPublicIdcCsdS)Nr )r r r r getSystemIdszLocator.getSystemIdN)r!r"r#r8r9r:r;r r r r r6sr6c@sfeZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ dS) InputSourceNcCs"||_d|_d|_d|_d|_dS)N)_InputSource__system_id_InputSource__public_id_InputSource__encoding_InputSource__bytefile_InputSource__charfile)r system_idr r r r s zInputSource.__init__cCs ||_dS)N)r>)r Z public_idr r r setPublicIdszInputSource.setPublicIdcCs|jS)N)r>)r r r r r:szInputSource.getPublicIdcCs ||_dS)N)r=)r rBr r r setSystemIdszInputSource.setSystemIdcCs|jS)N)r=)r r r r r;szInputSource.getSystemIdcCs ||_dS)N)r?)r encodingr r r setEncodingszInputSource.setEncodingcCs|jS)N)r?)r r r r getEncodingszInputSource.getEncodingcCs ||_dS)N)r@)r Zbytefiler r r setByteStreams zInputSource.setByteStreamcCs|jS)N)r@)r r r r r-szInputSource.getByteStreamcCs ||_dS)N)rA)r Zcharfiler r r setCharacterStreamszInputSource.setCharacterStreamcCs|jS)N)rA)r r r r r,szInputSource.getCharacterStream)N)r!r"r#r rCr:rDr;rFrGrHr-rIr,r r r r r<s    r<c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZd$ddZddZd d!Zd"d#ZdS)%AttributesImplcCs ||_dS)N)_attrs)r attrsr r r r szAttributesImpl.__init__cCs t|jS)N)lenrK)r r r r getLengthszAttributesImpl.getLengthcCsdS)NZCDATAr )r rr r r getType!szAttributesImpl.getTypecCs |j|S)N)rK)r rr r r getValue$szAttributesImpl.getValuecCs |j|S)N)rK)r rr r r getValueByQName'szAttributesImpl.getValueByQNamecCs||jkrt||S)N)rKKeyError)r rr r r getNameByQName*s zAttributesImpl.getNameByQNamecCs||jkrt||S)N)rKrR)r rr r r getQNameByName/s zAttributesImpl.getQNameByNamecCst|jjS)N)listrKkeys)r r r r getNames4szAttributesImpl.getNamescCst|jjS)N)rUrKrV)r r r r getQNames7szAttributesImpl.getQNamescCs t|jS)N)rMrK)r r r r __len__:szAttributesImpl.__len__cCs |j|S)N)rK)r rr r r __getitem__=szAttributesImpl.__getitem__cCst|jjS)N)rUrKrV)r r r r rV@szAttributesImpl.keyscCs ||jkS)N)rK)r rr r r __contains__CszAttributesImpl.__contains__NcCs|jj||S)N)rKget)r r alternativer r r r\FszAttributesImpl.getcCs |j|jS)N) __class__rK)r r r r copyIszAttributesImpl.copycCst|jjS)N)rUrKitems)r r r r r`LszAttributesImpl.itemscCst|jjS)N)rUrKvalues)r r r r raOszAttributesImpl.values)N)r!r"r#r rNrOrPrQrSrTrWrXrYrZrVr[r\r_r`rar r r r rJs" rJc@s<eZdZddZddZddZddZd d Zd d Zd S)AttributesNSImplcCs||_||_dS)N)rK_qnames)r rLZqnamesr r r r VszAttributesNSImpl.__init__cCs6x(|jjD]\}}||kr |j|Sq Wt|dS)N)rcr`rKrR)r rnsnameqnamer r r rQ^sz AttributesNSImpl.getValueByQNamecCs0x"|jjD]\}}||kr |Sq Wt|dS)N)rcr`rR)r rrdrer r r rSeszAttributesNSImpl.getNameByQNamecCs |j|S)N)rc)r rr r r rTlszAttributesNSImpl.getQNameByNamecCst|jjS)N)rUrcra)r r r r rXoszAttributesNSImpl.getQNamescCs|j|j|jS)N)r^rKrc)r r r r r_rszAttributesNSImpl.copyN) r!r"r#r rQrSrTrXr_r r r r rbTs rbcCstttdS)N)rr$r6r r r r _testvsrf__main__N) r*r _exceptionsrrrr$r6r<rJrbrfr!r r r r s PJY>"__pycache__/__init__.cpython-36.opt-1.pyc000064400000006132152527044710014111 0ustar003 \.@sdZddlmZddlmZmZddlmZmZm Z m Z m Z efddZ efddZ d gZd Zernd d lZd d lZd d lZejj rd ejkrejd jd Z[dZejd ddkrejjerejjejd ZgfddZejd ddkrddZnddZ[d S)aSimple 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. ) InputSource)ContentHandler ErrorHandler) SAXExceptionSAXNotRecognizedExceptionSAXParseExceptionSAXNotSupportedExceptionSAXReaderNotAvailablecCs(t}|j||j||j|dS)N) make_parsersetContentHandlersetErrorHandlerparse)sourcehandler errorHandlerparserr(/usr/lib64/python3.6/xml/sax/__init__.pyr s  r cCspddl}|dkrt}t}|j||j|t}t|trR|j|j |n|j |j ||j |dS)N) iorr r r r isinstancestrZsetCharacterStreamStringIOZ setByteStreamBytesIOr )stringrrrrZinpsrcrrr parseString#s   rzxml.sax.expatreaderrNZ PY_SAX_PARSER,zpython.xml.sax.parserjavacCsrxb|tD]V}yt|Stk rL}zddl}||jkr<WYdd}~Xq tk r^Yq Xq WtdddS)a&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.rNzNo parsers found)default_parser_list_create_parser ImportErrorsysmodulesr )Z parser_list parser_nameer"rrrr Fs  r cCs$ddlm}|j|dt}|jS)Nr)imp)Zorg.python.corer&Z importNameglobals create_parser)r$r& drv_modulerrrr as r cCst|iidg}|jS)Nr() __import__r()r$r)rrrr gs)__doc__Z xmlreaderrrrr _exceptionsrrrrr r rr_falseZxml.sax.expatreaderZxmlosr"flagsignore_environmentenvironsplitZ_keyplatformregistryZ containsKeyZ getPropertyr r rrrrs*   __pycache__/saxutils.cpython-36.opt-2.pyc000064400000025620152527044710014232 0ustar003 \/@sddlZddlZddlZddlZddlZddlmZddlmZddZ ifddZ ifd d Z ifd d Z d dZ GdddejZGdddejZdddZdS)N)handler) xmlreadercCs&x |jD]\}}|j||}q W|S)N)itemsreplace)sdkeyvaluer (/usr/lib64/python3.6/xml/sax/saxutils.py__dict_replace sr cCs6|jdd}|jdd}|jdd}|r2t||}|S)N&z&>z>._wrappercs t|S)N)getattr)selfname)outr r __getattr__[sz,_gettextwriter.._wrapper.__getattr__N)__name__ __module__ __qualname__ __class__r!r )r r r _wrapperYsr&cSsdS)Nr r r r r ^sz _gettextwriter..cSsdS)NTr r r r r r'csxmlcharrefreplacerT)encodingerrorsnewline write_through)sysstdout isinstanceio TextIOBasecodecs StreamWriterStreamReaderWriter RawIOBasecloseBufferedIOBasewritablewriteseekabletellAttributeError TextIOWrapper)r r)r-r&bufferr )r r _gettextwriterHs.     r?c@seZdZd ddZddZd!dd Zd d Zd d ZddZddZ ddZ ddZ ddZ ddZ ddZddZddZdS)" XMLGeneratorN iso-8859-1FcCsVtjj|t||}|j|_|j|_ig|_|jd|_ g|_ ||_ ||_ d|_ dS)NrF)rContentHandler__init__r?r9_writeflush_flush _ns_contexts_current_context_undeclared_ns_maps _encoding_short_empty_elements_pending_start_element)rr r)Zshort_empty_elementsr r r rDss   zXMLGenerator.__init__cCsJ|drBd|dkr d|dS|j|d}|rB|d|dS|dS)Nrz$http://www.w3.org/XML/1998/namespacezxml:r:)rI)rrprefixr r r _qnames  zXMLGenerator._qnamecCs|jr|jdd|_dS)NrF)rMrE)r endElementr r r _finish_pending_start_elements z*XMLGenerator._finish_pending_start_elementcCs|jd|jdS)Nz$ )rErK)rr r r startDocumentszXMLGenerator.startDocumentcCs |jdS)N)rG)rr r r endDocumentszXMLGenerator.endDocumentcCs0|jj|jj||j|<|jj||fdS)N)rHappendrIrrJ)rrOurir r r startPrefixMappings zXMLGenerator.startPrefixMappingcCs|jd|_|jd=dS)NrrBrB)rHrI)rrOr r r endPrefixMappings zXMLGenerator.endPrefixMappingcCs^|j|jd|x*|jD]\}}|jd|t|fq W|jrPd|_n |jddS)Nrz %s=%sTr)rRrErrrLrM)rrattrsr r r r startElementszXMLGenerator.startElementcCs*|jr|jdd|_n|jd|dS)Nz/>Fz)rMrE)rrr r r rQs zXMLGenerator.endElementcCs|j|jd|j|x8|jD].\}}|rD|jd||fq$|jd|q$Wg|_x0|jD]$\}}|jd|j|t|fqfW|jrd|_n |jddS)Nrz xmlns:%s="%s"z xmlns="%s"z %s=%sTr)rRrErPrJrrrLrM)rrqnamerYrOrVr r r r startElementNSs zXMLGenerator.startElementNScCs0|jr|jdd|_n|jd|j|dS)Nz/>Fz)rMrErP)rrr[r r r endElementNSs zXMLGenerator.endElementNScCs4|r0|jt|ts"t||j}|jt|dS)N)rRr/strrKrEr)rcontentr r r characterss   zXMLGenerator.characterscCs0|r,|jt|ts"t||j}|j|dS)N)rRr/r^rKrE)rr_r r r ignorableWhitespaces   z XMLGenerator.ignorableWhitespacecCs|j|jd||fdS)Nz )rRrE)rtargetrr r r processingInstructionsz"XMLGenerator.processingInstruction)NrAF)F)r"r#r$rDrPrRrSrTrWrXrZrQr\r]r`rarcr r r r r@qs   r@c@seZdZd:ddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9ZdS); XMLFilterBaseNcCstjj|||_dS)N)r XMLReaderrD_parent)rparentr r r rDs zXMLFilterBase.__init__cCs|jj|dS)N) _err_handlererror)r exceptionr r r riszXMLFilterBase.errorcCs|jj|dS)N)rh fatalError)rrjr r r rkszXMLFilterBase.fatalErrorcCs|jj|dS)N)rhwarning)rrjr r r rlszXMLFilterBase.warningcCs|jj|dS)N) _cont_handlersetDocumentLocator)rZlocatorr r r rnsz XMLFilterBase.setDocumentLocatorcCs|jjdS)N)rmrS)rr r r rSszXMLFilterBase.startDocumentcCs|jjdS)N)rmrT)rr r r rTszXMLFilterBase.endDocumentcCs|jj||dS)N)rmrW)rrOrVr r r rWsz XMLFilterBase.startPrefixMappingcCs|jj|dS)N)rmrX)rrOr r r rX szXMLFilterBase.endPrefixMappingcCs|jj||dS)N)rmrZ)rrrYr r r rZ szXMLFilterBase.startElementcCs|jj|dS)N)rmrQ)rrr r r rQszXMLFilterBase.endElementcCs|jj|||dS)N)rmr\)rrr[rYr r r r\szXMLFilterBase.startElementNScCs|jj||dS)N)rmr])rrr[r r r r]szXMLFilterBase.endElementNScCs|jj|dS)N)rmr`)rr_r r r r`szXMLFilterBase.characterscCs|jj|dS)N)rmra)rcharsr r r rasz!XMLFilterBase.ignorableWhitespacecCs|jj||dS)N)rmrc)rrbrr r r rcsz#XMLFilterBase.processingInstructioncCs|jj|dS)N)rm skippedEntity)rrr r r rp!szXMLFilterBase.skippedEntitycCs|jj|||dS)N) _dtd_handler notationDecl)rrpublicIdsystemIdr r r rr&szXMLFilterBase.notationDeclcCs|jj||||dS)N)rqunparsedEntityDecl)rrrsrtZndatar r r ru)sz XMLFilterBase.unparsedEntityDeclcCs|jj||S)N)Z _ent_handler resolveEntity)rrsrtr r r rv.szXMLFilterBase.resolveEntitycCs@|jj||jj||jj||jj||jj|dS)N)rfZsetContentHandlerZsetErrorHandlerZsetEntityResolverZ setDTDHandlerparse)rsourcer r r rw3s     zXMLFilterBase.parsecCs|jj|dS)N)rf setLocale)rZlocaler r r ry:szXMLFilterBase.setLocalecCs |jj|S)N)rf getFeature)rrr r r rz=szXMLFilterBase.getFeaturecCs|jj||dS)N)rf setFeature)rrstater r r r{@szXMLFilterBase.setFeaturecCs |jj|S)N)rf getProperty)rrr r r r}CszXMLFilterBase.getPropertycCs|jj||dS)N)rf setProperty)rrr r r r r~FszXMLFilterBase.setPropertycCs|jS)N)rf)rr r r getParentKszXMLFilterBase.getParentcCs ||_dS)N)rf)rrgr r r setParentNszXMLFilterBase.setParent)N)r"r#r$rDrirkrlrnrSrTrWrXrZrQr\r]r`rarcrprrrurvrwryrzr{r}r~rrr r r r rds8 rdcCs t|trtj|}n^t|drt|}tj}t|jdtrH|j|n |j|t|drtt|jtrt|j |j|j dko|j dkr|j }t jjt jj|}t jj||}t jj|r|j |t|d}n$|j tjj||tjj|j }|j||S)Nreadrrrb)r/r^rZ InputSourcehasattrrZsetCharacterStreamZ setByteStreamrZ setSystemIdZgetCharacterStreamZ getByteStreamZ getSystemIdospathdirnamenormpathjoinisfileopenurllibrwZurljoinZrequestZurlopen)rxbasefZsysidZbaseheadZ sysidfilenamer r r prepare_input_sourceSs*          r)r)rZ urllib.parserZurllib.requestr0r2rrrr rrrr?rCr@rerdrr r r r s     )so__pycache__/_exceptions.cpython-36.opt-2.pyc000064400000005351152527044710014675 0ustar003 \@s|ddlZejdddkr&ddlmZ[GdddeZGdddeZGd d d eZGd d d eZGd ddeZdS)Njava) Exceptionc@s6eZdZd ddZddZddZdd Zd d ZdS) SAXExceptionNcCs||_||_tj||dS)N)_msg _exceptionr__init__)selfmsg exceptionr +/usr/lib64/python3.6/xml/sax/_exceptions.pyrszSAXException.__init__cCs|jS)N)r)r r r r getMessageszSAXException.getMessagecCs|jS)N)r)r r r r getExceptionszSAXException.getExceptioncCs|jS)N)r)r r r r __str__"szSAXException.__str__cCs tddS)N __getitem__)AttributeError)r Zixr r r r&szSAXException.__getitem__)N)__name__ __module__ __qualname__rrrrrr r r r r s  rc@s<eZdZddZddZddZddZd d Zd d Zd S)SAXParseExceptioncCs<tj|||||_|jj|_|jj|_|jj|_dS)N) rr_locator getSystemId _systemIdgetColumnNumber_colnum getLineNumber_linenum)r r r Zlocatorr r r r;s   zSAXParseException.__init__cCs|jS)N)r)r r r r rHsz!SAXParseException.getColumnNumbercCs|jS)N)r)r r r r rMszSAXParseException.getLineNumbercCs |jjS)N)r getPublicId)r r r r rQszSAXParseException.getPublicIdcCs|jS)N)r)r r r r rUszSAXParseException.getSystemIdcCsN|j}|dkrd}|j}|dkr(d}|j}|dkr?z %s:%s:%s: %s)rrrr)r ZsysidZlinenumZcolnumr r r rYszSAXParseException.__str__N) rrrrrrrrrr r r r r.s   rc@s eZdZdS)SAXNotRecognizedExceptionN)rrrr r r r r isr c@s eZdZdS)SAXNotSupportedExceptionN)rrrr r r r r!ssr!c@s eZdZdS)SAXReaderNotAvailableN)rrrr r r r r"}sr") sysplatformZ java.langrrrr r!r"r r r r s %;  __pycache__/_exceptions.cpython-36.opt-1.pyc000064400000012533152527044710014674 0ustar003 \@sdZddlZejdddkr*ddlmZ[GdddeZGdd d eZGd d d eZGd d d eZGdddeZ dS)z!Different kinds of SAX ExceptionsNjava) Exceptionc@s:eZdZdZd ddZddZddZd d Zd d ZdS) SAXExceptionaEncapsulate 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.NcCs||_||_tj||dS)zUCreates an exception. The message is required, but the exception is optional.N)_msg _exceptionr__init__)selfmsg exceptionr +/usr/lib64/python3.6/xml/sax/_exceptions.pyrszSAXException.__init__cCs|jS)z$Return a message for this exception.)r)r r r r getMessageszSAXException.getMessagecCs|jS)z9Return the embedded exception, or None if there was none.)r)r r r r getExceptionszSAXException.getExceptioncCs|jS)z0Create a string representation of the exception.)r)r r r r __str__"szSAXException.__str__cCs tddS)zvAvoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined. __getitem__N)AttributeError)r Zixr r r r&szSAXException.__getitem__)N) __name__ __module__ __qualname____doc__rrrrrr r r r r s  rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)SAXParseExceptiona#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.cCs<tj|||||_|jj|_|jj|_|jj|_dS)zECreates the exception. The exception parameter is allowed to be None.N) rr_locator getSystemId _systemIdgetColumnNumber_colnum getLineNumber_linenum)r r r Zlocatorr r r r;s   zSAXParseException.__init__cCs|jS)zNThe column number of the end of the text where the exception occurred.)r)r r r r rHsz!SAXParseException.getColumnNumbercCs|jS)zDThe line number of the end of the text where the exception occurred.)r)r r r r rMszSAXParseException.getLineNumbercCs |jjS)zEGet the public identifier of the entity where the exception occurred.)r getPublicId)r r r r rQszSAXParseException.getPublicIdcCs|jS)zEGet the system identifier of the entity where the exception occurred.)r)r r r r rUszSAXParseException.getSystemIdcCsN|j}|dkrd}|j}|dkr(d}|j}|dkr?z %s:%s:%s: %s)rrrr)r ZsysidZlinenumZcolnumr r r rYszSAXParseException.__str__N) rrrrrrrrrrr r r r r.s  rc@seZdZdZdS)SAXNotRecognizedExceptionzException 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.N)rrrrr r r r r!isr!c@seZdZdZdS)SAXNotSupportedExceptionaException 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.N)rrrrr r r r r"ssr"c@seZdZdZdS)SAXReaderNotAvailableaException 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.N)rrrrr r r r r#}sr#) rsysplatformZ java.langrrrr!r"r#r r r r s %;  __pycache__/expatreader.cpython-36.opt-2.pyc000064400000027316152527044710014666 0ustar003 \X=@sdZddlTddlmZmZddlmZddlmZmZddlmZddlm Z m Z ddl Z e j dd d krxe d d[ ydd lmZWnek re d dYnXeedse d dddlmZmZmZejZejZy ddlZWnek rddZYnXddlZejZ[[GdddZGdddejZGdddejejZ ddZ!e"dkrddl#Z$e!Z%e%j&e$j'jj(e%j)e$j'j*e%j+ddS)z0.20)*)feature_validationfeature_namespaces)feature_namespace_prefixes)feature_external_gesfeature_external_pes)feature_string_interning)property_xml_stringproperty_interning_dictNjavazexpat not available in Java)expatzexpat not supported ParserCreate) xmlreadersaxutilshandlercCs|S)N)orr+/usr/lib64/python3.6/xml/sax/expatreader.py_mkproxy'src@s eZdZdS) _ClosedParserN)__name__ __module__ __qualname__rrrrr.src@s4eZdZddZddZddZddZd d Zd S) ExpatLocatorcCst||_dS)N)r_ref)selfparserrrr__init__9szExpatLocator.__init__cCs|j}|jdkrdS|jjS)N)r_parserErrorColumnNumber)rrrrrgetColumnNumber<s zExpatLocator.getColumnNumbercCs|j}|jdkrdS|jjS)N)rrErrorLineNumber)rrrrr getLineNumberBs zExpatLocator.getLineNumbercCs|j}|dkrdS|jjS)N)r_source getPublicId)rrrrrr&HszExpatLocator.getPublicIdcCs|j}|dkrdS|jjS)N)rr% getSystemId)rrrrrr'NszExpatLocator.getSystemIdN)rrrrr!r$r&r'rrrrr3s rc@seZdZdFddZddZd d Zd d Zd dZddZddZ ddZ dGddZ ddZ ddZ ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Zd?d@Z dAdBZ!dCS)H ExpatParserrcCsFtjj||tj|_d|_||_d|_d|_g|_ d|_ d|_ dS)Nr) rIncrementalParserrZ InputSourcer%r _namespaces_lex_handler_prop_parsing _entity_stack _external_ges _interning)rZnamespaceHandlingbufsizerrrrZs zExpatParser.__init__c CsVtj|}||_y*|j|jjt|tjj ||Wn|j YnXdS)N) rprepare_input_sourcer%reset _cont_handlerZsetDocumentLocatorrrr,parse _close_source)rsourcerrrr7gs zExpatParser.parsecCs |jdk r|jj|jdS)N)r'rZSetBase)rr9rrr prepareParserws zExpatParser.prepareParsercCs tjj|||jr|jdS)N)rr,setContentHandlerr/_reset_cont_handler)rrrrrr;}szExpatParser.setContentHandlercCsP|tkr|jS|tkr |jdk S|tttfkr2dS|tkr@|jSt d|dS)NrzFeature '%s' not recognized) rr-rr2rrrrr1SAXNotRecognizedException)rnamerrr getFeatures zExpatParser.getFeaturecCs|jrtd|tkr||_n|tkr.||_nt|tkrT|rL|jdkrRi|_qd|_nN|tkrj|rtdn8|t kr|rtdn"|t kr|rtdn t d|dS)Nz!Cannot set features while parsingz!expat does not support validationz/expat does not read external parameter entitiesz(expat does not report namespace prefixeszFeature '%s' not recognized) r/SAXNotSupportedExceptionrr-rr1rr2rrrr=)rr>staterrr setFeatures2 zExpatParser.setFeaturecCsd|tjkr|jS|tkr|jS|tkrT|jrLt|jdrB|jjSt dnt dt d|dS)NGetInputContextz=This version of expat does not support getting the XML stringz.XML string cannot be returned when not parsingzProperty '%s' not recognized) rproperty_lexical_handlerr.r r2r rhasattrrCr=r@)rr>rrr getPropertys   zExpatParser.getPropertycCsV|tjkr ||_|jrR|jn2|tkr0||_n"|tkrFtd|n t d|dS)NzProperty '%s' cannot be setzProperty '%s' not recognized) rrDr.r/_reset_lex_handler_propr r2r r@r=)rr>valuerrr setPropertys   zExpatParser.setPropertycCsz|js|jd|_|jjy|jj||WnDtjk rt}z&ttj |j ||}|j j |WYdd}~XnXdS)Nr") r/r5r6Z startDocumentrZParser errorZSAXParseExceptionZ ErrorStringcodeZ _err_handlerZ fatalError)rdataisFinaleexcrrrfeeds zExpatParser.feedc CsB|j}z|j}|dk r |jWd|j}|dk r<|jXdS)N)r%ZgetCharacterStreamcloseZ getByteStream)rr9filerrrr8s zExpatParser._close_sourcec Cs|js|jdkst|jtr dSz(|jddd|jjd|_d|_Wdd|_|jdk rzt}|jj|_|jj |_ ||_|j XdS)Nr")rMr) r0r isinstancerrPr6Z endDocumentr/r r#r8)rrrrrrQs      zExpatParser.closecCs|jj|j_|jj|j_dS)N)r6processingInstructionrZProcessingInstructionHandler charactersZCharacterDataHandler)rrrrr<s zExpatParser._reset_cont_handlercCs`|j}|j}|dkr4d|_d|_d|_d|_d|_n(|j|_|j|_|j |_|j |_|j |_dS)N) r.rZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ startCDATAZendCDATAstart_doctype_declZendDTD)rZlexrrrrrGsz#ExpatParser._reset_lex_handler_propc Cs|jr>tj|jjd|jd|_d|j_|j|j_ |j |j_ n,tj|jj|jd|_|j |j_ |j |j_ |j|j|j_|j|j_|j|j_|j|j_d|_|jr|j|j|j_y|j|j_Wntk rYnX|jjtj d|_!g|_"dS)N )internr"r)#r-r rr%Z getEncodingr2rZnamespace_prefixesstart_element_nsZStartElementHandlerend_element_nsZEndElementHandler start_element end_elementr<unparsed_entity_declZUnparsedEntityDeclHandler notation_declZNotationDeclHandlerstart_namespace_declZStartNamespaceDeclHandlerend_namespace_declZEndNamespaceDeclHandlerZ_decl_handler_propr.rGexternal_entity_refZExternalEntityRefHandlerskipped_entity_handlerZSkippedEntityHandlerAttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr/r0)rrrrr5s6            zExpatParser.resetcCs|jdkrdS|jjS)N)rr )rrrrr!;s zExpatParser.getColumnNumbercCs|jdkrdS|jjS)Nr")rr#)rrrrr$@s zExpatParser.getLineNumbercCs |jjS)N)r%r&)rrrrr&EszExpatParser.getPublicIdcCs |jjS)N)r%r')rrrrr'HszExpatParser.getSystemIdcCs|jj|t|dS)N)r6Z startElementAttributesImpl)rr>attrsrrrr\LszExpatParser.start_elementcCs|jj|dS)N)r6Z endElement)rr>rrrr]OszExpatParser.end_elementc Cs|j}t|dkrd|f}n&t|dkr<|d|df}nt|}i}i}x|jD]|\}}|j}t|} | dkr|} d|f} n>| dkrd|d|df} |d|df} n|d} t|} ||| <| || <qVW|jj|dt||dS)Nr"rz%s:%sr))splitlentupleitemsr6ZstartElementNSAttributesNSImpl) rr>rfpairZnewattrsZqnamesZanamerHpartsZlengthZqnameZapairrrrrZRs.      zExpatParser.start_element_nscCsV|j}t|dkrd|f}n&t|dkr<|d|df}nt|}|jj|ddS)Nr"rgr)rhrirjr6Z endElementNS)rr>rmrrrr[ts   zExpatParser.end_element_nscCs|jj||dS)N)r6rU)rtargetrLrrrprocessing_instructionsz"ExpatParser.processing_instructioncCs|jj|dS)N)r6rV)rrLrrrcharacter_dataszExpatParser.character_datacCs|jj||dS)N)r6ZstartPrefixMapping)rprefixZurirrrr`sz ExpatParser.start_namespace_declcCs|jj|dS)N)r6ZendPrefixMapping)rrrrrrraszExpatParser.end_namespace_declcCs|jj|||dS)N)r.ZstartDTD)rr>sysidpubidZhas_internal_subsetrrrrWszExpatParser.start_doctype_declcCs|jj||||dS)N) _dtd_handlerZunparsedEntityDecl)rr>basersrtZ notation_namerrrr^sz ExpatParser.unparsed_entity_declcCs|jj|||dS)N)ruZ notationDecl)rr>rvrsrtrrrr_szExpatParser.notation_declc Cs|js dS|jj||}tj||jjp*d}|jj|j |jf|j j ||_ ||_yt j j ||Wn dS|jd\|_ |_|jd=dS)Nr"rSrrw)r1Z _ent_handlerZ resolveEntityrr4r%r'r0appendrZExternalEntityParserCreaterr,r7)rcontextrvrsrtr9rrrrbs  zExpatParser.external_entity_refcCs|r d|}|jj|dS)N%)r6Z skippedEntity)rr>Zis_perrrrcsz"ExpatParser.skipped_entity_handlerNi)rr{)r)"rrrrr7r:r;r?rBrFrIrPr8rQr<rGr5r!r$r&r'r\r]rZr[rprqr`rarWr^r_rbrcrrrrr(Ws>    '" r(cOs t||S)N)r()argskwargsrrr create_parsersr~__main__z:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml),versionZxml.sax._exceptionsZxml.sax.handlerrrrrrrr r sysplatformZSAXReaderNotAvailableZ xml.parsersr ImportErrorrEZxml.saxrrrrerl_weakrefrweakrefproxyrZLocatorrr,r(r~rZxml.sax.saxutilsZxmlpr;ZsaxZ XMLGeneratorZsetErrorHandlerZ ErrorHandlerr7rrrrsL      $_ __pycache__/handler.cpython-36.opt-1.pyc000064400000030033152527044710013764 0ustar003 \b6@sdZdZGdddZGdddZGdddZGdd d Zd Zd Zd Zd Z dZ dZ eeee e e gZ dZ dZdZdZdZdZe eeeeegZdS)a0 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$ z2.0betac@s(eZdZdZddZddZddZdS) ErrorHandleraBasic 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)zHandle a recoverable error.N)self exceptionrr'/usr/lib64/python3.6/xml/sax/handler.pyerror szErrorHandler.errorcCs|dS)zHandle a non-recoverable error.Nr)rrrrr fatalError$szErrorHandler.fatalErrorcCs t|dS)zHandle a warning.N)print)rrrrrwarning(szErrorHandler.warningN)__name__ __module__ __qualname____doc__rrr rrrrrsrc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZdS)ContentHandlerzInterface 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)_locator)rrrr__init__6szContentHandler.__init__cCs ||_dS)a#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)rZlocatorrrrsetDocumentLocator9sz!ContentHandler.setDocumentLocatorcCsdS)zReceive 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).Nr)rrrr startDocumentPszContentHandler.startDocumentcCsdS)aQReceive 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.Nr)rrrr endDocumentWszContentHandler.endDocumentcCsdS)aBegin 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.Nr)rprefixZurirrrstartPrefixMapping`sz!ContentHandler.startPrefixMappingcCsdS)zEnd 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.Nr)rrrrrendPrefixMappingwszContentHandler.endPrefixMappingcCsdS)aSignals 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.Nr)rnameattrsrrr startElement~szContentHandler.startElementcCsdS)zSignals 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.Nr)rrrrr endElementszContentHandler.endElementcCsdS)aSignals 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.Nr)rrqnamerrrrstartElementNSszContentHandler.startElementNScCsdS)zSignals the end of an element in namespace mode. The name parameter contains the name of the element type, just as with the startElementNS event.Nr)rrrrrr endElementNSszContentHandler.endElementNScCsdS)aReceive 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.Nr)rZcontentrrr charactersszContentHandler.characterscCsdS)awReceive 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.Nr)rZ whitespacerrrignorableWhitespacesz"ContentHandler.ignorableWhitespacecCsdS)aReceive 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.Nr)rtargetdatarrrprocessingInstructionsz$ContentHandler.processingInstructioncCsdS)aReceive 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.Nr)rrrrr skippedEntityszContentHandler.skippedEntityN)r r r r rrrrrrrrrrrrr"r#rrrrr/s    rc@s eZdZdZddZddZdS) DTDHandlerzHandle DTD events. This interface specifies only those DTD events required for basic parsing (unparsed entities and attributes).cCsdS)z$Handle a notation declaration event.Nr)rrpublicIdsystemIdrrr notationDeclszDTDHandler.notationDeclcCsdS)z,Handle an unparsed entity declaration event.Nr)rrr%r&ZndatarrrunparsedEntityDeclszDTDHandler.unparsedEntityDeclN)r r r r r'r(rrrrr$sr$c@seZdZdZddZdS)EntityResolvera7Basic 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)zResolve the system identifier of an entity and return either the system identifier to read from as a string, or an InputSource to read from.r)rr%r&rrr resolveEntityszEntityResolver.resolveEntityN)r r r r r*rrrrr)sr)z&http://xml.org/sax/features/namespacesz.http://xml.org/sax/features/namespace-prefixesz,http://xml.org/sax/features/string-interningz&http://xml.org/sax/features/validationz5http://xml.org/sax/features/external-general-entitiesz7http://xml.org/sax/features/external-parameter-entitiesz-http://xml.org/sax/properties/lexical-handlerz1http://xml.org/sax/properties/declaration-handlerz&http://xml.org/sax/properties/dom-nodez(http://xml.org/sax/properties/xml-stringz-http://www.python.org/sax/properties/encodingz3http://www.python.org/sax/properties/interning-dictN)r versionrrr$r)Zfeature_namespacesZfeature_namespace_prefixesZfeature_string_interningZfeature_validationZfeature_external_gesZfeature_external_pesZ all_featuresZproperty_lexical_handlerZproperty_declaration_handlerZproperty_dom_nodeZproperty_xml_stringZproperty_encodingZproperty_interning_dictZall_propertiesrrrr s< "  __pycache__/expatreader.cpython-36.opt-1.pyc000064400000030153152527044710014656 0ustar003 \X=@sdZdZddlTddlmZmZddlmZddlmZmZddlm Z ddlm Z m Z dd l Z e j d d d kr|ed d [ ydd lmZWnek redd YnXeedsedd ddlmZmZmZejZejZy dd lZWnek r ddZYnXdd lZejZ[[GdddZGdddejZGdddej ejZ!ddZ"e#dkrdd l$Z%e"Z&e&j'e%j(jj)e&j*e%j(j+e&j,dd S)z] SAX driver for the pyexpat C module. This driver works with pyexpat.__version__ == '2.22'. z0.20)*)feature_validationfeature_namespaces)feature_namespace_prefixes)feature_external_gesfeature_external_pes)feature_string_interning)property_xml_stringproperty_interning_dictNjavazexpat not available in Java)expatzexpat not supported ParserCreate) xmlreadersaxutilshandlercCs|S)N)orr+/usr/lib64/python3.6/xml/sax/expatreader.py_mkproxy'src@s eZdZdS) _ClosedParserN)__name__ __module__ __qualname__rrrrr.src@s8eZdZdZddZddZddZdd Zd d Zd S) ExpatLocatorzLocator 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)r_ref)selfparserrrr__init__9szExpatLocator.__init__cCs|j}|jdkrdS|jjS)N)r_parserErrorColumnNumber)rrrrrgetColumnNumber<s zExpatLocator.getColumnNumbercCs|j}|jdkrdS|jjS)N)rrErrorLineNumber)rrrrr getLineNumberBs zExpatLocator.getLineNumbercCs|j}|dkrdS|jjS)N)r_source getPublicId)rrrrrr&HszExpatLocator.getPublicIdcCs|j}|dkrdS|jjS)N)rr% getSystemId)rrrrrr'NszExpatLocator.getSystemIdN) rrr__doc__rr!r$r&r'rrrrr3s rc@s eZdZdZdGddZdd Zd d Zd d ZddZddZ ddZ ddZ dHddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z d@dAZ!dBdCZ"dDS)I ExpatParserz$SAX driver for the pyexpat C module.rcCsFtjj||tj|_d|_||_d|_d|_g|_ d|_ d|_ dS)Nr) rIncrementalParserrZ InputSourcer%r _namespaces_lex_handler_prop_parsing _entity_stack _external_ges _interning)rZnamespaceHandlingbufsizerrrrZs zExpatParser.__init__c CsVtj|}||_y*|j|jjt|tjj ||Wn|j YnXdS)z3Parse an XML document from a URL or an InputSource.N) rprepare_input_sourcer%reset _cont_handlerZsetDocumentLocatorrrr-parse _close_source)rsourcerrrr8gs zExpatParser.parsecCs |jdk r|jj|jdS)N)r'rZSetBase)rr:rrr prepareParserws zExpatParser.prepareParsercCs tjj|||jr|jdS)N)rr-setContentHandlerr0_reset_cont_handler)rrrrrr<}szExpatParser.setContentHandlercCsP|tkr|jS|tkr |jdk S|tttfkr2dS|tkr@|jSt d|dS)NrzFeature '%s' not recognized) rr.rr3rrrrr2SAXNotRecognizedException)rnamerrr getFeatures zExpatParser.getFeaturecCs|jrtd|tkr||_n|tkr.||_nt|tkrT|rL|jdkrRi|_qd|_nN|tkrj|rtdn8|t kr|rtdn"|t kr|rtdn t d|dS)Nz!Cannot set features while parsingz!expat does not support validationz/expat does not read external parameter entitiesz(expat does not report namespace prefixeszFeature '%s' not recognized) r0SAXNotSupportedExceptionrr.rr2rr3rrrr>)rr?staterrr setFeatures2 zExpatParser.setFeaturecCsd|tjkr|jS|tkr|jS|tkrT|jrLt|jdrB|jjSt dnt dt d|dS)NGetInputContextz=This version of expat does not support getting the XML stringz.XML string cannot be returned when not parsingzProperty '%s' not recognized) rproperty_lexical_handlerr/r r3r rhasattrrDr>rA)rr?rrr getPropertys   zExpatParser.getPropertycCsV|tjkr ||_|jrR|jn2|tkr0||_n"|tkrFtd|n t d|dS)NzProperty '%s' cannot be setzProperty '%s' not recognized) rrEr/r0_reset_lex_handler_propr r3r rAr>)rr?valuerrr setPropertys   zExpatParser.setPropertycCsz|js|jd|_|jjy|jj||WnDtjk rt}z&ttj |j ||}|j j |WYdd}~XnXdS)Nr") r0r6r7Z startDocumentrZParser errorZSAXParseExceptionZ ErrorStringcodeZ _err_handlerZ fatalError)rdataisFinaleexcrrrfeeds zExpatParser.feedc CsB|j}z|j}|dk r |jWd|j}|dk r<|jXdS)N)r%ZgetCharacterStreamcloseZ getByteStream)rr:filerrrr9s zExpatParser._close_sourcec Cs|js|jdkst|jtr dSz(|jddd|jjd|_d|_Wdd|_|jdk rzt}|jj|_|jj |_ ||_|j XdS)Nr")rNr) r1r isinstancerrQr7Z endDocumentr0r r#r9)rrrrrrRs      zExpatParser.closecCs|jj|j_|jj|j_dS)N)r7processingInstructionrZProcessingInstructionHandler charactersZCharacterDataHandler)rrrrr=s zExpatParser._reset_cont_handlercCs`|j}|j}|dkr4d|_d|_d|_d|_d|_n(|j|_|j|_|j |_|j |_|j |_dS)N) r/rZCommentHandlerZStartCdataSectionHandlerZEndCdataSectionHandlerZStartDoctypeDeclHandlerZEndDoctypeDeclHandlerZcommentZ startCDATAZendCDATAstart_doctype_declZendDTD)rZlexrrrrrHsz#ExpatParser._reset_lex_handler_propc Cs|jr>tj|jjd|jd|_d|j_|j|j_ |j |j_ n,tj|jj|jd|_|j |j_ |j |j_ |j|j|j_|j|j_|j|j_|j|j_d|_|jr|j|j|j_y|j|j_Wntk rYnX|jjtj d|_!g|_"dS)N )internr"r)#r.r rr%Z getEncodingr3rZnamespace_prefixesstart_element_nsZStartElementHandlerend_element_nsZEndElementHandler start_element end_elementr=unparsed_entity_declZUnparsedEntityDeclHandler notation_declZNotationDeclHandlerstart_namespace_declZStartNamespaceDeclHandlerend_namespace_declZEndNamespaceDeclHandlerZ_decl_handler_propr/rHexternal_entity_refZExternalEntityRefHandlerskipped_entity_handlerZSkippedEntityHandlerAttributeErrorZSetParamEntityParsingZ*XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEr0r1)rrrrr6s6            zExpatParser.resetcCs|jdkrdS|jjS)N)rr )rrrrr!;s zExpatParser.getColumnNumbercCs|jdkrdS|jjS)Nr")rr#)rrrrr$@s zExpatParser.getLineNumbercCs |jjS)N)r%r&)rrrrr&EszExpatParser.getPublicIdcCs |jjS)N)r%r')rrrrr'HszExpatParser.getSystemIdcCs|jj|t|dS)N)r7Z startElementAttributesImpl)rr?attrsrrrr]LszExpatParser.start_elementcCs|jj|dS)N)r7Z endElement)rr?rrrr^OszExpatParser.end_elementc Cs|j}t|dkrd|f}n&t|dkr<|d|df}nt|}i}i}x|jD]|\}}|j}t|} | dkr|} d|f} n>| dkrd|d|df} |d|df} n|d} t|} ||| <| || <qVW|jj|dt||dS)Nr"rz%s:%sr*)splitlentupleitemsr7ZstartElementNSAttributesNSImpl) rr?rgpairZnewattrsZqnamesZanamerIpartsZlengthZqnameZapairrrrr[Rs.      zExpatParser.start_element_nscCsV|j}t|dkrd|f}n&t|dkr<|d|df}nt|}|jj|ddS)Nr"rhr)rirjrkr7Z endElementNS)rr?rnrrrr\ts   zExpatParser.end_element_nscCs|jj||dS)N)r7rV)rtargetrMrrrprocessing_instructionsz"ExpatParser.processing_instructioncCs|jj|dS)N)r7rW)rrMrrrcharacter_dataszExpatParser.character_datacCs|jj||dS)N)r7ZstartPrefixMapping)rprefixZurirrrrasz ExpatParser.start_namespace_declcCs|jj|dS)N)r7ZendPrefixMapping)rrsrrrrbszExpatParser.end_namespace_declcCs|jj|||dS)N)r/ZstartDTD)rr?sysidpubidZhas_internal_subsetrrrrXszExpatParser.start_doctype_declcCs|jj||||dS)N) _dtd_handlerZunparsedEntityDecl)rr?basertruZ notation_namerrrr_sz ExpatParser.unparsed_entity_declcCs|jj|||dS)N)rvZ notationDecl)rr?rwrtrurrrr`szExpatParser.notation_declc Cs|js dS|jj||}tj||jjp*d}|jj|j |jf|j j ||_ ||_yt j j ||Wn dS|jd\|_ |_|jd=dS)Nr"rTrrx)r2Z _ent_handlerZ resolveEntityrr5r%r'r1appendrZExternalEntityParserCreaterr-r8)rcontextrwrtrur:rrrrcs  zExpatParser.external_entity_refcCs|r d|}|jj|dS)N%)r7Z skippedEntity)rr?Zis_perrrrdsz"ExpatParser.skipped_entity_handlerNi)rr|)r)#rrrr(rr8r;r<r@rCrGrJrQr9rRr=rHr6r!r$r&r'r]r^r[r\rqrrrarbrXr_r`rcrdrrrrr)Ws@    '" r)cOs t||S)N)r))argskwargsrrr create_parsersr__main__z:http://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml)-r(versionZxml.sax._exceptionsZxml.sax.handlerrrrrrrr r sysplatformZSAXReaderNotAvailableZ xml.parsersr ImportErrorrFZxml.saxrrrrfrm_weakrefrweakrefproxyrZLocatorrr-r)rrZxml.sax.saxutilsZxmlpr<ZsaxZ XMLGeneratorZsetErrorHandlerZ ErrorHandlerr8rrrrsN      $_ __pycache__/saxutils.cpython-36.pyc000064400000031011152527044710013261 0ustar003 \/@sdZddlZddlZddlZddlZddlZddlmZddlm Z ddZ ifdd Z ifd d Z ifd d Z ddZGdddejZGddde jZdddZdS)znA library of useful helper classes to the SAX classes, for the convenience of application and driver writers. N)handler) xmlreadercCs&x |jD]\}}|j||}q W|S)z2Replace substrings of a string using a dictionary.)itemsreplace)sdkeyvaluer (/usr/lib64/python3.6/xml/sax/saxutils.py__dict_replace sr cCs6|jdd}|jdd}|jdd}|r2t||}|S)zEscape &, <, 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. &z&>z> 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. z z z )   "'z"%s"z"z'%s')copyupdaterr)rrr r r quoteattr0s   rcsdkrddl}|jSttjr&Sttjtjfr<SttjrlGfddd}|}dd|_ nDtj }dd|_ j |_ yj |_ j|_Wntk rYnXtj||ddd d S) NrcseZdZjZfddZdS)z _gettextwriter.._wrappercs t|S)N)getattr)selfname)outr r __getattr__[sz,_gettextwriter.._wrapper.__getattr__N)__name__ __module__ __qualname__ __class__r!r )r r r _wrapperYsr&cSsdS)Nr r r r r ^sz _gettextwriter..cSsdS)NTr r r r r r'csxmlcharrefreplacerT)encodingerrorsnewline write_through)sysstdout isinstanceio TextIOBasecodecs StreamWriterStreamReaderWriter RawIOBasecloseBufferedIOBasewritablewriteseekabletellAttributeError TextIOWrapper)r r)r-r&bufferr )r r _gettextwriterHs.     r?c@seZdZd ddZddZd!dd Zd d Zd d ZddZddZ ddZ ddZ ddZ ddZ ddZddZddZdS)" XMLGeneratorN iso-8859-1FcCsVtjj|t||}|j|_|j|_ig|_|jd|_ g|_ ||_ ||_ d|_ dS)NrF)rContentHandler__init__r?r9_writeflush_flush _ns_contexts_current_context_undeclared_ns_maps _encoding_short_empty_elements_pending_start_element)rr r)Zshort_empty_elementsr r r rDss   zXMLGenerator.__init__cCsJ|drBd|dkr d|dS|j|d}|rB|d|dS|dS)z7Builds a qualified name from a (ns_url, localname) pairrz$http://www.w3.org/XML/1998/namespacezxml:r:)rI)rrprefixr r r _qnames  zXMLGenerator._qnamecCs|jr|jdd|_dS)NrF)rMrE)r endElementr r r _finish_pending_start_elements z*XMLGenerator._finish_pending_start_elementcCs|jd|jdS)Nz$ )rErK)rr r r startDocumentszXMLGenerator.startDocumentcCs |jdS)N)rG)rr r r endDocumentszXMLGenerator.endDocumentcCs0|jj|jj||j|<|jj||fdS)N)rHappendrIrrJ)rrOurir r r startPrefixMappings zXMLGenerator.startPrefixMappingcCs|jd|_|jd=dS)NrrBrB)rHrI)rrOr r r endPrefixMappings zXMLGenerator.endPrefixMappingcCs^|j|jd|x*|jD]\}}|jd|t|fq W|jrPd|_n |jddS)Nrz %s=%sTr)rRrErrrLrM)rrattrsr r r r startElementszXMLGenerator.startElementcCs*|jr|jdd|_n|jd|dS)Nz/>Fz)rMrE)rrr r r rQs zXMLGenerator.endElementcCs|j|jd|j|x8|jD].\}}|rD|jd||fq$|jd|q$Wg|_x0|jD]$\}}|jd|j|t|fqfW|jrd|_n |jddS)Nrz xmlns:%s="%s"z xmlns="%s"z %s=%sTr)rRrErPrJrrrLrM)rrqnamerYrOrVr r r r startElementNSs zXMLGenerator.startElementNScCs0|jr|jdd|_n|jd|j|dS)Nz/>Fz)rMrErP)rrr[r r r endElementNSs zXMLGenerator.endElementNScCs4|r0|jt|ts"t||j}|jt|dS)N)rRr/strrKrEr)rcontentr r r characterss   zXMLGenerator.characterscCs0|r,|jt|ts"t||j}|j|dS)N)rRr/r^rKrE)rr_r r r ignorableWhitespaces   z XMLGenerator.ignorableWhitespacecCs|j|jd||fdS)Nz )rRrE)rtargetrr r r processingInstructionsz"XMLGenerator.processingInstruction)NrAF)F)r"r#r$rDrPrRrSrTrWrXrZrQr\r]r`rarcr r r r r@qs   r@c@seZdZdZd;ddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:ZdS)< XMLFilterBaseaYThis 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.NcCstjj|||_dS)N)r XMLReaderrD_parent)rparentr r r rDs zXMLFilterBase.__init__cCs|jj|dS)N) _err_handlererror)r exceptionr r r riszXMLFilterBase.errorcCs|jj|dS)N)rh fatalError)rrjr r r rkszXMLFilterBase.fatalErrorcCs|jj|dS)N)rhwarning)rrjr r r rlszXMLFilterBase.warningcCs|jj|dS)N) _cont_handlersetDocumentLocator)rZlocatorr r r rnsz XMLFilterBase.setDocumentLocatorcCs|jjdS)N)rmrS)rr r r rSszXMLFilterBase.startDocumentcCs|jjdS)N)rmrT)rr r r rTszXMLFilterBase.endDocumentcCs|jj||dS)N)rmrW)rrOrVr r r rWsz XMLFilterBase.startPrefixMappingcCs|jj|dS)N)rmrX)rrOr r r rX szXMLFilterBase.endPrefixMappingcCs|jj||dS)N)rmrZ)rrrYr r r rZ szXMLFilterBase.startElementcCs|jj|dS)N)rmrQ)rrr r r rQszXMLFilterBase.endElementcCs|jj|||dS)N)rmr\)rrr[rYr r r r\szXMLFilterBase.startElementNScCs|jj||dS)N)rmr])rrr[r r r r]szXMLFilterBase.endElementNScCs|jj|dS)N)rmr`)rr_r r r r`szXMLFilterBase.characterscCs|jj|dS)N)rmra)rcharsr r r rasz!XMLFilterBase.ignorableWhitespacecCs|jj||dS)N)rmrc)rrbrr r r rcsz#XMLFilterBase.processingInstructioncCs|jj|dS)N)rm skippedEntity)rrr r r rp!szXMLFilterBase.skippedEntitycCs|jj|||dS)N) _dtd_handler notationDecl)rrpublicIdsystemIdr r r rr&szXMLFilterBase.notationDeclcCs|jj||||dS)N)rqunparsedEntityDecl)rrrsrtZndatar r r ru)sz XMLFilterBase.unparsedEntityDeclcCs|jj||S)N)Z _ent_handler resolveEntity)rrsrtr r r rv.szXMLFilterBase.resolveEntitycCs@|jj||jj||jj||jj||jj|dS)N)rfZsetContentHandlerZsetErrorHandlerZsetEntityResolverZ setDTDHandlerparse)rsourcer r r rw3s     zXMLFilterBase.parsecCs|jj|dS)N)rf setLocale)rZlocaler r r ry:szXMLFilterBase.setLocalecCs |jj|S)N)rf getFeature)rrr r r rz=szXMLFilterBase.getFeaturecCs|jj||dS)N)rf setFeature)rrstater r r r{@szXMLFilterBase.setFeaturecCs |jj|S)N)rf getProperty)rrr r r r}CszXMLFilterBase.getPropertycCs|jj||dS)N)rf setProperty)rrr r r r r~FszXMLFilterBase.setPropertycCs|jS)N)rf)rr r r getParentKszXMLFilterBase.getParentcCs ||_dS)N)rf)rrgr r r setParentNszXMLFilterBase.setParent)N) r"r#r$__doc__rDrirkrlrnrSrTrWrXrZrQr\r]r`rarcrprrrurvrwryrzr{r}r~rrr r r r rds: rdcCs t|trtj|}n^t|drt|}tj}t|jdtrH|j|n |j|t|drtt|jtrt|j |j|j dko|j dkr|j }t jjt jj|}t jj||}t jj|r|j |t|d}n$|j tjj||tjj|j }|j||S)zThis function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.readrrNrb)r/r^rZ InputSourcehasattrrZsetCharacterStreamZ setByteStreamrZ setSystemIdZgetCharacterStreamZ getByteStreamZ getSystemIdospathdirnamenormpathjoinisfileopenurllibrwZurljoinZrequestZurlopen)rxbasefZsysidZbaseheadZ sysidfilenamer r r prepare_input_sourceSs*          r)r)rrZ urllib.parserZurllib.requestr0r2rrrr rrrr?rCr@rerdrr r r r s     )so__pycache__/__init__.cpython-36.opt-2.pyc000064400000004076152527044710014117 0ustar003 \.@s ddlmZddlmZmZddlmZmZmZm Z m Z efddZ efddZ dgZ d Zerjd d lZd d lZd d lZejj rd ejkrejd jd Z [d Zejd ddkrejjerejjejd Z gfddZejd ddkrddZnddZ[d S)) InputSource)ContentHandler ErrorHandler) SAXExceptionSAXNotRecognizedExceptionSAXParseExceptionSAXNotSupportedExceptionSAXReaderNotAvailablecCs(t}|j||j||j|dS)N) make_parsersetContentHandlersetErrorHandlerparse)sourcehandler errorHandlerparserr(/usr/lib64/python3.6/xml/sax/__init__.pyr s  r cCspddl}|dkrt}t}|j||j|t}t|trR|j|j |n|j |j ||j |dS)N) iorr r r r isinstancestrZsetCharacterStreamStringIOZ setByteStreamBytesIOr )stringrrrrZinpsrcrrr parseString#s   rzxml.sax.expatreaderrNZ PY_SAX_PARSER,zpython.xml.sax.parserjavacCsrxb|tD]V}yt|Stk rL}zddl}||jkr<WYdd}~Xq tk r^Yq Xq WtdddS)NrzNo parsers found)default_parser_list_create_parser ImportErrorsysmodulesr )Z parser_list parser_nameer"rrrr Fs  r cCs$ddlm}|j|dt}|jS)Nr)imp)Zorg.python.corer&Z importNameglobals create_parser)r$r& drv_modulerrrr as r cCst|iidg}|jS)Nr() __import__r()r$r)rrrr gs)Z xmlreaderrrrr _exceptionsrrrrr r rr_falseZxml.sax.expatreaderZxmlosr"flagsignore_environmentenvironsplitZ_keyplatformregistryZ containsKeyZ getPropertyr r rrrrs(   __pycache__/xmlreader.cpython-36.opt-1.pyc000064400000041034152527044710014335 0ustar003 \1@sdZddlmZddlmZmZGdddZGdddeZGdd d ZGd d d Z Gd d d Z Gddde Z ddZ e dkre dS)z]An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. )handler)SAXNotSupportedExceptionSAXNotRecognizedExceptionc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd S)! XMLReadera%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) rZContentHandler _cont_handlerZ DTDHandler _dtd_handlerZEntityResolver _ent_handlerZ ErrorHandler _err_handler)selfr )/usr/lib64/python3.6/xml/sax/xmlreader.py__init__s   zXMLReader.__init__cCs tddS)zAParse an XML document from a system identifier or an InputSource.z This method must be implemented!N)NotImplementedError)r sourcer r r parseszXMLReader.parsecCs|jS)z#Returns the current ContentHandler.)r)r r r r getContentHandler"szXMLReader.getContentHandlercCs ||_dS)z:Registers a new object to receive document content events.N)r)r rr r r setContentHandler&szXMLReader.setContentHandlercCs|jS)z Returns the current DTD handler.)r)r r r r getDTDHandler*szXMLReader.getDTDHandlercCs ||_dS)z7Register an object to receive basic DTD-related events.N)r)r rr r r setDTDHandler.szXMLReader.setDTDHandlercCs|jS)z#Returns the current EntityResolver.)r)r r r r getEntityResolver2szXMLReader.getEntityResolvercCs ||_dS)z0Register an object to resolve external entities.N)r)r Zresolverr r r setEntityResolver6szXMLReader.setEntityResolvercCs|jS)z!Returns the current ErrorHandler.)r )r r r r getErrorHandler:szXMLReader.getErrorHandlercCs ||_dS)z3Register an object to receive error-message events.N)r )r rr r r setErrorHandler>szXMLReader.setErrorHandlercCs tddS)aHAllow 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.zLocale support not implementedN)r)r Zlocaler r r setLocaleBszXMLReader.setLocalecCstd|dS)z1Looks up and returns the state of a SAX2 feature.zFeature '%s' not recognizedN)r)r namer r r getFeatureKszXMLReader.getFeaturecCstd|dS)z!Sets the state of a SAX2 feature.zFeature '%s' not recognizedN)r)r rstater r r setFeatureOszXMLReader.setFeaturecCstd|dS)z2Looks up and returns the value of a SAX2 property.zProperty '%s' not recognizedN)r)r rr r r getPropertySszXMLReader.getPropertycCstd|dS)z"Sets the value of a SAX2 property.zProperty '%s' not recognizedN)r)r rvaluer r r setPropertyWszXMLReader.setPropertyN)__name__ __module__ __qualname____doc__r rrrrrrrrrrrrrr r r r r r s   rc@sBeZdZdZdddZddZdd Zd d Zd d ZddZ dS)IncrementalParserasThis 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.cCs||_tj|dS)N)_bufsizerr )r bufsizer r r r oszIncrementalParser.__init__cCspddlm}|j|}|j||j}|dkr8|j}|j|j}x|rb|j||j|j}qFW|j dS)Nr)saxutils) r*Zprepare_input_source prepareParsergetCharacterStream getByteStreamreadr(feedclose)r rr*filebufferr r r rss     zIncrementalParser.parsecCs tddS)aThis 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.z This method must be implemented!N)r)r datar r r r0szIncrementalParser.feedcCs tddS)ztThis method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.z!prepareParser must be overridden!N)r)r rr r r r,szIncrementalParser.prepareParsercCs tddS)aThis 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.z This method must be implemented!N)r)r r r r r1s zIncrementalParser.closecCs tddS)zThis 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.z This method must be implemented!N)r)r r r r resetszIncrementalParser.resetN)r6) r!r"r#r$r rr0r,r1r5r r r r r%[s   r%c@s0eZdZdZddZddZddZdd Zd S) LocatorzInterface 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)z6Return the column number where the current event ends.rr )r r r r getColumnNumberszLocator.getColumnNumbercCsdS)z4Return the line number where the current event ends.rr8r )r r r r getLineNumberszLocator.getLineNumbercCsdS)z3Return the public identifier for the current event.Nr )r r r r getPublicIdszLocator.getPublicIdcCsdS)z3Return the system identifier for the current event.Nr )r r r r getSystemIdszLocator.getSystemIdN)r!r"r#r$r9r:r;r<r r r r r7s r7c@sjeZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS) InputSourceanEncapsulation 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.NcCs"||_d|_d|_d|_d|_dS)N)_InputSource__system_id_InputSource__public_id_InputSource__encoding_InputSource__bytefile_InputSource__charfile)r system_idr r r r s zInputSource.__init__cCs ||_dS)z/Sets the public identifier of this InputSource.N)r?)r Z public_idr r r setPublicIdszInputSource.setPublicIdcCs|jS)z2Returns the public identifier of this InputSource.)r?)r r r r r;szInputSource.getPublicIdcCs ||_dS)z/Sets the system identifier of this InputSource.N)r>)r rCr r r setSystemIdszInputSource.setSystemIdcCs|jS)z2Returns the system identifier of this InputSource.)r>)r r r r r<szInputSource.getSystemIdcCs ||_dS)a4Sets 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 encodingr r r setEncodingszInputSource.setEncodingcCs|jS)z/Get the character encoding of this InputSource.)r@)r r r r getEncodingszInputSource.getEncodingcCs ||_dS)aSet 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)rA)r Zbytefiler r r setByteStreams zInputSource.setByteStreamcCs|jS)zGet the byte stream for this input source. The getEncoding method will return the character encoding for this byte stream, or None if unknown.)rA)r r r r r.szInputSource.getByteStreamcCs ||_dS)a^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)rB)r Zcharfiler r r setCharacterStreamszInputSource.setCharacterStreamcCs|jS)z/Get the character stream for this input source.)rB)r r r r r-szInputSource.getCharacterStream)N)r!r"r#r$r rDr;rEr<rGrHrIr.rJr-r r r r r=s    r=c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZd$ddZddZd d!Zd"d#ZdS)%AttributesImplcCs ||_dS)zQNon-NS-aware implementation. attrs should be of the form {name : value}.N)_attrs)r attrsr r r r szAttributesImpl.__init__cCs t|jS)N)lenrL)r r r r getLengthszAttributesImpl.getLengthcCsdS)NZCDATAr )r rr r r getType!szAttributesImpl.getTypecCs |j|S)N)rL)r rr r r getValue$szAttributesImpl.getValuecCs |j|S)N)rL)r rr r r getValueByQName'szAttributesImpl.getValueByQNamecCs||jkrt||S)N)rLKeyError)r rr r r getNameByQName*s zAttributesImpl.getNameByQNamecCs||jkrt||S)N)rLrS)r rr r r getQNameByName/s zAttributesImpl.getQNameByNamecCst|jjS)N)listrLkeys)r r r r getNames4szAttributesImpl.getNamescCst|jjS)N)rVrLrW)r r r r getQNames7szAttributesImpl.getQNamescCs t|jS)N)rNrL)r r r r __len__:szAttributesImpl.__len__cCs |j|S)N)rL)r rr r r __getitem__=szAttributesImpl.__getitem__cCst|jjS)N)rVrLrW)r r r r rW@szAttributesImpl.keyscCs ||jkS)N)rL)r rr r r __contains__CszAttributesImpl.__contains__NcCs|jj||S)N)rLget)r r alternativer r r r]FszAttributesImpl.getcCs |j|jS)N) __class__rL)r r r r copyIszAttributesImpl.copycCst|jjS)N)rVrLitems)r r r r raLszAttributesImpl.itemscCst|jjS)N)rVrLvalues)r r r r rbOszAttributesImpl.values)N)r!r"r#r rOrPrQrRrTrUrXrYrZr[rWr\r]r`rarbr r r r rKs" rKc@s<eZdZddZddZddZddZd d Zd d Zd S)AttributesNSImplcCs||_||_dS)zNS-aware implementation. attrs should be of the form {(ns_uri, lname): value, ...}. qnames of the form {(ns_uri, lname): qname, ...}.N)rL_qnames)r rMZqnamesr r r r VszAttributesNSImpl.__init__cCs6x(|jjD]\}}||kr |j|Sq Wt|dS)N)rdrarLrS)r rnsnameqnamer r r rR^sz AttributesNSImpl.getValueByQNamecCs0x"|jjD]\}}||kr |Sq Wt|dS)N)rdrarS)r rrerfr r r rTeszAttributesNSImpl.getNameByQNamecCs |j|S)N)rd)r rr r r rUlszAttributesNSImpl.getQNameByNamecCst|jjS)N)rVrdrb)r r r r rYoszAttributesNSImpl.getQNamescCs|j|j|jS)N)r_rLrd)r r r r r`rszAttributesNSImpl.copyN) r!r"r#r rRrTrUrYr`r r r r rcTs rccCstttdS)N)rr%r7r r r r _testvsrg__main__N)r$r+r _exceptionsrrrr%r7r=rKrcrgr!r r r r s PJY>"__pycache__/xmlreader.cpython-36.pyc000064400000041034152527044710013376 0ustar003 \1@sdZddlmZddlmZmZGdddZGdddeZGdd d ZGd d d Z Gd d d Z Gddde Z ddZ e dkre dS)z]An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. )handler)SAXNotSupportedExceptionSAXNotRecognizedExceptionc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd S)! XMLReadera%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) rZContentHandler _cont_handlerZ DTDHandler _dtd_handlerZEntityResolver _ent_handlerZ ErrorHandler _err_handler)selfr )/usr/lib64/python3.6/xml/sax/xmlreader.py__init__s   zXMLReader.__init__cCs tddS)zAParse an XML document from a system identifier or an InputSource.z This method must be implemented!N)NotImplementedError)r sourcer r r parseszXMLReader.parsecCs|jS)z#Returns the current ContentHandler.)r)r r r r getContentHandler"szXMLReader.getContentHandlercCs ||_dS)z:Registers a new object to receive document content events.N)r)r rr r r setContentHandler&szXMLReader.setContentHandlercCs|jS)z Returns the current DTD handler.)r)r r r r getDTDHandler*szXMLReader.getDTDHandlercCs ||_dS)z7Register an object to receive basic DTD-related events.N)r)r rr r r setDTDHandler.szXMLReader.setDTDHandlercCs|jS)z#Returns the current EntityResolver.)r)r r r r getEntityResolver2szXMLReader.getEntityResolvercCs ||_dS)z0Register an object to resolve external entities.N)r)r Zresolverr r r setEntityResolver6szXMLReader.setEntityResolvercCs|jS)z!Returns the current ErrorHandler.)r )r r r r getErrorHandler:szXMLReader.getErrorHandlercCs ||_dS)z3Register an object to receive error-message events.N)r )r rr r r setErrorHandler>szXMLReader.setErrorHandlercCs tddS)aHAllow 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.zLocale support not implementedN)r)r Zlocaler r r setLocaleBszXMLReader.setLocalecCstd|dS)z1Looks up and returns the state of a SAX2 feature.zFeature '%s' not recognizedN)r)r namer r r getFeatureKszXMLReader.getFeaturecCstd|dS)z!Sets the state of a SAX2 feature.zFeature '%s' not recognizedN)r)r rstater r r setFeatureOszXMLReader.setFeaturecCstd|dS)z2Looks up and returns the value of a SAX2 property.zProperty '%s' not recognizedN)r)r rr r r getPropertySszXMLReader.getPropertycCstd|dS)z"Sets the value of a SAX2 property.zProperty '%s' not recognizedN)r)r rvaluer r r setPropertyWszXMLReader.setPropertyN)__name__ __module__ __qualname____doc__r rrrrrrrrrrrrrr r r r r r s   rc@sBeZdZdZdddZddZdd Zd d Zd d ZddZ dS)IncrementalParserasThis 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.cCs||_tj|dS)N)_bufsizerr )r bufsizer r r r oszIncrementalParser.__init__cCspddlm}|j|}|j||j}|dkr8|j}|j|j}x|rb|j||j|j}qFW|j dS)Nr)saxutils) r*Zprepare_input_source prepareParsergetCharacterStream getByteStreamreadr(feedclose)r rr*filebufferr r r rss     zIncrementalParser.parsecCs tddS)aThis 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.z This method must be implemented!N)r)r datar r r r0szIncrementalParser.feedcCs tddS)ztThis method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.z!prepareParser must be overridden!N)r)r rr r r r,szIncrementalParser.prepareParsercCs tddS)aThis 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.z This method must be implemented!N)r)r r r r r1s zIncrementalParser.closecCs tddS)zThis 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.z This method must be implemented!N)r)r r r r resetszIncrementalParser.resetN)r6) r!r"r#r$r rr0r,r1r5r r r r r%[s   r%c@s0eZdZdZddZddZddZdd Zd S) LocatorzInterface 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)z6Return the column number where the current event ends.rr )r r r r getColumnNumberszLocator.getColumnNumbercCsdS)z4Return the line number where the current event ends.rr8r )r r r r getLineNumberszLocator.getLineNumbercCsdS)z3Return the public identifier for the current event.Nr )r r r r getPublicIdszLocator.getPublicIdcCsdS)z3Return the system identifier for the current event.Nr )r r r r getSystemIdszLocator.getSystemIdN)r!r"r#r$r9r:r;r<r r r r r7s r7c@sjeZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS) InputSourceanEncapsulation 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.NcCs"||_d|_d|_d|_d|_dS)N)_InputSource__system_id_InputSource__public_id_InputSource__encoding_InputSource__bytefile_InputSource__charfile)r system_idr r r r s zInputSource.__init__cCs ||_dS)z/Sets the public identifier of this InputSource.N)r?)r Z public_idr r r setPublicIdszInputSource.setPublicIdcCs|jS)z2Returns the public identifier of this InputSource.)r?)r r r r r;szInputSource.getPublicIdcCs ||_dS)z/Sets the system identifier of this InputSource.N)r>)r rCr r r setSystemIdszInputSource.setSystemIdcCs|jS)z2Returns the system identifier of this InputSource.)r>)r r r r r<szInputSource.getSystemIdcCs ||_dS)a4Sets 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 encodingr r r setEncodingszInputSource.setEncodingcCs|jS)z/Get the character encoding of this InputSource.)r@)r r r r getEncodingszInputSource.getEncodingcCs ||_dS)aSet 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)rA)r Zbytefiler r r setByteStreams zInputSource.setByteStreamcCs|jS)zGet the byte stream for this input source. The getEncoding method will return the character encoding for this byte stream, or None if unknown.)rA)r r r r r.szInputSource.getByteStreamcCs ||_dS)a^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)rB)r Zcharfiler r r setCharacterStreamszInputSource.setCharacterStreamcCs|jS)z/Get the character stream for this input source.)rB)r r r r r-szInputSource.getCharacterStream)N)r!r"r#r$r rDr;rEr<rGrHrIr.rJr-r r r r r=s    r=c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZd$ddZddZd d!Zd"d#ZdS)%AttributesImplcCs ||_dS)zQNon-NS-aware implementation. attrs should be of the form {name : value}.N)_attrs)r attrsr r r r szAttributesImpl.__init__cCs t|jS)N)lenrL)r r r r getLengthszAttributesImpl.getLengthcCsdS)NZCDATAr )r rr r r getType!szAttributesImpl.getTypecCs |j|S)N)rL)r rr r r getValue$szAttributesImpl.getValuecCs |j|S)N)rL)r rr r r getValueByQName'szAttributesImpl.getValueByQNamecCs||jkrt||S)N)rLKeyError)r rr r r getNameByQName*s zAttributesImpl.getNameByQNamecCs||jkrt||S)N)rLrS)r rr r r getQNameByName/s zAttributesImpl.getQNameByNamecCst|jjS)N)listrLkeys)r r r r getNames4szAttributesImpl.getNamescCst|jjS)N)rVrLrW)r r r r getQNames7szAttributesImpl.getQNamescCs t|jS)N)rNrL)r r r r __len__:szAttributesImpl.__len__cCs |j|S)N)rL)r rr r r __getitem__=szAttributesImpl.__getitem__cCst|jjS)N)rVrLrW)r r r r rW@szAttributesImpl.keyscCs ||jkS)N)rL)r rr r r __contains__CszAttributesImpl.__contains__NcCs|jj||S)N)rLget)r r alternativer r r r]FszAttributesImpl.getcCs |j|jS)N) __class__rL)r r r r copyIszAttributesImpl.copycCst|jjS)N)rVrLitems)r r r r raLszAttributesImpl.itemscCst|jjS)N)rVrLvalues)r r r r rbOszAttributesImpl.values)N)r!r"r#r rOrPrQrRrTrUrXrYrZr[rWr\r]r`rarbr r r r rKs" rKc@s<eZdZddZddZddZddZd d Zd d Zd S)AttributesNSImplcCs||_||_dS)zNS-aware implementation. attrs should be of the form {(ns_uri, lname): value, ...}. qnames of the form {(ns_uri, lname): qname, ...}.N)rL_qnames)r rMZqnamesr r r r VszAttributesNSImpl.__init__cCs6x(|jjD]\}}||kr |j|Sq Wt|dS)N)rdrarLrS)r rnsnameqnamer r r rR^sz AttributesNSImpl.getValueByQNamecCs0x"|jjD]\}}||kr |Sq Wt|dS)N)rdrarS)r rrerfr r r rTeszAttributesNSImpl.getNameByQNamecCs |j|S)N)rd)r rr r r rUlszAttributesNSImpl.getQNameByNamecCst|jjS)N)rVrdrb)r r r r rYoszAttributesNSImpl.getQNamescCs|j|j|jS)N)r_rLrd)r r r r r`rszAttributesNSImpl.copyN) r!r"r#r rRrTrUrYr`r r r r rcTs rccCstttdS)N)rr%r7r r r r _testvsrg__main__N)r$r+r _exceptionsrrrr%r7r=rKrcrgr!r r r r s PJY>"__pycache__/handler.cpython-36.opt-2.pyc000064400000010632152527044710013770 0ustar003 \b6@sdZGdddZGdddZGdddZGdddZd Zd Zd Zd Zd Z dZ eeeee e gZ dZ dZ dZdZdZdZe ee eeegZdS)z2.0betac@s$eZdZddZddZddZdS) ErrorHandlercCs|dS)N)self exceptionrr'/usr/lib64/python3.6/xml/sax/handler.pyerror szErrorHandler.errorcCs|dS)Nr)rrrrr fatalError$szErrorHandler.fatalErrorcCs t|dS)N)print)rrrrrwarning(szErrorHandler.warningN)__name__ __module__ __qualname__rrr rrrrrs rc@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)ContentHandlercCs d|_dS)N)_locator)rrrr__init__6szContentHandler.__init__cCs ||_dS)N)r)rZlocatorrrrsetDocumentLocator9sz!ContentHandler.setDocumentLocatorcCsdS)Nr)rrrr startDocumentPszContentHandler.startDocumentcCsdS)Nr)rrrr endDocumentWszContentHandler.endDocumentcCsdS)Nr)rprefixZurirrrstartPrefixMapping`sz!ContentHandler.startPrefixMappingcCsdS)Nr)rrrrrendPrefixMappingwszContentHandler.endPrefixMappingcCsdS)Nr)rnameattrsrrr startElement~szContentHandler.startElementcCsdS)Nr)rrrrr endElementszContentHandler.endElementcCsdS)Nr)rrqnamerrrrstartElementNSszContentHandler.startElementNScCsdS)Nr)rrrrrr endElementNSszContentHandler.endElementNScCsdS)Nr)rZcontentrrr charactersszContentHandler.characterscCsdS)Nr)rZ whitespacerrrignorableWhitespacesz"ContentHandler.ignorableWhitespacecCsdS)Nr)rtargetdatarrrprocessingInstructionsz$ContentHandler.processingInstructioncCsdS)Nr)rrrrr skippedEntityszContentHandler.skippedEntityN)r r r rrrrrrrrrrrrr!r"rrrrr /s    r c@seZdZddZddZdS) DTDHandlercCsdS)Nr)rrpublicIdsystemIdrrr notationDeclszDTDHandler.notationDeclcCsdS)Nr)rrr$r%ZndatarrrunparsedEntityDeclszDTDHandler.unparsedEntityDeclN)r r r r&r'rrrrr#sr#c@seZdZddZdS)EntityResolvercCs|S)Nr)rr$r%rrr resolveEntityszEntityResolver.resolveEntityN)r r r r)rrrrr(sr(z&http://xml.org/sax/features/namespacesz.http://xml.org/sax/features/namespace-prefixesz,http://xml.org/sax/features/string-interningz&http://xml.org/sax/features/validationz5http://xml.org/sax/features/external-general-entitiesz7http://xml.org/sax/features/external-parameter-entitiesz-http://xml.org/sax/properties/lexical-handlerz1http://xml.org/sax/properties/declaration-handlerz&http://xml.org/sax/properties/dom-nodez(http://xml.org/sax/properties/xml-stringz-http://www.python.org/sax/properties/encodingz3http://www.python.org/sax/properties/interning-dictN)versionrr r#r(Zfeature_namespacesZfeature_namespace_prefixesZfeature_string_interningZfeature_validationZfeature_external_gesZfeature_external_pesZ all_featuresZproperty_lexical_handlerZproperty_declaration_handlerZproperty_dom_nodeZproperty_xml_stringZproperty_encodingZproperty_interning_dictZall_propertiesrrrr s: "  __pycache__/saxutils.cpython-36.opt-1.pyc000064400000031011152527044710014220 0ustar003 \/@sdZddlZddlZddlZddlZddlZddlmZddlm Z ddZ ifdd Z ifd d Z ifd d Z ddZGdddejZGddde jZdddZdS)znA library of useful helper classes to the SAX classes, for the convenience of application and driver writers. N)handler) xmlreadercCs&x |jD]\}}|j||}q W|S)z2Replace substrings of a string using a dictionary.)itemsreplace)sdkeyvaluer (/usr/lib64/python3.6/xml/sax/saxutils.py__dict_replace sr cCs6|jdd}|jdd}|jdd}|r2t||}|S)zEscape &, <, 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. &z&>z> 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. z z z )   "'z"%s"z"z'%s')copyupdaterr)rrr r r quoteattr0s   rcsdkrddl}|jSttjr&Sttjtjfr<SttjrlGfddd}|}dd|_ nDtj }dd|_ j |_ yj |_ j|_Wntk rYnXtj||ddd d S) NrcseZdZjZfddZdS)z _gettextwriter.._wrappercs t|S)N)getattr)selfname)outr r __getattr__[sz,_gettextwriter.._wrapper.__getattr__N)__name__ __module__ __qualname__ __class__r!r )r r r _wrapperYsr&cSsdS)Nr r r r r ^sz _gettextwriter..cSsdS)NTr r r r r r'csxmlcharrefreplacerT)encodingerrorsnewline write_through)sysstdout isinstanceio TextIOBasecodecs StreamWriterStreamReaderWriter RawIOBasecloseBufferedIOBasewritablewriteseekabletellAttributeError TextIOWrapper)r r)r-r&bufferr )r r _gettextwriterHs.     r?c@seZdZd ddZddZd!dd Zd d Zd d ZddZddZ ddZ ddZ ddZ ddZ ddZddZddZdS)" XMLGeneratorN iso-8859-1FcCsVtjj|t||}|j|_|j|_ig|_|jd|_ g|_ ||_ ||_ d|_ dS)NrF)rContentHandler__init__r?r9_writeflush_flush _ns_contexts_current_context_undeclared_ns_maps _encoding_short_empty_elements_pending_start_element)rr r)Zshort_empty_elementsr r r rDss   zXMLGenerator.__init__cCsJ|drBd|dkr d|dS|j|d}|rB|d|dS|dS)z7Builds a qualified name from a (ns_url, localname) pairrz$http://www.w3.org/XML/1998/namespacezxml:r:)rI)rrprefixr r r _qnames  zXMLGenerator._qnamecCs|jr|jdd|_dS)NrF)rMrE)r endElementr r r _finish_pending_start_elements z*XMLGenerator._finish_pending_start_elementcCs|jd|jdS)Nz$ )rErK)rr r r startDocumentszXMLGenerator.startDocumentcCs |jdS)N)rG)rr r r endDocumentszXMLGenerator.endDocumentcCs0|jj|jj||j|<|jj||fdS)N)rHappendrIrrJ)rrOurir r r startPrefixMappings zXMLGenerator.startPrefixMappingcCs|jd|_|jd=dS)NrrBrB)rHrI)rrOr r r endPrefixMappings zXMLGenerator.endPrefixMappingcCs^|j|jd|x*|jD]\}}|jd|t|fq W|jrPd|_n |jddS)Nrz %s=%sTr)rRrErrrLrM)rrattrsr r r r startElementszXMLGenerator.startElementcCs*|jr|jdd|_n|jd|dS)Nz/>Fz)rMrE)rrr r r rQs zXMLGenerator.endElementcCs|j|jd|j|x8|jD].\}}|rD|jd||fq$|jd|q$Wg|_x0|jD]$\}}|jd|j|t|fqfW|jrd|_n |jddS)Nrz xmlns:%s="%s"z xmlns="%s"z %s=%sTr)rRrErPrJrrrLrM)rrqnamerYrOrVr r r r startElementNSs zXMLGenerator.startElementNScCs0|jr|jdd|_n|jd|j|dS)Nz/>Fz)rMrErP)rrr[r r r endElementNSs zXMLGenerator.endElementNScCs4|r0|jt|ts"t||j}|jt|dS)N)rRr/strrKrEr)rcontentr r r characterss   zXMLGenerator.characterscCs0|r,|jt|ts"t||j}|j|dS)N)rRr/r^rKrE)rr_r r r ignorableWhitespaces   z XMLGenerator.ignorableWhitespacecCs|j|jd||fdS)Nz )rRrE)rtargetrr r r processingInstructionsz"XMLGenerator.processingInstruction)NrAF)F)r"r#r$rDrPrRrSrTrWrXrZrQr\r]r`rarcr r r r r@qs   r@c@seZdZdZd;ddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:ZdS)< XMLFilterBaseaYThis 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.NcCstjj|||_dS)N)r XMLReaderrD_parent)rparentr r r rDs zXMLFilterBase.__init__cCs|jj|dS)N) _err_handlererror)r exceptionr r r riszXMLFilterBase.errorcCs|jj|dS)N)rh fatalError)rrjr r r rkszXMLFilterBase.fatalErrorcCs|jj|dS)N)rhwarning)rrjr r r rlszXMLFilterBase.warningcCs|jj|dS)N) _cont_handlersetDocumentLocator)rZlocatorr r r rnsz XMLFilterBase.setDocumentLocatorcCs|jjdS)N)rmrS)rr r r rSszXMLFilterBase.startDocumentcCs|jjdS)N)rmrT)rr r r rTszXMLFilterBase.endDocumentcCs|jj||dS)N)rmrW)rrOrVr r r rWsz XMLFilterBase.startPrefixMappingcCs|jj|dS)N)rmrX)rrOr r r rX szXMLFilterBase.endPrefixMappingcCs|jj||dS)N)rmrZ)rrrYr r r rZ szXMLFilterBase.startElementcCs|jj|dS)N)rmrQ)rrr r r rQszXMLFilterBase.endElementcCs|jj|||dS)N)rmr\)rrr[rYr r r r\szXMLFilterBase.startElementNScCs|jj||dS)N)rmr])rrr[r r r r]szXMLFilterBase.endElementNScCs|jj|dS)N)rmr`)rr_r r r r`szXMLFilterBase.characterscCs|jj|dS)N)rmra)rcharsr r r rasz!XMLFilterBase.ignorableWhitespacecCs|jj||dS)N)rmrc)rrbrr r r rcsz#XMLFilterBase.processingInstructioncCs|jj|dS)N)rm skippedEntity)rrr r r rp!szXMLFilterBase.skippedEntitycCs|jj|||dS)N) _dtd_handler notationDecl)rrpublicIdsystemIdr r r rr&szXMLFilterBase.notationDeclcCs|jj||||dS)N)rqunparsedEntityDecl)rrrsrtZndatar r r ru)sz XMLFilterBase.unparsedEntityDeclcCs|jj||S)N)Z _ent_handler resolveEntity)rrsrtr r r rv.szXMLFilterBase.resolveEntitycCs@|jj||jj||jj||jj||jj|dS)N)rfZsetContentHandlerZsetErrorHandlerZsetEntityResolverZ setDTDHandlerparse)rsourcer r r rw3s     zXMLFilterBase.parsecCs|jj|dS)N)rf setLocale)rZlocaler r r ry:szXMLFilterBase.setLocalecCs |jj|S)N)rf getFeature)rrr r r rz=szXMLFilterBase.getFeaturecCs|jj||dS)N)rf setFeature)rrstater r r r{@szXMLFilterBase.setFeaturecCs |jj|S)N)rf getProperty)rrr r r r}CszXMLFilterBase.getPropertycCs|jj||dS)N)rf setProperty)rrr r r r r~FszXMLFilterBase.setPropertycCs|jS)N)rf)rr r r getParentKszXMLFilterBase.getParentcCs ||_dS)N)rf)rrgr r r setParentNszXMLFilterBase.setParent)N) r"r#r$__doc__rDrirkrlrnrSrTrWrXrZrQr\r]r`rarcrprrrurvrwryrzr{r}r~rrr r r r rds: rdcCs t|trtj|}n^t|drt|}tj}t|jdtrH|j|n |j|t|drtt|jtrt|j |j|j dko|j dkr|j }t jjt jj|}t jj||}t jj|r|j |t|d}n$|j tjj||tjj|j }|j||S)zThis function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.readrrNrb)r/r^rZ InputSourcehasattrrZsetCharacterStreamZ setByteStreamrZ setSystemIdZgetCharacterStreamZ getByteStreamZ getSystemIdospathdirnamenormpathjoinisfileopenurllibrwZurljoinZrequestZurlopen)rxbasefZsysidZbaseheadZ sysidfilenamer r r prepare_input_sourceSs*          r)r)rrZ urllib.parserZurllib.requestr0r2rrrr rrrr?rCr@rerdrr r r r s     )so__pycache__/__init__.cpython-36.pyc000064400000006132152527044710013152 0ustar003 \.@sdZddlmZddlmZmZddlmZmZm Z m Z m Z efddZ efddZ d gZd Zernd d lZd d lZd d lZejj rd ejkrejd jd Z[dZejd ddkrejjerejjejd ZgfddZejd ddkrddZnddZ[d S)aSimple 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. ) InputSource)ContentHandler ErrorHandler) SAXExceptionSAXNotRecognizedExceptionSAXParseExceptionSAXNotSupportedExceptionSAXReaderNotAvailablecCs(t}|j||j||j|dS)N) make_parsersetContentHandlersetErrorHandlerparse)sourcehandler errorHandlerparserr(/usr/lib64/python3.6/xml/sax/__init__.pyr s  r cCspddl}|dkrt}t}|j||j|t}t|trR|j|j |n|j |j ||j |dS)N) iorr r r r isinstancestrZsetCharacterStreamStringIOZ setByteStreamBytesIOr )stringrrrrZinpsrcrrr parseString#s   rzxml.sax.expatreaderrNZ PY_SAX_PARSER,zpython.xml.sax.parserjavacCsrxb|tD]V}yt|Stk rL}zddl}||jkr<WYdd}~Xq tk r^Yq Xq WtdddS)a&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.rNzNo parsers found)default_parser_list_create_parser ImportErrorsysmodulesr )Z parser_list parser_nameer"rrrr Fs  r cCs$ddlm}|j|dt}|jS)Nr)imp)Zorg.python.corer&Z importNameglobals create_parser)r$r& drv_modulerrrr as r cCst|iidg}|jS)Nr() __import__r()r$r)rrrr gs)__doc__Z xmlreaderrrrr _exceptionsrrrrr r rr_falseZxml.sax.expatreaderZxmlosr"flagsignore_environmentenvironsplitZ_keyplatformregistryZ containsKeyZ getPropertyr r rrrrs*