• File: HTMLParser.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python27/lib64/python2.7/HTMLParser.pyc
  • Date Modified: 10/26/2026 8:10 PM
  • File size: 14.78 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

jc@s)dZddlZddlZejdZejdZejdZejdZejdZejdZ	ejd	Z
ejd
ZejdZejdZ
ejd
ZejdejZejd	ZejdZdefdYZdejfdYZdS(sA parser for HTML and XHTML.iNs[&<]s
&[a-zA-Z#]s%&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]s)&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]s	<[a-zA-Z]s
</[a-zA-Z]t>s--\s*>s$([a-zA-Z][^	

 />]*)(?:\s|/(?!>))*s[a-zA-Z][^	

 />]*s]((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*s
  <[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|/(?!>))*
     )*
   )?
  \s*                                # trailing whitespace
s#</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>tHTMLParseErrorcBs#eZdZddZdZRS(s&Exception raised for all parse errors.cCs3|st||_|d|_|d|_dS(Nii(tAssertionErrortmsgtlinenotoffset(tselfRtposition((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyt__init__=s	
cCsW|j}|jdk	r,|d|j}n|jdk	rS|d|jd}n|S(Ns, at line %ds, column %di(RRtNoneR(Rtresult((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyt__str__Cs	N(NN(t__name__t
__module__t__doc__R	RR(((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyR:st
HTMLParsercBs
eZdZdZdZdZdZdZdZdZ
dZd	Zd
Z
dZdZd
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ RS( sFind 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).  Entity references are
    passed by calling self.handle_entityref() with the entity
    reference as the argument.  Numeric character references are
    passed to self.handle_charref() with the string containing the
    reference as the argument.
    tscripttstylecCs|jdS(s#Initialize and reset this instance.N(treset(R((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRcscCsSd|_d|_t|_d|_g|_d|_d|_t	j
j|dS(s1Reset this instance.  Loses all unprocessed data.ts???iiN(trawdatatlasttagtinteresting_normaltinterestingR	t
cdata_elemt_pendingt_pending_lent_parse_thresholdt
markupbaset
ParserBaseR(R((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRgs							cCs|jt|7_|j|jkr:|jj|n|jsU|j|7_n2|jj||jdj|j7_|j2d|_t|j}|jdt|j|krd|_nt|j|_dS(sFeed data to the parser.

        Call this as often as you want, with as little or as much text
        as you want (may include '\n').
        RiiN(RtlenRRtappendRtjointgoahead(Rtdatatn((s//opt/alt/python27/lib64/python2.7/HTMLParser.pytfeedrs
		
cCsH|jr7|jdj|j7_|j2d|_n|jddS(sHandle any buffered data.RiiN(RRR RR!(R((s//opt/alt/python27/lib64/python2.7/HTMLParser.pytcloses
	cCst||jdS(N(Rtgetpos(Rtmessage((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyterrorscCs|jS(s)Return full source of start tag: '<...>'.(t_HTMLParser__starttag_text(R((s//opt/alt/python27/lib64/python2.7/HTMLParser.pytget_starttag_textscCs2|j|_tjd|jtj|_dS(Ns</\s*%s\s*>(tlowerRtretcompiletIR(Rtelem((s//opt/alt/python27/lib64/python2.7/HTMLParser.pytset_cdata_modescCst|_d|_dS(N(RRR	R(R((s//opt/alt/python27/lib64/python2.7/HTMLParser.pytclear_cdata_modes	cCs|j}d}t|}x4||krQ|jj||}|rT|j}n|jraPn|}||kr|j|||!n|j||}||krPn|j}|d|rct	j
||r|j|}n|d|r	|j|}n|d|r*|j
|}ns|d|rK|j|}nR|d|rl|j|}n1|d|ks|r|jd|d}nP|dkrN|sPnt	j
||rn}|d|r$|d|kr|jdqEtj
||rqE|j||dn!|d|r|}x8dD]0}	|j|	|dr@|t|	8}Pq@q@W|j||d|!n|d
|r|j||dn|||d!jdkr|j||dnZ|d|r|j||dn3|d|r9|j||dntd|}n|j||}q|d|r3tj
||}|r|jdd!}
|j|
|j}|d|ds|d}n|j||}qqNd||kr/|j|||d!|j||d}nPq|d|r<tj
||}|r|jd}
|j|
|j}|d|ds|d}n|j||}qntj
||}|r|r|j||kr|jdnPqN|d|kr8|jd|j||d}qNPqdstdqW|r||kr|jr|j|||!|j||}n|||_dS(Nit<s</s<!--s<?s<!iis--!s--t-is	<![CDATA[ii	s	<!doctypeswe should not get here!s&#it;t&s#EOF in middle of entity or char refsinteresting.search() lied(s--!s--R3( RRRtsearchtstartRthandle_datat	updatepost
startswithtstarttagopentmatchtparse_starttagtparse_endtagt
parse_commenttparse_pitparse_html_declarationt
endtagopenthandle_commenttendswithtunknown_declR+thandle_declt	handle_piRtcharreftgroupthandle_charreftendt	entityrefthandle_entityreft
incompleteR((RRKRtiR#R<tjR:tktsuffixtname((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyR!s			


	




cCs|j}|||d!dkr0|jdn|||d!dkrT|j|S|||d!dkrx|j|S|||d!jd	kr|jd
|d}|dkrdS|j||d|!|dS|j|SdS(
Nis<!s+unexpected call to parse_html_declaration()is<!--is<![i	s	<!doctypeRii(RR(R?tparse_marked_sectionR+tfindRFtparse_bogus_comment(RRORtgtpos((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRAs	

icCs|j}|||d!dkr0|jdn|jd|d}|dkrVdS|rw|j||d|!n|dS(	Nis<!s</s"unexpected call to parse_comment()Rii(s<!s</(RR(RURC(RROtreportRtpos((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRV4s	cCs|j}|||d!dks,tdtj||d}|sLdS|j}|j||d|!|j}|S(Nis<?sunexpected call to parse_pi()i(RRtpicloseR6R7RGRK(RRORR<RP((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyR@@s	#cCsd|_|j|}|dkr(|S|j}|||!|_g}tj||d}|sotd|j}|jdj	|_
}x||krtj||}|sPn|jddd\}	}
}|
sd}nX|d dko|dkns7|d dko2|dknrG|dd!}n|r_|j|}n|j
|	j	|f|j}qW|||!j}|dkr+|j\}
}d|jkr|
|jjd}
t|j|jjd}n|t|j}|j|||!|S|jd
rM|j||n/|j||||jkr||j|n|S(
Niis#unexpected call to parse_starttag()iis'it"Rs/>s
(Rs/>(R	R)tcheck_for_whole_start_tagRttagfindR<RRKRIR+RtattrfindtunescapeRtstripR&tcountRtrfindR8RDthandle_startendtagthandle_starttagtCDATA_CONTENT_ELEMENTSR0(RROtendposRtattrsR<RQttagtmtattrnametrestt	attrvalueRKRR((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyR=LsR			$$cCs|j}tj||}|r|j}|||d!}|dkrR|dS|dkr|jd|rx|dS|jd|rdS|j||d|jdn|dkrdS|d	krdS||kr|S|dSntd
dS(NiRt/s/>iismalformed empty start tagRs6abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZswe should not get here!(RtlocatestarttagendR<RKR:R9R(R(RRORRiRPtnext((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyR\s,	cCs|j}|||d!dks,tdtj||d}|sLdS|j}tj||}|s$|jdk	r|j	|||!|St
j||d}|s|||d!dkr|dS|j|Sn|jdj
}|jd|j}|j||dS|jdj
}|jdk	rr||jkrr|j	|||!|Sn|j||j|S(	Nis</sunexpected call to parse_endtagiiis</>R(RRt	endendtagR6RKt
endtagfindR<RR	R8R]RVRIR+RUt
handle_endtagR1(RRORR<RWt	namematchttagnameR/((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyR>s8	#


cCs!|j|||j|dS(N(RdRr(RRhRg((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRcscCsdS(N((RRhRg((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRdscCsdS(N((RRh((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRrscCsdS(N((RRS((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRJscCsdS(N((RRS((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRMscCsdS(N((RR"((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyR8scCsdS(N((RR"((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRCscCsdS(N((Rtdecl((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRFscCsdS(N((RR"((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRGscCsdS(N((RR"((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyREscs2d|kr|Sfd}tjd||S(NR5cs|jd}yZ|ddkri|d}|dd
krSt|dd}nt|}t|SWntk
rd|dSXtjdkrd	dl}id
d6}x-|jj	D]\}}t|||<qW|t_nyj|SWnt
k
rd|dSXdS(Nit#itxtXis&#R4iu'taposR5(RwRx(tgroupstinttunichrt
ValueErrorRt
entitydefsR	thtmlentitydefstname2codepointt	iteritemstKeyError(tstcRR~RQtv(R(s//opt/alt/python27/lib64/python2.7/HTMLParser.pytreplaceEntitiess(




s#&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));(R,tsub(RRR((Rs//opt/alt/python27/lib64/python2.7/HTMLParser.pyR_s(RRN(!RR
RReRRR$R%R(R	R)R*R0R1R!RARVR@R=R\R>RcRdRrRJRMR8RCRFRGRER~R_(((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyRLs<									s			4	 	(										(RRR,R-RRNRLRHR;RBRZtcommentcloseR]ttagfind_tolerantR^tVERBOSERnRpRqt	ExceptionRRR(((s//opt/alt/python27/lib64/python2.7/HTMLParser.pyt<module>s(