Mini Shell

Direktori : /usr/lib64/python3.9/xml/sax/__pycache__/
Upload File :
Current File : //usr/lib64/python3.9/xml/sax/__pycache__/xmlreader.cpython-39.pyc

a

�DOg�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
�)/usr/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�localer
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)
�r8Zprepare_input_source�
prepareParser�getCharacterStream�
getByteStream�readr6�feed�close)rrr8�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
rr:�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)r5)
r0r1r2r3rrr>r:r?rCr
r
r
rr4[s
	
r4c@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.rEr
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)r0r1r2r3rFrGrHrIr
r
r
rrD�s
rDc@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�rL)rZ	public_idr
r
r�setPublicId�szInputSource.setPublicIdcCs|jS)z2Returns the public identifier of this InputSource.rQrr
r
rrH�szInputSource.getPublicIdcCs
||_dS)z/Sets the system identifier of this InputSource.N�rKrPr
r
r�setSystemId�szInputSource.setSystemIdcCs|jS)z2Returns the system identifier of this InputSource.rSrr
r
rrI�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�rM)r�encodingr
r
r�setEncoding�szInputSource.setEncodingcCs|jS)z/Get the character encoding of this InputSource.rUrr
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�rN)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.rYrr
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�rO)rZcharfiler
r
r�setCharacterStreamszInputSource.setCharacterStreamcCs|jS)z/Get the character stream for this input source.r[rr
r
rr;szInputSource.getCharacterStream)N)r0r1r2r3rrRrHrTrIrWrXrZr<r\r;r
r
r
rrJ�s



rJc@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|��|Srrgr'r
r
r�getQNameByName/s
zAttributesImpl.getQNameByNamecCst|j���Sr��listr_�keysrr
r
r�getNames4szAttributesImpl.getNamescCst|j���Srrkrr
r
r�	getQNames7szAttributesImpl.getQNamescCs
t|j�Srrarr
r
r�__len__:szAttributesImpl.__len__cCs
|j|Srr^r'r
r
r�__getitem__=szAttributesImpl.__getitem__cCst|j���Srrkrr
r
rrm@szAttributesImpl.keyscCs
||jvSrr^r'r
r
r�__contains__CszAttributesImpl.__contains__NcCs|j�||�Sr)r_�get)rr(�alternativer
r
rrsFszAttributesImpl.getcCs|�|j�Sr)�	__class__r_rr
r
r�copyIszAttributesImpl.copycCst|j���Sr)rlr_�itemsrr
r
rrwLszAttributesImpl.itemscCst|j���Sr)rlr_�valuesrr
r
rrxOszAttributesImpl.values)N)r0r1r2rrcrdrerfrirjrnrorprqrmrrrsrvrwrxr
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)rzrwr_rh�rr(ZnsnameZqnamer
r
rrf^sz AttributesNSImpl.getValueByQNamecCs0|j��D]\}}||kr
|Sq
t|��dSr)rzrwrhr{r
r
rries
zAttributesNSImpl.getNameByQNamecCs
|j|Sr)rzr'r
r
rrjlszAttributesNSImpl.getQNameByNamecCst|j���Sr)rlrzrxrr
r
rrooszAttributesNSImpl.getQNamescCs|�|j|j�Sr)rur_rzrr
r
rrvrszAttributesNSImpl.copyN)	r0r1r2rrfrirjrorvr
r
r
rryTsrycCst�t�t�dSr)rr4rDr
r
r
r�_testvsr|�__main__N)r3r9r�_exceptionsrrrr4rDrJr]ryr|r0r
r
r
r�<module>sPJY>"

Zerion Mini Shell 1.0