usr/lib64/python2.7/htmllib.pyc000064400000047525147204465540012245 0ustar00 zfc@sdZddlmZeddd[ddlZddlmZdd gZd ejfd YZdej fd YZ e d Z e d kre 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/usr/lib64/python2.7/htmllib.pyRscBs3eZdZddlmZddZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ 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/Z0d0Z1d1Z2d2Z3d3Z4d4Z5d5Z6d6Z7d7Z8d8Z9d9Z:d:Z;d;Z<d<Z=d=Z>dd>Z?d?Z@d@ZAdAZBdBZCdCZDdDZEdEZFdFZGdGZHdHZIdIZJdJZKdKZLdLZMdMZNdNZOdOZPdPZQdQZRdRZSdSZTdTZUdUZVdVZWdWZXdXZYdYZZdZZ[RS([sThis 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(sCreates an instance of the HTMLParser class. The formatter parameter is the formatter instance associated with the parser. N(tsgmllibt SGMLParsert__init__t formatter(tselfR tverbose((s/usr/lib64/python2.7/htmllib.pyR "scCst|dS(N(R(R tmessage((s/usr/lib64/python2.7/htmllib.pyterror,scCs\tjj|d|_d|_d|_d|_d|_g|_ d|_ g|_ dS(Ni( R R tresettNonetsavedatatisindexttitletbasetanchort anchorlisttnofillt list_stack(R ((s/usr/lib64/python2.7/htmllib.pyR/s       cCsR|jdk r"|j||_n,|jr>|jj|n|jj|dS(N(RRRR tadd_literal_datatadd_flowing_data(R tdata((s/usr/lib64/python2.7/htmllib.pyt handle_data?s  cCs d|_dS(sBegins 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/usr/lib64/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/usr/lib64/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 tag with the same names. The default implementation maintains a list of hyperlinks (defined by the HREF attribute for tags) within the document. The list of hyperlinks is available as the data attribute anchorlist. N(RRtappend(R threftnamettype((s/usr/lib64/python2.7/htmllib.pyt anchor_bgnes  cCs3|jr/|jdt|jd|_ndS(sThis 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/usr/lib64/python2.7/htmllib.pyt anchor_endss cGs|j|dS(sThis method is called to handle images. The default implementation simply passes the alt value to the handle_data() method. N(R(R tsrctalttargs((s/usr/lib64/python2.7/htmllib.pyt handle_imagescCsdS(N((R tattrs((s/usr/lib64/python2.7/htmllib.pyt start_htmlRcCsdS(N((R ((s/usr/lib64/python2.7/htmllib.pytend_htmlRcCsdS(N((R R0((s/usr/lib64/python2.7/htmllib.pyt start_headRcCsdS(N((R ((s/usr/lib64/python2.7/htmllib.pytend_headRcCsdS(N((R R0((s/usr/lib64/python2.7/htmllib.pyt start_bodyRcCsdS(N((R ((s/usr/lib64/python2.7/htmllib.pytend_bodyRcCs|jdS(N(R (R R0((s/usr/lib64/python2.7/htmllib.pyt start_titlescCs|j|_dS(N(R$R(R ((s/usr/lib64/python2.7/htmllib.pyt end_titlescCs3x,|D]$\}}|dkr||_qqWdS(NR&(R(R R0tatv((s/usr/lib64/python2.7/htmllib.pytdo_bases cCs d|_dS(Ni(R(R R0((s/usr/lib64/python2.7/htmllib.pyt do_isindexscCsdS(N((R R0((s/usr/lib64/python2.7/htmllib.pytdo_linkscCsdS(N((R R0((s/usr/lib64/python2.7/htmllib.pytdo_metascCsdS(N((R R0((s/usr/lib64/python2.7/htmllib.pyt do_nextidscCs$|jjd|jjddS(Nith1i(R@iii(R t end_paragrapht push_font(R R0((s/usr/lib64/python2.7/htmllib.pytstart_h1scCs!|jjd|jjdS(Ni(R RAtpop_font(R ((s/usr/lib64/python2.7/htmllib.pytend_h1scCs$|jjd|jjddS(Nith2i(RFiii(R RARB(R R0((s/usr/lib64/python2.7/htmllib.pytstart_h2scCs!|jjd|jjdS(Ni(R RARD(R ((s/usr/lib64/python2.7/htmllib.pytend_h2scCs$|jjd|jjddS(Nith3i(RIiii(R RARB(R R0((s/usr/lib64/python2.7/htmllib.pytstart_h3scCs!|jjd|jjdS(Ni(R RARD(R ((s/usr/lib64/python2.7/htmllib.pytend_h3scCs$|jjd|jjddS(Nith4i(RLiii(R RARB(R R0((s/usr/lib64/python2.7/htmllib.pytstart_h4scCs!|jjd|jjdS(Ni(R RARD(R ((s/usr/lib64/python2.7/htmllib.pytend_h4scCs$|jjd|jjddS(Nith5i(ROiii(R RARB(R R0((s/usr/lib64/python2.7/htmllib.pytstart_h5scCs!|jjd|jjdS(Ni(R RARD(R ((s/usr/lib64/python2.7/htmllib.pytend_h5scCs$|jjd|jjddS(Nith6i(RRiii(R RARB(R R0((s/usr/lib64/python2.7/htmllib.pytstart_h6scCs!|jjd|jjdS(Ni(R RARD(R ((s/usr/lib64/python2.7/htmllib.pytend_h6scCs|jjddS(Ni(R RA(R R0((s/usr/lib64/python2.7/htmllib.pytdo_pscCs@|jjd|jjtttdf|jd|_dS(Ni(R RARBRR(R R0((s/usr/lib64/python2.7/htmllib.pyt start_prescCs:|jjd|jjtd|jd|_dS(Nii(R RARDtmaxR(R ((s/usr/lib64/python2.7/htmllib.pytend_pres cCs|j||jddS(Ntxmp(RVt setliteral(R R0((s/usr/lib64/python2.7/htmllib.pyt start_xmps cCs|jdS(N(RX(R ((s/usr/lib64/python2.7/htmllib.pytend_xmpscCs|j||jddS(Ntlisting(RVRZ(R R0((s/usr/lib64/python2.7/htmllib.pyt start_listings cCs|jdS(N(RX(R ((s/usr/lib64/python2.7/htmllib.pyt end_listingscCs0|jjd|jjtdttfdS(Nii(R RARBR(R R0((s/usr/lib64/python2.7/htmllib.pyt start_addressscCs!|jjd|jjdS(Ni(R RARD(R ((s/usr/lib64/python2.7/htmllib.pyt end_addressscCs$|jjd|jjddS(Nit blockquote(R RAt push_margin(R R0((s/usr/lib64/python2.7/htmllib.pytstart_blockquotescCs!|jjd|jjdS(Ni(R RAt pop_margin(R ((s/usr/lib64/python2.7/htmllib.pytend_blockquote scCsA|jj|j |jjd|jjdddgdS(Ntult*i(R RARRcR%(R R0((s/usr/lib64/python2.7/htmllib.pytstart_ulscCs;|jr|jd=n|jj|j |jjdS(Ni(RR RARe(R ((s/usr/lib64/python2.7/htmllib.pytend_uls cCsk|jjd|jrH|jd\}}}}|d|d<}n d\}}|jj||dS(NiiiiRh(Rhi(R RARtadd_label_data(R R0tdummytlabeltcounterttop((s/usr/lib64/python2.7/htmllib.pytdo_lis   cCs|jj|j |jjdd}xH|D]@\}}|dkr1t|dkrh|d}n|}q1q1W|jjd|dgdS(Ntols1.R(it.i(R RARRcR*R%(R R0RmR9R:((s/usr/lib64/python2.7/htmllib.pytstart_ol#s   cCs;|jr|jd=n|jj|j |jjdS(Ni(RR RARe(R ((s/usr/lib64/python2.7/htmllib.pytend_ol-s cCs|j|dS(N(Ri(R R0((s/usr/lib64/python2.7/htmllib.pyt start_menu2scCs|jdS(N(Rj(R ((s/usr/lib64/python2.7/htmllib.pytend_menu5scCs|j|dS(N(Ri(R R0((s/usr/lib64/python2.7/htmllib.pyt start_dir8scCs|jdS(N(Rj(R ((s/usr/lib64/python2.7/htmllib.pytend_dir;scCs-|jjd|jjdddgdS(NitdlRi(R RARR%(R R0((s/usr/lib64/python2.7/htmllib.pytstart_dl>scCs'|jd|jr#|jd=ndS(Nii(tddpopR(R ((s/usr/lib64/python2.7/htmllib.pytend_dlBs  cCs|jdS(N(R{(R R0((s/usr/lib64/python2.7/htmllib.pytdo_dtFscCs7|j|jjd|jjdddgdS(NtddRi(R{R RcRR%(R R0((s/usr/lib64/python2.7/htmllib.pytdo_ddIs cCsQ|jj||jrM|jdddkrM|jd=|jjqMndS(NiiR~(R RARRe(R tbl((s/usr/lib64/python2.7/htmllib.pyR{Ns   cCs|j|dS(N(tstart_i(R R0((s/usr/lib64/python2.7/htmllib.pyt start_citeYRcCs|jdS(N(tend_i(R ((s/usr/lib64/python2.7/htmllib.pytend_citeZRcCs|j|dS(N(tstart_tt(R R0((s/usr/lib64/python2.7/htmllib.pyt start_code\RcCs|jdS(N(tend_tt(R ((s/usr/lib64/python2.7/htmllib.pytend_code]RcCs|j|dS(N(R(R R0((s/usr/lib64/python2.7/htmllib.pytstart_em_RcCs|jdS(N(R(R ((s/usr/lib64/python2.7/htmllib.pytend_em`RcCs|j|dS(N(R(R R0((s/usr/lib64/python2.7/htmllib.pyt start_kbdbRcCs|jdS(N(R(R ((s/usr/lib64/python2.7/htmllib.pytend_kbdcRcCs|j|dS(N(R(R R0((s/usr/lib64/python2.7/htmllib.pyt start_sampeRcCs|jdS(N(R(R ((s/usr/lib64/python2.7/htmllib.pytend_sampfRcCs|j|dS(N(tstart_b(R R0((s/usr/lib64/python2.7/htmllib.pyt start_stronghRcCs|jdS(N(tend_b(R ((s/usr/lib64/python2.7/htmllib.pyt end_strongiRcCs|j|dS(N(R(R R0((s/usr/lib64/python2.7/htmllib.pyt start_varkRcCs|jdS(N(R(R ((s/usr/lib64/python2.7/htmllib.pytend_varlRcCs |jjtdttfdS(Ni(R RBR(R R0((s/usr/lib64/python2.7/htmllib.pyRpscCs|jjdS(N(R RD(R ((s/usr/lib64/python2.7/htmllib.pyRrscCs |jjttdtfdS(Ni(R RBR(R R0((s/usr/lib64/python2.7/htmllib.pyRuscCs|jjdS(N(R RD(R ((s/usr/lib64/python2.7/htmllib.pyRwscCs |jjtttdfdS(Ni(R RBR(R R0((s/usr/lib64/python2.7/htmllib.pyRzscCs|jjdS(N(R RD(R ((s/usr/lib64/python2.7/htmllib.pyR|scCsd}d}d}xe|D]]\}}|j}|dkrF|}n|dkr[|}n|dkr|j}qqW|j|||dS(NRR&R'R((tstriptlowerR)(R R0R&R'R(tattrnametvalue((s/usr/lib64/python2.7/htmllib.pytstart_as      cCs|jdS(N(R+(R ((s/usr/lib64/python2.7/htmllib.pytend_ascCs|jjdS(N(R tadd_line_break(R R0((s/usr/lib64/python2.7/htmllib.pytdo_brscCs|jjdS(N(R t add_hor_rule(R R0((s/usr/lib64/python2.7/htmllib.pytdo_hrsc Csd}d}d}d}d}d}x|D]\}} |dkrL| }n|dkra| }n|dkrv| }n|dkr| }n|dkryt| }Wqtk rqXn|d kr+yt| }Wqtk rqXq+q+W|j||||||dS( NRs(image)italignR-tismapR,twidththeight(tintt ValueErrorR/( R R0RR-RR,RRRR((s/usr/lib64/python2.7/htmllib.pytdo_imgs4            cCs|j||jdS(N(RVt setnomoretags(R R0((s/usr/lib64/python2.7/htmllib.pyt do_plaintexts cCsdS(N((R ttagR0((s/usr/lib64/python2.7/htmllib.pytunknown_starttagscCsdS(N((R R((s/usr/lib64/python2.7/htmllib.pytunknown_endtags(\RRRthtmlentitydefsRR RRRR R$R)R+R/R1R2R3R4R5R6R7R8R;R<R=R>R?RCRERGRHRJRKRMRNRPRQRSRTRURVRXR[R\R^R_R`RaRdRfRiRjRpRsRtRuRvRwRxRzR|R}RR{RRRRRRRRRRRRRRRRRRRRRRRRRRRR(((s/usr/lib64/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|jdnX|j}||jk r|jn|r|j }n|j |j }t |}|j ||jdS( Niiis-ss test.htmlt-trt:(tsysR targvtstdintopentIOErrortexittreadtcloset NullFormattertAbstractFormattert DumbWriterRtfeed( R.RR tsilenttfiletftmsgRtp((s/usr/lib64/python2.7/htmllib.pyttests2         t__main__(RtwarningsRR R Rt__all__tSGMLParseErrorRR RRRR(((s/usr/lib64/python2.7/htmllib.pyts    '