Your IP : 3.133.149.244


Current Path : /opt/alt/python35/lib64/python3.5/html/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/html/__pycache__/parser.cpython-35.opt-2.pyc



���]?E�@sddlZddlZddlZddlmZdgZejd�Zejd�Zejd�Z	ejd�Z
ejd�Zejd	�Zejd
�Z
ejd�Zejd�Zejd
ej�Zejd	�Zejd�ZGdd�dej�ZdS)�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--\s*>z$([a-zA-Z][^	

 />]*)(?:\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@sQeZdZd9Zdddd�Zdd�Zd	d
�Zdd�Zd
Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
ddd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd
S):r�script�style�convert_charrefsTcCs||_|j�dS)N)r�reset)�selfr�r
�+/opt/alt/python35/lib64/python3.5/parser.py�__init__Ws	zHTMLParser.__init__cCs8d|_d|_t|_d|_tjj|�dS)N�z???)�rawdata�lasttag�interesting_normal�interesting�
cdata_elem�_markupbase�
ParserBaser)r	r
r
rr`s
				zHTMLParser.resetcCs!|j||_|jd�dS)Nr)r�goahead)r	�datar
r
r�feedhszHTMLParser.feedcCs|jd�dS)N�)r)r	r
r
r�closeqszHTMLParser.closeNcCs|jS)N)�_HTMLParser__starttag_text)r	r
r
r�get_starttag_textwszHTMLParser.get_starttag_textcCs2|j�|_tjd|jtj�|_dS)Nz</\s*%s\s*>)�lowerr�re�compile�Ir)r	�elemr
r
r�set_cdata_mode{szHTMLParser.set_cdata_modecCst|_d|_dS)N)rrr)r	r
r
r�clear_cdata_modes	zHTMLParser.clear_cdata_modecCs�|j}d}t|�}x�||kr|jr�|jr�|jd|�}|dkr�|jdt||d��}|dkr�tjd�j	||�r�P|}n:|j
j	||�}|r�|j�}n|jr�P|}||kr<|jr%|jr%|jt
|||���n|j|||��|j||�}||kr[P|j}|d|�rtj||�r�|j|�}	n�|d|�r�|j|�}	n�|d|�r�|j|�}	nm|d|�r�|j|�}	nL|d	|�r|j|�}	n+|d
|krE|jd�|d
}	nP|	dkr�|sYP|jd|d
�}	|	dkr�|jd|d
�}	|	dkr�|d
}	n
|	d
7}	|jr�|jr�|jt
|||	���n|j|||	��|j||	�}q|d|�r�tj||�}|r�|j�d
d�}
|j|
�|j�}	|d|	d
�s�|	d
}	|j||	�}qqd||d�kr�|j|||d
��|j||d
�}Pq|d|�rtj||�}|rj|jd
�}
|j|
�|j�}	|d|	d
�sU|	d
}	|j||	�}qtj||�}|r�|r�|j�||d�kr�|j�}	|	|kr�|}	|j||d
�}Pq|d
|kr|jd�|j||d
�}qPqqW|r�||kr�|jr�|jri|jri|jt
|||���n|j|||��|j||�}||d�|_dS)Nr�<�&�"z[\s;]z</z<!--z<?z<!rrz&#��;���)r�lenrr�find�rfind�maxrr�searchr�start�handle_datarZ	updatepos�
startswith�starttagopen�match�parse_starttag�parse_endtag�
parse_comment�parse_pi�parse_html_declaration�charref�group�handle_charref�end�	entityref�handle_entityref�
incomplete)r	r;r�i�n�jZampposr2r0�k�namer
r
rr�s�			 	



 



"
 zHTMLParser.goaheadcCs�|j}|||d�dkr0|j|�S|||d�dkrW|j|�S|||d�j�dkr�|jd|d�}|d
kr�dS|j||d	|��|dS|j|�SdS)N�z<!--�z<![�	z	<!doctyperrr&r(r()rr5Zparse_marked_sectionrr*�handle_decl�parse_bogus_comment)r	r?r�gtposr
r
rr7s	

 z!HTMLParser.parse_html_declarationrcCsX|j}|jd|d�}|dkr/dS|rP|j||d|��|dS)Nrr&rr(r()rr*�handle_comment)r	r?Zreportr�posr
r
rrHs	zHTMLParser.parse_bogus_commentcCs`|j}tj||d�}|s)dS|j�}|j||d|��|j�}|S)Nr&rr()r�picloser-r.�	handle_pir;)r	r?rr2rAr
r
rr6!s	zHTMLParser.parse_picCs�d|_|j|�}|dkr(|S|j}|||�|_g}tj||d�}|j�}|jd�j�|_}x�||kr�t	j||�}|s�P|jddd�\}	}
}|
s�d}np|dd�dko|d
d�kns=|dd�dko8|dd�knrM|dd�}|r_t
|�}|j|	j�|f�|j�}q�W|||�j�}|d
kr1|j
�\}
}d	|jkr|
|jjd	�}
t|j�|jjd	�}n|t|j�}|j|||��|S|jd�rS|j||�n,|j||�||jkr|j|�|S)Nrrr&rE�'�"r�/>�
r(r(r()rrP)r�check_for_whole_start_tagr�tagfind_tolerantr2r;r9rr�attrfind_tolerantr�append�stripZgetpos�countr)r+r/�endswith�handle_startendtag�handle_starttag�CDATA_CONTENT_ELEMENTSr!)r	r?�endposr�attrsr2rB�tag�mZattrname�restZ	attrvaluer;�lineno�offsetr
r
rr3-sP			00
zHTMLParser.parse_starttagcCs�|j}tj||�}|r�|j�}|||d�}|dkrU|dS|dkr�|jd|�r{|dS|jd|�r�d	S||kr�|S|dS|dkr�d
S|dkr�dS||kr�|S|dStd��dS)Nrr�/z/>r&r
z6abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZzwe should not get here!r(r(r()r�locatestarttagend_tolerantr2r;r0�AssertionError)r	r?rr_rA�nextr
r
rrR`s.	z$HTMLParser.check_for_whole_start_tagcCss|j}tj||d�}|s)dS|j�}tj||�}|s|jdk	rw|j|||��|Stj||d�}|s�|||d�dkr�|dS|j	|�S|j
d�j�}|jd|j��}|j
|�|dS|j
d�j�}|jdk	rR||jkrR|j|||��|S|j
|j��|j�|S)Nrr&rEz</>rr()r�	endendtagr-r;�
endtagfindr2rr/rSrHr9rr*�
handle_endtagr")r	r?rr2rIZ	namematchZtagnamer r
r
rr4�s6	


zHTMLParser.parse_endtagcCs!|j||�|j|�dS)N)rZri)r	r^r]r
r
rrY�szHTMLParser.handle_startendtagcCsdS)Nr
)r	r^r]r
r
rrZ�szHTMLParser.handle_starttagcCsdS)Nr
)r	r^r
r
rri�szHTMLParser.handle_endtagcCsdS)Nr
)r	rCr
r
rr:�szHTMLParser.handle_charrefcCsdS)Nr
)r	rCr
r
rr=�szHTMLParser.handle_entityrefcCsdS)Nr
)r	rr
r
rr/�szHTMLParser.handle_datacCsdS)Nr
)r	rr
r
rrJ�szHTMLParser.handle_commentcCsdS)Nr
)r	Zdeclr
r
rrG�szHTMLParser.handle_declcCsdS)Nr
)r	rr
r
rrM�szHTMLParser.handle_picCsdS)Nr
)r	rr
r
r�unknown_decl�szHTMLParser.unknown_declcCs tjdtdd�t|�S)NzZThe unescape method is deprecated and will be removed in 3.5, use html.unescape() instead.�
stacklevelr&)�warnings�warn�DeprecationWarningr)r	�sr
r
rr�s	
zHTMLParser.unescape)rr)�__name__�
__module__�__qualname__r[rrrrrrr!r"rr7rHr6r3rRr4rYrZrir:r=r/rJrGrMrjrr
r
r
rr?s6		z3"()rrlrZhtmlr�__all__rrr>r<r8r1rLZcommentcloserSrT�VERBOSErdrgrhrrr
r
r
r�<module>s&		

?>