%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core18/3267/usr/lib/python3.6/html/__pycache__/
Upload File :
Create Path :
Current File : //snap/core18/3267/usr/lib/python3.6/html/__pycache__/parser.cpython-36.pyc

3

�نj�M�@s�dZddlZddlZddlZddlmZdgZejd�Zejd�Z	ejd�Z
ejd�Zejd	�Zejd
�Z
ejd�Zejd�Zejd
�Zejd�Zejdej�Zejd�Zejd�ZGdd�dej�ZdS)zA parser for HTML and XHTML.�N)�unescape�
HTMLParserz[&<]z
&[a-zA-Z#]z%&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]z)&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]z	<[a-zA-Z]z
</[a-zA-Z]�>z--\s*>z+([a-zA-Z][^\t\n\r\f />\x00]*)(?:\s|/(?!>))*z]((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*aF
  <[a-zA-Z][^\t\n\r\f />\x00]*       # tag name
  (?:[\s/]*                          # optional whitespace before attribute name
    (?:(?<=['"\s/])[^\s/>][^\s/=>]*  # attribute name
      (?:\s*=+\s*                    # value indicator
        (?:'[^']*'                   # LITA-enclosed value
          |"[^"]*"                   # LIT-enclosed value
          |(?!['"])[^>\s]*           # bare value
         )
         (?:\s*,)*                   # possibly followed by a comma
       )?(?:\s|/(?!>))*
     )*
   )?
  \s*                                # trailing whitespace
z#</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>c@s�eZdZdZd:Zdd�dd�Zdd	�Zd
d�Zdd
�ZdZ	dd�Z
dd�Zdd�Zdd�Z
dd�Zd;dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�ZdS)<raEFind tags and other markup and call handler functions.

    Usage:
        p = HTMLParser()
        p.feed(data)
        ...
        p.close()

    Start tags are handled by calling self.handle_starttag() or
    self.handle_startendtag(); end tags by self.handle_endtag().  The
    data between tags is passed from the parser to the derived class
    by calling self.handle_data() with the data as argument (the data
    may be split up in arbitrary chunks).  If convert_charrefs is
    True the character references are converted automatically to the
    corresponding Unicode character (and self.handle_data() is no
    longer split in chunks), otherwise they are passed by calling
    self.handle_entityref() or self.handle_charref() with the string
    containing respectively the named or numeric reference as the
    argument.
    �script�styleT)�convert_charrefscCs||_|j�dS)z�Initialize and reset this instance.

        If convert_charrefs is True (the default), all character references
        are automatically converted to the corresponding Unicode characters.
        N)r�reset)�selfr�r
�!/usr/lib/python3.6/html/parser.py�__init__XszHTMLParser.__init__cCs:d|_d|_t|_d|_g|_d|_d|_tj	j
|�dS)z1Reset this instance.  Loses all unprocessed data.�z???Nr�)�rawdata�lasttag�interesting_normal�interesting�
cdata_elem�_pending�_pending_len�_parse_threshold�_markupbase�
ParserBaser)r	r
r
rraszHTMLParser.resetcCs�|jt|�7_|j|jkr,|jj|�n~|jsB|j|7_n,|jj|�|jdj|j�7_|jj�d|_t|j�}|jd�t|j�|kr�d|_nt|j�|_dS)z�Feed data to the parser.

        Call this as often as you want, with as little or as much text
        as you want (may include '\n').
        r
rrN)	r�lenrr�appendr�join�clear�goahead)r	�data�nr
r
r�feedls



zHTMLParser.feedcCs:|jr,|jdj|j�7_|jj�d|_|jd�dS)zHandle any buffered data.r
rrN)rrrrrr)r	r
r
r�close�s

zHTMLParser.closeNcCs|jS)z)Return full source of start tag: '<...>'.)�_HTMLParser__starttag_text)r	r
r
r�get_starttag_text�szHTMLParser.get_starttag_textcCs$|j�|_tjd|jtj�|_dS)Nz</\s*%s\s*>)�lowerr�re�compile�Ir)r	�elemr
r
r�set_cdata_mode�s
zHTMLParser.set_cdata_modecCst|_d|_dS)N)rrr)r	r
r
r�clear_cdata_mode�szHTMLParser.clear_cdata_modecCsB|j}d}t|�}�x�||k�r�|jr||jr||jd|�}|dkr�|jdt||d��}|dkrvtjd�j	||�rvP|}n(|j
j	||�}|r�|j�}n|jr�P|}||kr�|jr�|jr�|jt
|||���n|j|||��|j||�}||kr�P|j}|d|��r4tj||��r&|j|�}	n�|d|��r>|j|�}	nr|d|��rV|j|�}	nZ|d|��rn|j|�}	nB|d	|��r�|j|�}	n*|d
|k�s�|�r�|jd�|d
}	nP|	dk�r&|�s�Ptj||��rԐnN|d|��r$|d|k�r�|jd�n&tj||��r
n|j||dd���n�|d|��r||}x.dD]&}
|j|
|d��r:|t|
�8}P�q:W|j||d|��n�|d|��r�|j||dd��n�|||d�j�dk�r�|j||dd��nP|d	|��r�|j||dd��n,|d|��r|j||dd��ntd��|}	|j||	�}q|d|��r�tj||�}|�r�|j �dd�}|j!|�|j"�}	|d|	d
��s�|	d
}	|j||	�}qn:d||d�k�r�|j|||d��|j||d�}Pq|d|��r�t#j||�}|�r8|j d
�}|j$|�|j"�}	|d|	d
��s*|	d
}	|j||	�}qt%j||�}|�r�|�r�|j �||d�k�r�|j"�}	|	|k�r||}	|j||d
�}Pn,|d
|k�r�|jd�|j||d
�}nPqdstd��qW|�r0||k�r0|j�r0|j�r|j�r|jt
|||���n|j|||��|j||�}||d�|_dS)Nr�<�&�"z[\s;]z</z<!--z<?z<!r��--!�--�-�z	<![CDATA[��	z	<!doctypezwe should not get here!z&#�;zinteresting.search() lied)r/r0r1���)&rrrr�find�rfind�maxr%r&�searchr�start�handle_datarZ	updatepos�
startswith�starttagopen�match�parse_starttag�parse_endtag�
parse_comment�parse_pi�parse_html_declaration�
endtagopen�handle_comment�endswith�unknown_declr$�handle_decl�	handle_pi�AssertionError�charref�group�handle_charref�end�	entityref�handle_entityref�
incomplete)r	rOr�ir�jZampposr?r=�k�suffix�namer
r
rr�s�









zHTMLParser.goaheadcCs�|j}|||d�dks"td��|||d�dkr@|j|�S|||d�dkr^|j|�S|||d�j�d	kr�|jd
|d�}|dkr�d
S|j||d|��|dS|j|�SdS)Nr.z<!z+unexpected call to parse_html_declaration()r2z<!--r3z<![r4z	<!doctyperrr6r6)rrKrBZparse_marked_sectionr$r7rI�parse_bogus_comment)r	rSr�gtposr
r
rrD/s

z!HTMLParser.parse_html_declarationrcCs`|j}|||d�dks"td��|jd|d�}|dkr>d	S|rX|j||d|��|dS)
Nr.�<!�</z"unexpected call to parse_comment()rr)rZr[r6r6)rrKr7rF)r	rSZreportr�posr
r
rrXDszHTMLParser.parse_bogus_commentcCsd|j}|||d�dks"td��tj||d�}|s:dS|j�}|j||d|��|j�}|S)Nr.z<?zunexpected call to parse_pi()rr6)rrK�picloser:r;rJrO)r	rSrr?rTr
r
rrCPszHTMLParser.parse_picCs�d|_|j|�}|dkr|S|j}|||�|_g}tj||d�}|sPtd��|j�}|jd�j�|_	}x�||k�r0t
j||�}|s�P|jddd�\}	}
}|
s�d}n^|dd�dko�|dd�knp�|dd�dko�|dd�kn�r|dd
�}|�rt|�}|j|	j�|f�|j�}qnW|||�j
�}|dk�r�|j�\}
}d
|jk�r�|
|jjd
�}
t|j�|jjd
�}n|t|j�}|j|||��|S|jd	��r�|j||�n"|j||�||jk�r�|j|�|S)Nrrz#unexpected call to parse_starttag()r.r3�'�"r�/>�
r6r6r6)rr`)r"�check_for_whole_start_tagr�tagfind_tolerantr?rKrOrMr$r�attrfind_tolerantrr�stripZgetpos�countrr8r<rG�handle_startendtag�handle_starttag�CDATA_CONTENT_ELEMENTSr))r	rS�endposr�attrsr?rU�tag�mZattrname�restZ	attrvaluerO�lineno�offsetr
r
rr@\sR
(*

zHTMLParser.parse_starttagcCs�|j}tj||�}|r�|j�}|||d�}|dkr>|dS|dkr~|jd|�rZ|dS|jd|�rjd	S||krv|S|dS|dkr�d
S|dkr�dS||kr�|S|dStd��dS)Nrr�/z/>r.r
z6abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZzwe should not get here!r6r6r6)r�locatestarttagend_tolerantr?rOr=rK)r	rSrrmrT�nextr
r
rrb�s.z$HTMLParser.check_for_whole_start_tagcCs2|j}|||d�dks"td��tj||d�}|s:dS|j�}tj||�}|s�|jdk	rr|j|||��|St	j||d�}|s�|||d�dkr�|dS|j
|�S|jd�j�}|j
d|j��}|j|�|dS|jd�j�}|jdk	�r||jk�r|j|||��|S|j|j��|j�|S)	Nr.z</zunexpected call to parse_endtagrr3z</>rr6)rrK�	endendtagr:rO�
endtagfindr?rr<rcrXrMr$r7�
handle_endtagr*)r	rSrr?rYZ	namematchZtagnamer(r
r
rrA�s8


zHTMLParser.parse_endtagcCs|j||�|j|�dS)N)rhrv)r	rlrkr
r
rrg�szHTMLParser.handle_startendtagcCsdS)Nr
)r	rlrkr
r
rrh�szHTMLParser.handle_starttagcCsdS)Nr
)r	rlr
r
rrv�szHTMLParser.handle_endtagcCsdS)Nr
)r	rWr
r
rrN�szHTMLParser.handle_charrefcCsdS)Nr
)r	rWr
r
rrQ�szHTMLParser.handle_entityrefcCsdS)Nr
)r	rr
r
rr<�szHTMLParser.handle_datacCsdS)Nr
)r	rr
r
rrF�szHTMLParser.handle_commentcCsdS)Nr
)r	Zdeclr
r
rrI�szHTMLParser.handle_declcCsdS)Nr
)r	rr
r
rrJ�szHTMLParser.handle_picCsdS)Nr
)r	rr
r
rrH�szHTMLParser.unknown_declcCstjdtdd�t|�S)NzZThe unescape method is deprecated and will be removed in 3.5, use html.unescape() instead.r.)�
stacklevel)�warnings�warn�DeprecationWarningr)r	�sr
r
rrs
zHTMLParser.unescape)rr)r)�__name__�
__module__�__qualname__�__doc__rirrr r!r"r#r)r*rrDrXrCr@rbrArgrhrvrNrQr<rFrIrJrHrr
r
r
rr@s:	

3"()rr%rxrZhtmlr�__all__r&rrRrPrLr>rEr]Zcommentclosercrd�VERBOSErrrtrurrr
r
r
r�<module>s*














Zerion Mini Shell 1.0