Hacked By AnonymousFox

Current Path : /opt/alt/python39/lib64/python3.9/xml/sax/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/xml/sax/__pycache__/xmlreader.cpython-39.opt-1.pyc

a

R�f�1�@s�dZddlmZddlmZmZGdd�d�ZGdd�de�ZGdd	�d	�ZGd
d�d�Z	Gdd
�d
�Z
Gdd�de
�Zdd�Ze
dkr�e�dS)z]An XML Reader is the SAX 2 name for an XML parser. XML Parsers
should be based on this code. �)�handler)�SAXNotSupportedException�SAXNotRecognizedExceptionc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd 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,t��|_t��|_t��|_t��|_dS�N)	rZContentHandler�
_cont_handlerZ
DTDHandler�_dtd_handlerZEntityResolver�_ent_handlerZErrorHandler�_err_handler��self�r
�6/opt/alt/python39/lib64/python3.9/xml/sax/xmlreader.py�__init__s


zXMLReader.__init__cCstd��dS)zAParse an XML document from a system identifier or an InputSource.� This method must be implemented!N��NotImplementedError�r�sourcer
r
r�parseszXMLReader.parsecCs|jS)z#Returns the current ContentHandler.�rrr
r
r�getContentHandler"szXMLReader.getContentHandlercCs
||_dS)z:Registers a new object to receive document content events.Nr�rrr
r
r�setContentHandler&szXMLReader.setContentHandlercCs|jS)z Returns the current DTD handler.�rrr
r
r�
getDTDHandler*szXMLReader.getDTDHandlercCs
||_dS)z7Register an object to receive basic DTD-related events.Nrrr
r
r�
setDTDHandler.szXMLReader.setDTDHandlercCs|jS)z#Returns the current EntityResolver.�r	rr
r
r�getEntityResolver2szXMLReader.getEntityResolvercCs
||_dS)z0Register an object to resolve external entities.Nr)rZresolverr
r
r�setEntityResolver6szXMLReader.setEntityResolvercCs|jS)z!Returns the current ErrorHandler.�r
rr
r
r�getErrorHandler:szXMLReader.getErrorHandlercCs
||_dS)z3Register an object to receive error-message events.Nr rr
r
r�setErrorHandler>szXMLReader.setErrorHandlercCstd��dS)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.�Feature '%s' not recognizedN�r�r�namer
r
r�
getFeatureKszXMLReader.getFeaturecCstd|��dS)z!Sets the state of a SAX2 feature.r$Nr%)rr'�stater
r
r�
setFeatureOszXMLReader.setFeaturecCstd|��dS)z2Looks up and returns the value of a SAX2 property.�Property '%s' not recognizedNr%r&r
r
r�getPropertySszXMLReader.getPropertycCstd|��dS)z"Sets the value of a SAX2 property.r+Nr%)rr'�valuer
r
r�setPropertyWszXMLReader.setPropertyN)�__name__�
__module__�__qualname__�__doc__rrrrrrrrr!r"r#r(r*r,r.r
r
r
rrs 	rc@sBeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	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||_t�|�dSr)�_bufsizerr)r�bufsizer
r
rroszIncrementalParser.__init__cCslddlm}|�|�}|�|�|��}|dur8|��}|�|j�}|r`|�|�|�|j�}qD|�	�dS)Nr)�saxutils)
�r7Zprepare_input_source�
prepareParser�getCharacterStream�
getByteStream�readr5�feed�close)rrr7�file�bufferr
r
rrss


zIncrementalParser.parsecCstd��dS)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.rNr)r�datar
r
rr=�szIncrementalParser.feedcCstd��dS)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!Nrrr
r
rr9�szIncrementalParser.prepareParsercCstd��dS)a�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.rNrrr
r
rr>�szIncrementalParser.closecCstd��dS)z�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.rNrrr
r
r�reset�szIncrementalParser.resetN)r4)
r/r0r1r2rrr=r9r>rBr
r
r
rr3[s
	
r3c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Locatorz�Interface for associating a SAX event with a document
    location. A locator object will return valid results only during
    calls to DocumentHandler methods; at any other time, the
    results are unpredictable.cCsdS)z6Return the column number where the current event ends.���r
rr
r
r�getColumnNumber�szLocator.getColumnNumbercCsdS)z4Return the line number where the current event ends.rDr
rr
r
r�
getLineNumber�szLocator.getLineNumbercCsdS)z3Return the public identifier for the current event.Nr
rr
r
r�getPublicId�szLocator.getPublicIdcCsdS)z3Return the system identifier for the current event.Nr
rr
r
r�getSystemId�szLocator.getSystemIdN)r/r0r1r2rErFrGrHr
r
r
rrC�s
rCc@sjeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�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|_dSr)�_InputSource__system_id�_InputSource__public_id�_InputSource__encoding�_InputSource__bytefile�_InputSource__charfile�rZ	system_idr
r
rr�s
zInputSource.__init__cCs
||_dS)z/Sets the public identifier of this InputSource.N�rK)rZ	public_idr
r
r�setPublicId�szInputSource.setPublicIdcCs|jS)z2Returns the public identifier of this InputSource.rPrr
r
rrG�szInputSource.getPublicIdcCs
||_dS)z/Sets the system identifier of this InputSource.N�rJrOr
r
r�setSystemId�szInputSource.setSystemIdcCs|jS)z2Returns the system identifier of this InputSource.rRrr
r
rrH�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�rL)r�encodingr
r
r�setEncoding�szInputSource.setEncodingcCs|jS)z/Get the character encoding of this InputSource.rTrr
r
r�getEncoding�szInputSource.getEncodingcCs
||_dS)a�Set the byte stream (a Python file-like object which does
        not perform byte-to-character conversion) for this input
        source.

        The SAX parser will ignore this if there is also a character
        stream specified, but it will use a byte stream in preference
        to opening a URI connection itself.

        If the application knows the character encoding of the byte
        stream, it should set it with the setEncoding method.N�rM)rZbytefiler
r
r�
setByteStream�szInputSource.setByteStreamcCs|jS)z�Get the byte stream for this input source.

        The getEncoding method will return the character encoding for
        this byte stream, or None if unknown.rXrr
r
rr;�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�rN)rZcharfiler
r
r�setCharacterStreamszInputSource.setCharacterStreamcCs|jS)z/Get the character stream for this input source.rZrr
r
rr:szInputSource.getCharacterStream)N)r/r0r1r2rrQrGrSrHrVrWrYr;r[r:r
r
r
rrI�s



rIc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd$dd�Zdd�Zd d!�Zd"d#�ZdS)%�AttributesImplcCs
||_dS)zQNon-NS-aware implementation.

        attrs should be of the form {name : value}.N��_attrs)r�attrsr
r
rrszAttributesImpl.__init__cCs
t|j�Sr��lenr^rr
r
r�	getLengthszAttributesImpl.getLengthcCsdS)NZCDATAr
r&r
r
r�getType!szAttributesImpl.getTypecCs
|j|Srr]r&r
r
r�getValue$szAttributesImpl.getValuecCs
|j|Srr]r&r
r
r�getValueByQName'szAttributesImpl.getValueByQNamecCs||jvrt|��|Sr�r^�KeyErrorr&r
r
r�getNameByQName*s
zAttributesImpl.getNameByQNamecCs||jvrt|��|Srrfr&r
r
r�getQNameByName/s
zAttributesImpl.getQNameByNamecCst|j���Sr��listr^�keysrr
r
r�getNames4szAttributesImpl.getNamescCst|j���Srrjrr
r
r�	getQNames7szAttributesImpl.getQNamescCs
t|j�Srr`rr
r
r�__len__:szAttributesImpl.__len__cCs
|j|Srr]r&r
r
r�__getitem__=szAttributesImpl.__getitem__cCst|j���Srrjrr
r
rrl@szAttributesImpl.keyscCs
||jvSrr]r&r
r
r�__contains__CszAttributesImpl.__contains__NcCs|j�||�Sr)r^�get)rr'Zalternativer
r
rrrFszAttributesImpl.getcCs|�|j�Sr)�	__class__r^rr
r
r�copyIszAttributesImpl.copycCst|j���Sr)rkr^�itemsrr
r
rruLszAttributesImpl.itemscCst|j���Sr)rkr^�valuesrr
r
rrvOszAttributesImpl.values)N)r/r0r1rrbrcrdrerhrirmrnrorprlrqrrrtrurvr
r
r
rr\s"
r\c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�AttributesNSImplcCs||_||_dS)z�NS-aware implementation.

        attrs should be of the form {(ns_uri, lname): value, ...}.
        qnames of the form {(ns_uri, lname): qname, ...}.N)r^�_qnames)rr_Zqnamesr
r
rrVszAttributesNSImpl.__init__cCs6|j��D]\}}||kr
|j|Sq
t|��dSr)rxrur^rg�rr'ZnsnameZqnamer
r
rre^sz AttributesNSImpl.getValueByQNamecCs0|j��D]\}}||kr
|Sq
t|��dSr)rxrurgryr
r
rrhes
zAttributesNSImpl.getNameByQNamecCs
|j|Sr)rxr&r
r
rrilszAttributesNSImpl.getQNameByNamecCst|j���Sr)rkrxrvrr
r
rrnoszAttributesNSImpl.getQNamescCs|�|j|j�Sr)rsr^rxrr
r
rrtrszAttributesNSImpl.copyN)	r/r0r1rrerhrirnrtr
r
r
rrwTsrwcCst�t�t�dSr)rr3rCr
r
r
r�_testvsrz�__main__N)r2r8r�_exceptionsrrrr3rCrIr\rwrzr/r
r
r
r�<module>sPJY>"

Hacked By AnonymousFox1.0, Coded By AnonymousFox