�`^c@s�dZddlmZeddd�[ddlZddlmZdd gZd ejfd
��YZdej fd��YZ
ed�Ze
d
kr�e�ndS(svHTML 2.0 parser.
See the HTML 2.0 specification:
http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
i�(twarnpy3ks1the htmllib module has been removed in Python 3.0t
stackleveliN(tAS_ISt
HTMLParsertHTMLParseErrorcBseZdZRS(s3Error raised when an HTML document can't be parsed.(t__name__t
__module__t__doc__(((s/sys/lib/python2.7/htmllib.pyRscBs3eZdZddlmZdd�Zd�Zd�Zd�Zd�Z d �Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d$�Z%d%�Z&d&�Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,d,�Z-d-�Z.d.�Z/d/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4�Z5d5�Z6d6�Z7d7�Z8d8�Z9d9�Z:d:�Z;d;�Z<d<�Z=d=�Z>dd>�Z?d?�Z@d@�ZAdA�ZBdB�ZCdC�ZDdD�ZEdE�ZFdF�ZGdG�ZHdH�ZIdI�ZJdJ�ZKdK�ZLdL�ZMdM�ZNdN�ZOdO�ZPdP�ZQdQ�ZRdR�ZSdS�ZTdT�ZUdU�ZVdV�ZWdW�ZXdX�ZYdY�ZZdZ�Z[RS([s�This is the basic HTML parser class.
It supports all entity names required by the XHTML 1.0 Recommendation.
It also defines handlers for all HTML 2.0 and many HTML 3.0 and 3.2
elements.
i�(t
entitydefsicCs tjj||�||_dS(s�Creates an instance of the HTMLParser class.
The formatter parameter is the formatter instance associated with
the parser.
N(tsgmllibt
SGMLParsert__init__t formatter(tselfRtverbose((s/sys/lib/python2.7/htmllib.pyR"scCst|��dS(N(R(R
tmessage((s/sys/lib/python2.7/htmllib.pyterror,scCs\tjj|�d|_d|_d|_d|_d|_g|_ d|_
g|_dS(Ni(R R
tresettNonetsavedatatisindexttitletbasetanchort
anchorlisttnofillt
list_stack(R
((s/sys/lib/python2.7/htmllib.pyR/s cCsR|jdk r"|j||_n,|jr>|jj|�n|jj|�dS(N(RRRRtadd_literal_datatadd_flowing_data(R
tdata((s/sys/lib/python2.7/htmllib.pythandle_data?s
cCs
d|_dS(s�Begins saving character data in a buffer instead of sending it
to the formatter object.
Retrieve the stored data via the save_end() method. Use of the
save_bgn() / save_end() pair may not be nested.
tN(R(R
((s/sys/lib/python2.7/htmllib.pytsave_bgnJscCs7|j}d|_|js3dj|j��}n|S(sHEnds buffering character data and returns all data saved since
the preceding call to the save_bgn() method.
If the nofill flag is false, whitespace is collapsed to single
spaces. A call to this method without a preceding call to the
save_bgn() method will raise a TypeError exception.
t N(RRRtjointsplit(R
R((s/sys/lib/python2.7/htmllib.pytsave_endTs
cCs)||_|jr%|jj|�ndS(s}This method is called at the start of an anchor region.
The arguments correspond to the attributes of the <A> tag with
the same names. The default implementation maintains a list of
hyperlinks (defined by the HREF attribute for <A> tags) within
the document. The list of hyperlinks is available as the data
attribute anchorlist.
N(RRtappend(R
threftnamettype((s/sys/lib/python2.7/htmllib.pyt
anchor_bgnes
cCs3|jr/|jdt|j��d|_ndS(s�This method is called at the end of an anchor region.
The default implementation adds a textual footnote marker using an
index into the list of hyperlinks created by the anchor_bgn()method.
s[%d]N(RRtlenRR(R
((s/sys/lib/python2.7/htmllib.pyt
anchor_endss cGs|j|�dS(s�This method is called to handle images.
The default implementation simply passes the alt value to the
handle_data() method.
N(R(R
tsrctalttargs((s/sys/lib/python2.7/htmllib.pythandle_image�scCsdS(N((R
tattrs((s/sys/lib/python2.7/htmllib.pyt
start_html�scCsdS(N((R
((s/sys/lib/python2.7/htmllib.pytend_html�scCsdS(N((R
R0((s/sys/lib/python2.7/htmllib.pyt
start_head�scCsdS(N((R
((s/sys/lib/python2.7/htmllib.pytend_head�scCsdS(N((R
R0((s/sys/lib/python2.7/htmllib.pyt
start_body�scCsdS(N((R
((s/sys/lib/python2.7/htmllib.pytend_body�scCs|j�dS(N(R (R
R0((s/sys/lib/python2.7/htmllib.pytstart_title�scCs|j�|_dS(N(R$R(R
((s/sys/lib/python2.7/htmllib.pyt end_title�scCs3x,|D]$\}}|dkr||_qqWdS(NR&(R(R
R0tatv((s/sys/lib/python2.7/htmllib.pytdo_base�scCs
d|_dS(Ni(R(R
R0((s/sys/lib/python2.7/htmllib.pyt
do_isindex�scCsdS(N((R
R0((s/sys/lib/python2.7/htmllib.pytdo_link�scCsdS(N((R
R0((s/sys/lib/python2.7/htmllib.pytdo_meta�scCsdS(N((R
R0((s/sys/lib/python2.7/htmllib.pyt do_nextid�scCs$|jjd�|jjd�dS(Nith1i(R@iii(Rt
end_paragrapht push_font(R
R0((s/sys/lib/python2.7/htmllib.pytstart_h1�scCs!|jjd�|jj�dS(Ni(RRAtpop_font(R
((s/sys/lib/python2.7/htmllib.pytend_h1�scCs$|jjd�|jjd�dS(Nith2i(RFiii(RRARB(R
R0((s/sys/lib/python2.7/htmllib.pytstart_h2�scCs!|jjd�|jj�dS(Ni(RRARD(R
((s/sys/lib/python2.7/htmllib.pytend_h2�scCs$|jjd�|jjd�dS(Nith3i(RIiii(RRARB(R
R0((s/sys/lib/python2.7/htmllib.pytstart_h3�scCs!|jjd�|jj�dS(Ni(RRARD(R
((s/sys/lib/python2.7/htmllib.pytend_h3�scCs$|jjd�|jjd�dS(Nith4i(RLiii(RRARB(R
R0((s/sys/lib/python2.7/htmllib.pytstart_h4�scCs!|jjd�|jj�dS(Ni(RRARD(R
((s/sys/lib/python2.7/htmllib.pytend_h4�scCs$|jjd�|jjd�dS(Nith5i(ROiii(RRARB(R
R0((s/sys/lib/python2.7/htmllib.pytstart_h5�scCs!|jjd�|jj�dS(Ni(RRARD(R
((s/sys/lib/python2.7/htmllib.pytend_h5�scCs$|jjd�|jjd�dS(Nith6i(RRiii(RRARB(R
R0((s/sys/lib/python2.7/htmllib.pytstart_h6�scCs!|jjd�|jj�dS(Ni(RRARD(R
((s/sys/lib/python2.7/htmllib.pytend_h6�scCs|jjd�dS(Ni(RRA(R
R0((s/sys/lib/python2.7/htmllib.pytdo_p�scCs@|jjd�|jjtttdf�|jd|_dS(Ni(RRARBRR(R
R0((s/sys/lib/python2.7/htmllib.pyt start_pre�scCs:|jjd�|jj�td|jd�|_dS(Nii(RRARDtmaxR(R
((s/sys/lib/python2.7/htmllib.pytend_pre�s
cCs|j|�|jd�dS(Ntxmp(RVt
setliteral(R
R0((s/sys/lib/python2.7/htmllib.pyt start_xmp�s
cCs|j�dS(N(RX(R
((s/sys/lib/python2.7/htmllib.pytend_xmp�scCs|j|�|jd�dS(Ntlisting(RVRZ(R
R0((s/sys/lib/python2.7/htmllib.pyt
start_listing�s
cCs|j�dS(N(RX(R
((s/sys/lib/python2.7/htmllib.pytend_listing�scCs0|jjd�|jjtdttf�dS(Nii(RRARBR(R
R0((s/sys/lib/python2.7/htmllib.pyt
start_address�scCs!|jjd�|jj�dS(Ni(RRARD(R
((s/sys/lib/python2.7/htmllib.pytend_addressscCs$|jjd�|jjd�dS(Nit
blockquote(RRAtpush_margin(R
R0((s/sys/lib/python2.7/htmllib.pytstart_blockquotescCs!|jjd�|jj�dS(Ni(RRAt
pop_margin(R
((s/sys/lib/python2.7/htmllib.pytend_blockquote
scCsA|jj|j�|jjd�|jjdddg�dS(Ntult*i(RRARRcR%(R
R0((s/sys/lib/python2.7/htmllib.pytstart_ulscCs;|jr|jd=n|jj|j�|jj�dS(Ni�(RRRARe(R
((s/sys/lib/python2.7/htmllib.pytend_uls
cCsk|jjd�|jrH|jd\}}}}|d|d<}nd\}}|jj||�dS(Nii�iiRh(Rhi(RRARtadd_label_data(R
R0tdummytlabeltcounterttop((s/sys/lib/python2.7/htmllib.pytdo_lis cCs�|jj|j�|jjd�d}xH|D]@\}}|dkr1t|�dkrh|d}n|}q1q1W|jjd|dg�dS(Ntols1.R(it.i(RRARRcR*R%(R
R0RmR9R:((s/sys/lib/python2.7/htmllib.pytstart_ol#s
cCs;|jr|jd=n|jj|j�|jj�dS(Ni�(RRRARe(R
((s/sys/lib/python2.7/htmllib.pytend_ol-s
cCs|j|�dS(N(Ri(R
R0((s/sys/lib/python2.7/htmllib.pyt
start_menu2scCs|j�dS(N(Rj(R
((s/sys/lib/python2.7/htmllib.pytend_menu5scCs|j|�dS(N(Ri(R
R0((s/sys/lib/python2.7/htmllib.pyt start_dir8scCs|j�dS(N(Rj(R
((s/sys/lib/python2.7/htmllib.pytend_dir;scCs-|jjd�|jjdddg�dS(NitdlRi(RRARR%(R
R0((s/sys/lib/python2.7/htmllib.pytstart_dl>scCs'|jd�|jr#|jd=ndS(Nii�(tddpopR(R
((s/sys/lib/python2.7/htmllib.pytend_dlBs
cCs|j�dS(N(R{(R
R0((s/sys/lib/python2.7/htmllib.pytdo_dtFscCs7|j�|jjd�|jjdddg�dS(NtddRi(R{RRcRR%(R
R0((s/sys/lib/python2.7/htmllib.pytdo_ddIs
cCsQ|jj|�|jrM|jdddkrM|jd=|jj�qMndS(Ni�iR~(RRARRe(R
tbl((s/sys/lib/python2.7/htmllib.pyR{Ns
cCs|j|�dS(N(tstart_i(R
R0((s/sys/lib/python2.7/htmllib.pyt
start_citeYscCs|j�dS(N(tend_i(R
((s/sys/lib/python2.7/htmllib.pytend_citeZscCs|j|�dS(N(tstart_tt(R
R0((s/sys/lib/python2.7/htmllib.pyt
start_code\scCs|j�dS(N(tend_tt(R
((s/sys/lib/python2.7/htmllib.pytend_code]scCs|j|�dS(N(R�(R
R0((s/sys/lib/python2.7/htmllib.pytstart_em_scCs|j�dS(N(R�(R
((s/sys/lib/python2.7/htmllib.pytend_em`scCs|j|�dS(N(R�(R
R0((s/sys/lib/python2.7/htmllib.pyt start_kbdbscCs|j�dS(N(R�(R
((s/sys/lib/python2.7/htmllib.pytend_kbdcscCs|j|�dS(N(R�(R
R0((s/sys/lib/python2.7/htmllib.pyt
start_sampescCs|j�dS(N(R�(R
((s/sys/lib/python2.7/htmllib.pytend_sampfscCs|j|�dS(N(tstart_b(R
R0((s/sys/lib/python2.7/htmllib.pytstart_stronghscCs|j�dS(N(tend_b(R
((s/sys/lib/python2.7/htmllib.pyt
end_strongiscCs|j|�dS(N(R�(R
R0((s/sys/lib/python2.7/htmllib.pyt start_varkscCs|j�dS(N(R�(R
((s/sys/lib/python2.7/htmllib.pytend_varlscCs |jjtdttf�dS(Ni(RRBR(R
R0((s/sys/lib/python2.7/htmllib.pyR�pscCs|jj�dS(N(RRD(R
((s/sys/lib/python2.7/htmllib.pyR�rscCs |jjttdtf�dS(Ni(RRBR(R
R0((s/sys/lib/python2.7/htmllib.pyR�uscCs|jj�dS(N(RRD(R
((s/sys/lib/python2.7/htmllib.pyR�wscCs |jjtttdf�dS(Ni(RRBR(R
R0((s/sys/lib/python2.7/htmllib.pyR�zscCs|jj�dS(N(RRD(R
((s/sys/lib/python2.7/htmllib.pyR�|scCs�d}d}d}xe|D]]\}}|j�}|dkrF|}n|dkr[|}n|dkr|j�}qqW|j|||�dS(NRR&R'R((tstriptlowerR)(R
R0R&R'R(tattrnametvalue((s/sys/lib/python2.7/htmllib.pytstart_as cCs|j�dS(N(R+(R
((s/sys/lib/python2.7/htmllib.pytend_a�scCs|jj�dS(N(Rtadd_line_break(R
R0((s/sys/lib/python2.7/htmllib.pytdo_br�scCs|jj�dS(N(Rtadd_hor_rule(R
R0((s/sys/lib/python2.7/htmllib.pytdo_hr�sc
Csd}d}d}d}d}d}x�|D]�\}} |dkrL| }n|dkra| }n|dkrv| }n|dkr�| }n|dkr�yt| �}Wq�tk
r�q�Xn|d kr+yt| �}Wq�k
r�q�+q+W|j||||||�dS(
NRs(image)italignR-tismapR,twidththeight(tintt
ValueErrorR/(
R
R0R�R-R�R,R�R�R�R�((s/sys/lib/python2.7/htmllib.pytdo_img�s4
cCs|j|�|j�dS(N(RVt
setnomoretags(R
R0((s/sys/lib/python2.7/htmllib.pytdo_plaintext�s
cCsdS(N((R
ttagR0((s/sys/lib/python2.7/htmllib.pytunknown_starttag�scCsdS(N((R
R�((s/sys/lib/python2.7/htmllib.pytunknown_endtag�s(\RRRthtmlentitydefsRRRRRR R$R)R+R/R1R2R3R4R5R6R7R8R;R<R=R>R?RCRERGRHRJRKRMRNRPRQRSRTRURVRXR[R\R^R_R`RaRdRfRiRjRpRsRtRuRvRwRxRzR|R}RR{R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s/sys/lib/python2.7/htmllib.pyRs�
c CsAddl}ddl}|s.|jd}n|oA|ddk}|rT|d=n|rg|d}nd}|dkr�|j}nCyt|d�}Wn-tk
r�}|GdG|GH|jd�nX|j�}||jk r�j�n|r|j �}n|j
|j��}t|�}|j
|�|j�dS( Ni�iis-ss test.htmlt-trt:(tsysRtargvtstdintopentIOErrortexittreadtcloset
NullFormattertAbstractFormattert
DumbWriterRtfeed( R.R�RtsilenttfiletftmsgRtp((s/sys/lib/python2.7/htmllib.pyttest�s2
t__main__(RtwarningsRR RRt__all__tSGMLParseErrorRR
RRR�R(((s/sys/lib/python2.7/htmllib.pyt<module>s �'
|