Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/
Upload File :
Current File : //usr/lib/python2.7/sgmllib.pyc


|_c@s]dZddlmZeddd[ddlZddlZddgZejd	Zejd
ZejdZ	ejdZ
ejd
ZejdZ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/lib/python2.7/sgmllib.pyR,scBsieZejdZddZdZdZdZdZ	dZ
dZd	Zd
Z
dZd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/lib/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/lib/python2.7/sgmllib.pyR	Gs						cCsd|_|_dS(sYEnter literal mode (CDATA) till EOF.

        Intended for derived classes only.
        iN(RR(R
((s/usr/lib/python2.7/sgmllib.pyt
setnomoretagsQscGs
d|_dS(sPEnter literal mode (CDATA).

        Intended for derived classes only.
        iN(R(R
targs((s/usr/lib/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/lib/python2.7/sgmllib.pytfeed_scCs|jddS(sHandle the remaining data.iN(R(R
((s/usr/lib/python2.7/sgmllib.pytclosejscCst|dS(N(R(R
tmessage((s/usr/lib/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|jd|rt|j|}|dkr_Pn|}d|_	qn|j	r||dkr|jd|d}qPqn|jd|r|j
|}|dkrPn|}qn|jd|r,|j|}|dkrPn||}qn|jd|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(Nit<is</s<!--s<?s<!t&t;sneither < nor & ??(RtlenRthandle_datatinterestingtsearchtstarttstarttagopentmatchRtparse_starttagt
startswithtparse_endtagt
parse_commenttparse_pitparse_declarationtcharreftgroupthandle_charreftendt	entityrefthandle_entityrefRt
incomplete(	R
R2RtitnR(tjtktname((s/usr/lib/python2.7/sgmllib.pyRts			
		


		




	


	t=cCs|j}|||d!dkr0|jdntj||d}|sPdS|jd}|j||d|!|jd}||S(Nis<?sunexpected call to parse_pi()ii(RRtpicloseR%R&t	handle_piR2(R
R6RR(R8((s/usr/lib/python2.7/sgmllib.pyR-s	cCs|jS(N(R(R
((s/usr/lib/python2.7/sgmllib.pytget_starttag_textsc
Csd|_|}|j}tj||rtj||}|sFdS|jdd\}}d||_|j}|jd}|j	|||||jdd!|_|St
j||d}|sdS|jd}g}	|||d!dkr|}|j
}n[tj||d}|sA|jdn|jd}||d|!j}||_
x||krctj||}|sPn|jddd\}
}}|s|
}np|d d	ko|dkns|d d
ko|dknr |dd!}n|jj|j|}|	j|
j|f|jd}qsW||dkr|d}n|||!|_|j||	|S(Niiis<%s/is<>s!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/lib/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/lib/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/lib/python2.7/sgmllib.pyR+7s	

cCs.|j|g|j||j|dS(N(RLR#RW(R
RNR((s/usr/lib/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/lib/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/lib/python2.7/sgmllib.pyRW]s4







cCs||dS(N((R
RNR^RO((s/usr/lib/python2.7/sgmllib.pyR]|scCs|dS(N((R
RNR^((s/usr/lib/python2.7/sgmllib.pyRcscCs)|jr%d|dGHdG|jGHndS(Ns*** Unbalanced </Rs
*** Stack:(RR(R
RN((s/usr/lib/python2.7/sgmllib.pyRas	
cCsRyt|}Wntk
r$dSXd|ko<dknsEdS|j|S(s/Convert character reference, may be overridden.Nii(tintt
ValueErrortconvert_codepoint(R
R:R7((s/usr/lib/python2.7/sgmllib.pyRSs
cCs
t|S(N(tchr(R
t	codepoint((s/usr/lib/python2.7/sgmllib.pyRgscCs<|j|}|dkr+|j|n
|j|dS(s0Handle character reference, no need to override.N(RSR
tunknown_charrefR#(R
R:treplacement((s/usr/lib/python2.7/sgmllib.pyR1sRtltRtgtR tampR@tquots'taposcCs%|j}||kr||SdSdS(sConvert entity references.

        As an alternative to overriding this method; one can tailor the
        results by setting up the self.entitydefs mapping appropriately.
        N(t
entitydefs(R
R:ttable((s/usr/lib/python2.7/sgmllib.pyRUs	cCs<|j|}|dkr+|j|n
|j|dS(s.Handle entity references, no need to override.N(RUR
tunknown_entityrefR#(R
R:Rk((s/usr/lib/python2.7/sgmllib.pyR4scCsdS(N((R
R((s/usr/lib/python2.7/sgmllib.pyR#scCsdS(N((R
R((s/usr/lib/python2.7/sgmllib.pythandle_commentscCsdS(N((R
tdecl((s/usr/lib/python2.7/sgmllib.pythandle_declscCsdS(N((R
R((s/usr/lib/python2.7/sgmllib.pyR=scCsdS(N((R
RNRO((s/usr/lib/python2.7/sgmllib.pyR\scCsdS(N((R
RN((s/usr/lib/python2.7/sgmllib.pyR`scCsdS(N((R
tref((s/usr/lib/python2.7/sgmllib.pyRjscCsdS(N((R
Rw((s/usr/lib/python2.7/sgmllib.pyRss('RRtretcompileRHRR	RRRRRRt_decl_othercharsR-R>R)RJR+RDRLRWR]RcRaRSRgR1RqRUR4R#RtRvR=R\R`RjRs(((s/usr/lib/python2.7/sgmllib.pyR<sF	
						g			>		
							
		
)										tTestSGMLParsercBseeZddZdZdZdZdZdZdZdZ	d	Z
d
ZRS(icCsd|_tj||dS(NR(ttestdataRR(R
R((s/usr/lib/python2.7/sgmllib.pyRs	cCs<|j||_tt|jdkr8|jndS(NiF(R|R"treprtflush(R
R((s/usr/lib/python2.7/sgmllib.pyR#scCs.|j}|r*d|_dGt|GHndS(NRsdata:(R|R}(R
R((s/usr/lib/python2.7/sgmllib.pyR~s		cCsN|jt|}t|dkrA|d d|d}ndG|GHdS(NiDi s...iscomment:(R~R}R"(R
Rtr((s/usr/lib/python2.7/sgmllib.pyRts

cCs\|j|s d|dGHn8d|Gx(|D] \}}|dd|dGq/WdGHdS(Nsstart tag: <RR;R@(R~(R
RNROR:tvalue((s/usr/lib/python2.7/sgmllib.pyR\s
cCs|jd|dGHdS(Nsend tag: </R(R~(R
RN((s/usr/lib/python2.7/sgmllib.pyR`s
cCs|jd|dGHdS(Ns*** unknown entity ref: &R!(R~(R
Rw((s/usr/lib/python2.7/sgmllib.pyRss
cCs|jd|dGHdS(Ns*** unknown char ref: &#R!(R~(R
Rw((s/usr/lib/python2.7/sgmllib.pyRjs
cCs|jd|dGHdS(Ns*** unknown decl: [t](R~(R
R((s/usr/lib/python2.7/sgmllib.pytunknown_decls
cCstj||jdS(N(RRR~(R
((s/usr/lib/python2.7/sgmllib.pyRs
(RRRR#R~RtR\R`RsRjRR(((s/usr/lib/python2.7/sgmllib.pyR{s				
				c	Cs(ddl}|dkr(|jd}n|rQ|ddkrQ|d}t}nt}|rj|d}nd}|dkr|j}nCyt|d}Wn-tk
r}|GdG|GH|jdnX|j	}||jk	r|j
n|}x|D]}|j|qW|j
dS(	Niiis-ss	test.htmlt-Rt:(tsysR
targvRR{tstdintopentIOErrortexittreadRR(	RRtklasstfiletftmsgRtxtc((s/usr/lib/python2.7/sgmllib.pyttests0
	


	
t__main__(RtwarningsRRRxt__all__RyR$R5R3R/R'RARBR<RERFRGtRuntimeErrorRRRR{R
RR(((s/usr/lib/python2.7/sgmllib.pyt<module>s4		7$