Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib/python3.7/site-packages/future/backports/html/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/future/backports/html/__pycache__/parser.cpython-37.pyc

B

�A�[:M�@sdZddlmZmZmZmZddlTddlmZddl	Z	ddl
Z
e	�d�Ze	�d�Z
e	�d�Ze	�d	�Ze	�d
�Ze	�d�Ze	�d�Ze	�d
�Ze	�d�Ze	�d�Ze	�d�Ze	�de	j�Ze	�de	j�Ze	�d�Ze	�d�ZGdd�de�ZGdd�dej�ZdS)zLA parser for HTML and XHTML.

Backported for python-future from Python 3.3.
�)�absolute_import�division�print_function�unicode_literals)�*)�_markupbaseNz[&<]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--\s*>z(([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*z[a-zA-Z][^	

 />]*zJ\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*(\'[^\']*\'|"[^"]*"|[^\s"\'=<>`]*))?z]((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*a�
  <[a-zA-Z][-.a-zA-Z0-9:_]*          # tag name
  (?:\s+                             # whitespace before attribute name
    (?:[a-zA-Z_][-.:a-zA-Z0-9_]*     # attribute name
      (?:\s*=\s*                     # value indicator
        (?:'[^']*'                   # LITA-enclosed value
          |\"[^\"]*\"                # LIT-enclosed value
          |[^'\">\s]+                # bare value
         )
       )?
     )
   )*
  \s*                                # trailing whitespace
aF
  <[a-zA-Z][-.a-zA-Z0-9:_]*          # 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"eZdZdZddd�Zdd�ZdS)	�HTMLParseErrorz&Exception raised for all parse errors.�NNcCs&|st�||_|d|_|d|_dS)Nr�)�AssertionError�msg�lineno�offset)�selfr
�position�r�M/opt/alt/python37/lib/python3.7/site-packages/future/backports/html/parser.py�__init__Us
zHTMLParseError.__init__cCs>|j}|jdk	r|d|j}|jdk	r:|d|jd}|S)Nz, at line %dz, column %dr)r
rr)r�resultrrr�__str__[s

zHTMLParseError.__str__N)r
)�__name__�
__module__�__qualname__�__doc__rrrrrrr	Rs
r	c@s�eZdZdZdZd:dd�Zdd�Zdd	�Zd
d�Zdd
�Z	dZ
dd�Zdd�Zdd�Z
dd�Zdd�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)<�
HTMLParsera�Find 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).  Entity references are
    passed by calling self.handle_entityref() with the entity
    reference as the argument.  Numeric character references are
    passed to self.handle_charref() with the string containing the
    reference as the argument.
    )�script�styleFcCs&|rtjdtdd�||_|��dS)z�Initialize and reset this instance.

        If strict is set to False (the default) the parser will parse invalid
        markup, otherwise it will raise an error.  Note that the strict mode
        is deprecated.
        zThe strict mode is deprecated.�)�
stacklevelN)�warnings�warn�DeprecationWarning�strict�reset)rr#rrrrzs

zHTMLParser.__init__cCs(d|_d|_t|_d|_tj�|�dS)z1Reset this instance.  Loses all unprocessed data.�z???N)�rawdata�lasttag�interesting_normal�interesting�
cdata_elemr�
ParserBaser$)rrrrr$�s
zHTMLParser.resetcCs|j||_|�d�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').
        rN)r&�goahead)r�datarrr�feed�szHTMLParser.feedcCs|�d�dS)zHandle any buffered data.rN)r,)rrrr�close�szHTMLParser.closecCst||����dS)N)r	�getpos)r�messagerrr�error�szHTMLParser.errorNcCs|jS)z)Return full source of start tag: '<...>'.)�_HTMLParser__starttag_text)rrrr�get_starttag_text�szHTMLParser.get_starttag_textcCs$|��|_t�d|jtj�|_dS)Nz</\s*%s\s*>)�lowerr*�re�compile�Ir))r�elemrrr�set_cdata_mode�s
zHTMLParser.set_cdata_modecCst|_d|_dS)N)r(r)r*)rrrr�clear_cdata_mode�szHTMLParser.clear_cdata_modec
Cs�|j}d}t|�}�xF||k�rZ|j�||�}|r<|��}n|jrDP|}||krb|�|||��|�||�}||krxP|j}|d|��r�t	�
||�r�|�|�}n�|d|�r�|�|�}n||d|�r�|�
|�}nf|d|�r�|�|�}nP|d|��r|j�r|�|�}n
|�|�}n$|d|k�r2|�d�|d}nP|dk�r�|�sFP|j�rX|�d�|�d	|d�}|dk�r�|�d|d�}|dk�r�|d}n|d7}|�|||��|�||�}q|d
|��rZt�
||�}|�r&|��dd�}	|�|	�|��}|d
|d��s|d}|�||�}qn2d
||d�k�rV|�|dd��|�|d�}Pq|d|��rLt�
||�}|�r�|�d�}	|�|	�|��}|d
|d��s�|d}|�||�}qt�
||�}|�r|�r|��||d�k�r|j�r�|�d�n||k�r
|}|�||d�}Pn,|d|k�rH|�d�|�||d�}nPqdstd��qW|�r�||k�r�|j�s�|�|||��|�||�}||d�|_dS)Nr�<z</z<!--z<?z<!rzEOF in middle of constructrz&#r����;�&z#EOF in middle of entity or char refzinteresting.search() lied)r&�lenr)�search�startr*�handle_data�	updatepos�
startswith�starttagopen�match�parse_starttag�parse_endtag�
parse_comment�parse_pir#Zparse_declaration�parse_html_declarationr2�find�charref�group�handle_charref�end�	entityref�handle_entityref�
incompleter)
rrQr&�i�nrG�jrE�k�namerrrr,�s�















zHTMLParser.goaheadcCs�|j}|||d�dks"td��|||d�dkr@|�|�S|||d�dkr^|�|�S|||d���d	kr�|�d
|d�}|dkr�dS|�||d|��|dS|�|�SdS)
Nrz<!z+unexpected call to parse_html_declaration()�z<!--�z<![�	z	<!doctyperr=r)r&rrJZparse_marked_sectionr5rM�handle_decl�parse_bogus_comment)rrUr&�gtposrrrrLs

z!HTMLParser.parse_html_declarationrcCs`|j}|||d�dks"td��|�d|d�}|dkr>dS|rX|�||d|��|dS)Nr)z<!z</z"unexpected call to parse_comment()rr=r)r&rrM�handle_comment)rrU�reportr&�posrrrr^-szHTMLParser.parse_bogus_commentcCsd|j}|||d�dks"td��t�||d�}|s:dS|��}|�||d|��|��}|S)Nrz<?zunexpected call to parse_pi()r=)r&r�picloserArB�	handle_pirQ)rrUr&rGrWrrrrK9szHTMLParser.parse_picCs0d|_|�|�}|dkr|S|j}|||�|_g}t�||d�}|sPtd��|��}|�d���|_	}x�||k�rH|j
r�t�||�}nt�||�}|s�P|�ddd�\}	}
}|
s�d}n`|dd�dkr�|dd�k�sn|dd�dk�r|dd�k�rnn|dd�}|�r,|�
|�}|�|	��|f�|��}qnW|||���}|d	k�r�|��\}
}d
|jk�r�|
|j�d
�}
t|j�|j�d
�}n|t|j�}|j
�r�|�d|||�dd�f�|�|||��|S|�d
��r
|�||�n"|�||�||jk�r,|�|�|S)Nrrz#unexpected call to parse_starttag()rr[�'r=�")rz/>�
z junk characters in start tag: %r�z/>)r3�check_for_whole_start_tagr&�tagfindrGrrQrOr5r'r#�attrfind�attrfind_tolerant�unescape�append�stripr0�countr@�rfindr2rC�endswith�handle_startendtag�handle_starttag�CDATA_CONTENT_ELEMENTSr:)rrU�endposr&�attrsrGrX�tag�m�attrname�restZ	attrvaluerQrrrrrrHEs\
(,


zHTMLParser.parse_starttagcCs|j}|jrt�||�}nt�||�}|r�|��}|||d�}|dkrR|dS|dkr�|�d|�rn|dS|�d|�r~dS|jr�|�||d�|�d�||kr�|S|dS|dkr�dS|d	kr�dS|jr�|�||�|�d
�||kr�|S|dSt	d��dS)Nrr�/z/>rr=zmalformed empty start tagr%z6abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZzmalformed start tagzwe should not get here!)
r&r#�locatestarttagendrG�locatestarttagend_tolerantrQrErDr2r)rrUr&ryrW�nextrrrri~s>

z$HTMLParser.check_for_whole_start_tagcCsN|j}|||d�dks"td��t�||d�}|s:dS|��}t�||�}|s�|jdk	rr|�|||��|S|j	r�|�
d|||�f�t�||d�}|s�|||d�dkr�|dS|�|�S|�
���}|�d	|���}|�|�|dS|�
d���}|jdk	�r4||jk�r4|�|||��|S|�|���|��|S)
Nrz</zunexpected call to parse_endtagrr=zbad end tag: %rr[z</>r)r&r�	endendtagrArQ�
endtagfindrGr*rCr#r2�tagfind_tolerantr^rOr5rM�
handle_endtagr;)rrUr&rGr_Z	namematchZtagnamer9rrrrI�s<


zHTMLParser.parse_endtagcCs|�||�|�|�dS)N)rtr�)rrxrwrrrrs�szHTMLParser.handle_startendtagcCsdS)Nr)rrxrwrrrrt�szHTMLParser.handle_starttagcCsdS)Nr)rrxrrrr��szHTMLParser.handle_endtagcCsdS)Nr)rrYrrrrP�szHTMLParser.handle_charrefcCsdS)Nr)rrYrrrrS�szHTMLParser.handle_entityrefcCsdS)Nr)rr-rrrrC�szHTMLParser.handle_datacCsdS)Nr)rr-rrrr`�szHTMLParser.handle_commentcCsdS)Nr)rZdeclrrrr]�szHTMLParser.handle_declcCsdS)Nr)rr-rrrrd�szHTMLParser.handle_picCs|jr|�d|f�dS)Nzunknown declaration: %r)r#r2)rr-rrr�unknown_decl�szHTMLParser.unknown_declcCs"d|kr|Sdd�}t�d||�S)Nr?cSs�|��d}yX|ddkrb|dd�}|ddkrLt|dd��d�d�}nt|�d��}t|�SWntk
r|d|SXddlm}||kr�||S|�d�r�d	|SxJtd
t	|��D]0}|d|�|kr�||d|�||d�Sq�Wd	|SdS)Nr�#r)�x�Xr>�z&#)�html5r?r)
�groups�int�rstrip�chr�
ValueErrorZfuture.backports.html.entitiesr�rr�ranger@)�s�cr�r�rrr�replaceEntities�s&

 z,HTMLParser.unescape.<locals>.replaceEntitiesz&&(#?[xX]?(?:[0-9a-fA-F]+;|\w{1,32};?)))r6�sub)rr�r�rrrrm�s
zHTMLParser.unescape)F)r) rrrrrurr$r.r/r2r3r4r:r;r,rLr^rKrHrirIrsrtr�rPrSrCr`r]rdr�rmrrrrrds:

	h
9+*r) r�
__future__rrrrZfuture.builtinsZfuture.backportsrr6r r7r(rTrRrNrFrcZcommentcloserjr�rkrl�VERBOSEr}r~r�r��	Exceptionr	r+rrrrr�<module>s4	














Hacked By AnonymousFox1.0, Coded By AnonymousFox