nfc@s]dZddlmZeddd[ddlZddlZddgZejd Zejd Zejd Z ejd Z ejd Z ejdZ ejdZ ejdZejdZejdZejdZdefdYZdejfdYZdefdYZedZedkrYendS(s;A parser for SGML, using the derived class as a static DTD.i(twarnpy3ks1the sgmllib module has been removed in Python 3.0t stackleveliNt SGMLParsertSGMLParseErrors[&<]sN&([a-zA-Z][a-zA-Z0-9]*|#[0-9]*)?|<([a-zA-Z][^<>]*|/([a-zA-Z][^<>]*)?|![^<>]*)?s%&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]s&#([0-9]+)[^0-9]s <[>a-zA-Z]s<[a-zA-Z][-.a-zA-Z0-9]*/s"<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/t>s[<>]s[a-zA-Z][-_.a-zA-Z0-9]*se\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*(\'[^\']*\'|"[^"]*"|[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*))?cBseZdZRS(s&Exception raised for all parse errors.(t__name__t __module__t__doc__(((s/usr/lib64/python2.7/sgmllib.pyR,scBsieZejdZddZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZidd6dd6dd6dd 6d!d"6Zd#Zd$Zd%Zd&Z d'Z!d(Z"d)Z#d*Z$d+Z%d,Z&RS(-s+&(?:([a-zA-Z][-.a-zA-Z0-9]*)|#([0-9]+))(;?)icCs||_|jdS(s#Initialize and reset this instance.N(tverbosetreset(tselfR((s/usr/lib64/python2.7/sgmllib.pyt__init__Bs cCsJd|_d|_g|_d|_d|_d|_tjj |dS(s0Reset this instance. Loses all unprocessed data.ts???iN( tNonet_SGMLParser__starttag_texttrawdatatstacktlasttagt nomoretagstliteralt markupbaset ParserBaseR (R ((s/usr/lib64/python2.7/sgmllib.pyR Gs      cCsd|_|_dS(sYEnter literal mode (CDATA) till EOF. Intended for derived classes only. iN(RR(R ((s/usr/lib64/python2.7/sgmllib.pyt setnomoretagsQscGs d|_dS(sPEnter literal mode (CDATA). Intended for derived classes only. iN(R(R targs((s/usr/lib64/python2.7/sgmllib.pyt setliteralXscCs!|j||_|jddS(sFeed some data to the parser. Call this as often as you want, with as little or as much text as you want (may include ' '). (This just saves the text, all the processing is done by goahead().) iN(Rtgoahead(R tdata((s/usr/lib64/python2.7/sgmllib.pytfeed_scCs|jddS(sHandle the remaining data.iN(R(R ((s/usr/lib64/python2.7/sgmllib.pytclosejscCst|dS(N(R(R tmessage((s/usr/lib64/python2.7/sgmllib.pyterrornsc Cs@|j}d}t|}x||kr|jrQ|j|||!|}Pntj||}|rx|j}n|}||kr|j|||!n|}||krPn||dkrltj||r.|j r|j|||d}qn|j |}|dkr"Pn|}qn|j d|rt|j |}|dkr_Pn|}d|_ qn|j r||dkr|jd|d}qPqn|j d|r|j |}|dkrPn|}qn|j d|r,|j|}|dkrPn||}qn|j d|r|j|}|dkr]Pn|}qqn||dkr}|j r|j|||d}qntj||}|r|jd}|j||jd}||dd kr|d}qqntj||}|r|jd}|j||jd}||dd kr|d}qqqn |jd tj||}|s|j|||d}qn|jd}||krPn|j|||!|}qW|r/||kr/|j|||!|}n|||_dS( Nits!unexpected call to parse_starttagit't"R(R RRt shorttagopenR(tshorttagR0tlowerR2tfinish_shorttagt endbracketR%R&RttagfindRtattrfindtentity_or_charreftsubt _convert_reftappendtfinish_starttag( R R6t start_posRR(ttagRR9R8tattrstattrnametrestt attrvalue((s/usr/lib64/python2.7/sgmllib.pyR)s^       $$  cCs|jdr9|j|jdp8d|jdS|jdrq|j|jdppd|jdSd|jdSdS(Nis&#%s%siis&%s;s&%s(R0tconvert_charreftgroupstconvert_entityref(R R(((s/usr/lib64/python2.7/sgmllib.pyRJ,scCs|j}tj||d}|s)dS|jd}||d|!jj}||dkrr|d}n|j||S(NiiiiR(RRER%R&tstripRCt finish_endtag(R R6RR(R8RN((s/usr/lib64/python2.7/sgmllib.pyR+7s   cCs.|j|g|j||j|dS(N(RLR#RW(R RNR((s/usr/lib64/python2.7/sgmllib.pyRDDs cCsyt|d|}Wndtk r}yt|d|}Wn"tk rb|j||dSX|j|||dSn(X|jj||j|||dSdS(Ntstart_tdo_iii(tgetattrtAttributeErrortunknown_starttagthandle_starttagRRK(R RNROtmethod((s/usr/lib64/python2.7/sgmllib.pyRLKs  cCsa|s9t|jd}|dkr|j|dSn||jkryt|d|}Wntk r|j|nX|j|dSt|j}x0t|D]"}|j||kr|}qqWxt|j|kr\|jd}yt|d|}Wntk r(d}nX|rB|j||n |j||jd=qWdS(Niitend_i( R"Rtunknown_endtagRZR[treport_unbalancedtrangeR t handle_endtag(R RNtfoundR^R6((s/usr/lib64/python2.7/sgmllib.pyRW]s4         cCs||dS(N((R RNR^RO((s/usr/lib64/python2.7/sgmllib.pyR]|scCs |dS(N((R RNR^((s/usr/lib64/python2.7/sgmllib.pyRcscCs)|jr%d|dGHdG|jGHndS(Ns*** Unbalanced R)RJR+RDRLRWR]RcRaRSRgR1RqRUR4R#RtRvR=R\R`RjRs(((s/usr/lib64/python2.7/sgmllib.pyR<sF      g  >        )       tTestSGMLParsercBseeZddZdZdZdZdZdZdZdZ d Z d Z RS( icCsd|_tj||dS(NR (ttestdataRR (R R((s/usr/lib64/python2.7/sgmllib.pyR s cCs<|j||_tt|jdkr8|jndS(NiF(R|R"treprtflush(R R((s/usr/lib64/python2.7/sgmllib.pyR#scCs.|j}|r*d|_dGt|GHndS(NR sdata:(R|R}(R R((s/usr/lib64/python2.7/sgmllib.pyR~s  cCsN|jt|}t|dkrA|d d|d}ndG|GHdS(NiDi s...iscomment:(R~R}R"(R Rtr((s/usr/lib64/python2.7/sgmllib.pyRts   cCs\|j|s d|dGHn8d|Gx(|D] \}}|dd|dGq/WdGHdS(Ns start tag: s4      7 $