AlkantarClanX12

Your IP : 3.21.46.24


Current Path : /opt/alt/python34/lib64/python3.4/html/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/html/__pycache__/parser.cpython-34.pyo

�
h f�S�@sldZddlZddlZddlZddlmZdgZejd�Zejd�Z	ejd�Z
ejd�Zejd	�Zejd
�Z
ejd�Zejd�Zejd
�Zejd�Zejd�Zejdej�Zejdej�Zejd
�Zejd�ZGdd�de�Ze�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--\s*>z(([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*z$([a-zA-Z][^	

 />]*)(?:\s|/(?!>))*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][^\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@s1eZdZdZddd�Zdd�ZdS)�HTMLParseErrorz&Exception raised for all parse errors.NcCs'||_|d|_|d|_dS)Nr�)�msg�lineno�offset)�selfrZposition�r�0/opt/alt/python34/lib64/python3.4/html/parser.py�__init__Us	
zHTMLParseError.__init__cCsW|j}|jdk	r,|d|j}n|jdk	rS|d|jd}n|S)Nz, at line %dz, column %dr)rrr	)r
�resultrrr�__str__[s	zHTMLParseError.__str__)NN)�__name__�
__module__�__qualname__�__doc__r
rrrrrrRsrc@sfeZdZdZd;Zededd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dZdd�Zdd�Z
dd�Zdd�Zdd�Zddd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z dS)<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�style�convert_charrefscCsv|tk	r%tjdtdd�nd}||_|tkr_d}tjdtdd�n||_|j�dS)a�Initialize and reset this instance.

        If convert_charrefs is True (default: False), all character references
        are automatically converted to the corresponding Unicode characters.
        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
        and argument are deprecated.
        z,The strict argument and mode are deprecated.�
stacklevel�FzfThe value of convert_charrefs will become True in 3.5. You are encouraged to set the value explicitly.N)�_default_sentinel�warnings�warn�DeprecationWarning�strictr�reset)r
rrrrrr
~s
				zHTMLParser.__init__cCs8d|_d|_t|_d|_tjj|�dS)z1Reset this instance.  Loses all unprocessed data.�z???N)�rawdata�lasttag�interesting_normal�interesting�
cdata_elem�_markupbase�
ParserBaser)r
rrrr�s
				zHTMLParser.resetcCs!|j||_|jd�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�szHTMLParser.feedcCs|jd�dS)zHandle any buffered data.rN)r')r
rrr�close�szHTMLParser.closecCs/tjdtdd�t||j���dS)Nz!The 'error' method is deprecated.rr)rrrr�getpos)r
�messagerrr�error�s	
zHTMLParser.errorNcCs|jS)z)Return full source of start tag: '<...>'.)�_HTMLParser__starttag_text)r
rrr�get_starttag_text�szHTMLParser.get_starttag_textcCs2|j�|_tjd|jtj�|_dS)Nz</\s*%s\s*>)�lowerr$�re�compile�Ir#)r
�elemrrr�set_cdata_mode�szHTMLParser.set_cdata_modecCst|_d|_dS)N)r"r#r$)r
rrr�clear_cdata_mode�s	zHTMLParser.clear_cdata_modecCs#|j}d}t|�}xs||kr�|jr�|jr�|jd|�}|dkr�|jdt||d��}|dkr�tjd�j	||�r�Pn|}q�n=|j
j	||�}|r�|j�}n|jr�Pn|}||krH|jr.|jr.|jt
|||���qH|j|||��n|j||�}||krjPn|j}|d|�r_tj||�r�|j|�}	n�|d|�r�|j|�}	n�|d|�r�|j|�}	n�|d|�r	|j|�}	ng|d	|�rE|jr3|j|�}	qp|j|�}	n+|d
|kro|jd�|d
}	nP|	dkrJ|s�Pn|jr�|jd�n|jd|d
�}	|	dkr�|jd|d
�}	|	dkr�|d
}	q�n
|	d
7}	|jr0|jr0|jt
|||	���qJ|j|||	��n|j||	�}q|d
|�r;tj||�}|r�|j�dd�}
|j|
�|j�}	|d|	d
�s�|	d
}	n|j||	�}qq�d||d�kr7|j|||d��|j||d�}nPq|d|�rtj||�}|r�|jd
�}
|j|
�|j�}	|d|	d
�s�|	d
}	n|j||	�}qnt j||�}|rS|rO|j�||d�krO|jr|jd�qO|j�}	|	|kr6|}	n|j||d
�}nPq�|d
|kr�|jd�|j||d
�}q�PqqW|r||kr|jr|jr�|jr�|jt
|||���n|j|||��|j||�}n||d�|_dS)Nr�<�&�"z[\s;]z</z<!--z<?z<!rzEOF in middle of constructrz&#r�;z#EOF in middle of entity or char ref���)!r �lenrr$�find�rfind�maxr1r2�searchr#�start�handle_datar�	updatepos�
startswith�starttagopen�match�parse_starttag�parse_endtag�
parse_comment�parse_pirZparse_declaration�parse_html_declarationr-�charref�group�handle_charref�end�	entityref�handle_entityref�
incomplete)r
rOr �i�n�jZampposrFrD�k�namerrrr'�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	<!doctyperrrr;r;)r rIZparse_marked_sectionr0r=�handle_decl�parse_bogus_comment)r
rSr �gtposrrrrKCs	

 z!HTMLParser.parse_html_declarationrcCs[|j}|jd|d�}|dkr/dS|rS|j||d|��n|dS)Nrrrr;r;)r r=�handle_comment)r
rSZreportr �posrrrr\Xs	zHTMLParser.parse_bogus_commentcCs`|j}tj||d�}|s)dS|j�}|j||d|��|j�}|S)Nrrr;)r �picloser@rA�	handle_pirO)r
rSr rFrUrrrrJds	zHTMLParser.parse_picCsd|_|j|�}|dkr(|S|j}|||�|_g}|jrltj||d�}ntj||d�}|j�}|jd�j	�|_
}x$||kr�|jr�tj||�}ntj||�}|s�Pn|jddd�\}	}
}|
s d}ns|dd�dkoK|dd�kns�|dd�dko{|d
d�knr�|dd�}n|r�t
|�}n|j|	j	�|f�|j�}q�W|||�j�}|dkr�|j�\}
}d	|jkrL|
|jjd	�}
t|j�|jjd	�}n|t|j�}|jr�|jd
|||�dd�f�n|j|||��|S|jd�r�|j||�n/|j||�||jkr�|j|�n|S)NrrrrY�'�"r�/>�
z junk characters in start tag: %r�r;r;r;)rrd)r.�check_for_whole_start_tagr r�tagfindrF�tagfind_tolerantrOrMr0r!�attrfind�attrfind_tolerantr�append�stripr+�countr<r>r-rB�endswith�handle_startendtag�handle_starttag�CDATA_CONTENT_ELEMENTSr5)r
rS�endposr �attrsrFrV�tag�mZattrname�restZ	attrvaluerOrr	rrrrGps^					00		"zHTMLParser.parse_starttagcCsk|j}|jr'tj||�}ntj||�}|r[|j�}|||d�}|dkrs|dS|dkr�|jd|�r�|dS|jd|�r�dS|jr�|j||d�|jd�n||kr�|S|dSn|dkrdS|dkrd
S|jr@|j||�|jd	�n||krP|S|dSnt	d
��dS)Nrr�/z/>rzmalformed empty start tagrz6abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZzmalformed start tagzwe should not get here!r;r;r;)
r r�locatestarttagendrF�locatestarttagend_tolerantrOrDrCr-�AssertionError)r
rSr rvrU�nextrrrrg�s>				z$HTMLParser.check_for_whole_start_tagcCs�|j}tj||d�}|s)dS|j�}tj||�}|s1|jdk	rw|j|||��|S|jr�|j	d|||�f�nt
j||d�}|s�|||d�dkr�|dS|j|�Sn|jd�j
�}|jd|j��}|j|�|dS|jd�j
�}|jdk	r�||jkr�|j|||��|Sn|j|j
��|j�|S)Nrzbad end tag: %rrrYz</>rr;)r �	endendtagr@rO�
endtagfindrFr$rBrr-rir\rMr0r=�
handle_endtagr6)r
rSr rFr]Z	namematchZtagnamer4rrrrH�s:		!

zHTMLParser.parse_endtagcCs!|j||�|j|�dS)N)rqr)r
rurtrrrrpszHTMLParser.handle_startendtagcCsdS)Nr)r
rurtrrrrqszHTMLParser.handle_starttagcCsdS)Nr)r
rurrrr
szHTMLParser.handle_endtagcCsdS)Nr)r
rWrrrrNszHTMLParser.handle_charrefcCsdS)Nr)r
rWrrrrQszHTMLParser.handle_entityrefcCsdS)Nr)r
r(rrrrBszHTMLParser.handle_datacCsdS)Nr)r
r(rrrr^szHTMLParser.handle_commentcCsdS)Nr)r
Zdeclrrrr[szHTMLParser.handle_declcCsdS)Nr)r
r(rrrra"szHTMLParser.handle_picCs$|jr |jd|f�ndS)Nzunknown declaration: %r)rr-)r
r(rrr�unknown_decl%s	zHTMLParser.unknown_declcCs tjdtdd�t|�S)NzZThe unescape method is deprecated and will be removed in 3.5, use html.unescape() instead.rr)rrrr)r
�srrrr*s	
zHTMLParser.unescape)rr)!rrrrrrrr
rr)r*r-r.r/r5r6r'rKr\rJrGrgrHrprqrrNrQrBr^r[rar�rrrrrrfs<	�<+*)rr1rr%Zhtmlr�__all__r2r"rRrPrLrEr`Zcommentcloserhrirjrk�VERBOSEryrzr}r~�	Exceptionr�objectrr&rrrrr�<module>s6