Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/backports/html/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@`szdZddlmZmZmZmZddlTddlmZddl Z ddl
Z
e jd�Ze jd�Z
e jd�Ze jd �Ze jd
�Ze jd�Ze jd�Ze jd
�Ze jd�Ze jd�Ze jd�Ze jde j�Ze jde j�Ze jd�Ze jd�Zdefd��YZdejfd��YZdS(uLA
parser for HTML and XHTML.
Backported for python-future from Python 3.3.
i(tabsolute_importtdivisiontprint_functiontunicode_literals(t*(t_markupbaseNu[&<]u
&[a-zA-Z#]u%&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]u)&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]u <[a-zA-Z]u>u--\s*>u(([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*u[a-zA-Z][^
/>]*uJ\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*(\'[^\']*\'|"[^"]*"|[^\s"\'=<>`]*))?u]((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*u�
<[a-zA-Z][-.a-zA-Z0-9:_]* # tag name
(?:\s+ # whitespace before attribute name
(?:[a-zA-Z_][-.:a-zA-Z0-9_]* # attribute name
(?:\s*=\s* # value indicator
(?:'[^']*' # LITA-enclosed value
|\"[^\"]*\" # LIT-enclosed value
|[^'\">\s]+ # bare value
)
)?
)
)*
\s* # trailing whitespace
uF
<[a-zA-Z][-.a-zA-Z0-9:_]* # 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*,)* # possibly followed by a comma
)?(?:\s|/(?!>))*
)*
)?
\s* # trailing whitespace
u#</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>tHTMLParseErrorcB`s#eZdZdd�Zd�ZRS(u&Exception
raised for all parse
errors.cC`s3|st�||_|d|_|d|_dS(Nii(tAssertionErrortmsgtlinenotoffset(tselfRtposition((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyt__init__Us
cC`sW|j}|jdk r,|d|j}n|jdk rS|d|jd}n|S(Nu,
at line %du, column %di(RR tNoneR
(Rtresult((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyt__str__[s N(NN(t__name__t
__module__t__doc__RR
R(((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRRst
HTMLParsercB`s
eZdZdZed�Zd�Zd�Zd�Zd�Z dZd�Zd �Z
d
�Zd�Zd�Zd
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z
RS( u�Find 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.
uscriptustylecC`s6|rtjdtdd�n||_|j�dS(u�Initialize
and reset this instance.
If strict is set to False (the default) the parser will parse
invalid
markup, otherwise it will raise an error. Note that the strict
mode
is deprecated.
uThe strict mode is deprecated.t
stackleveliN(twarningstwarntDeprecationWarningtstricttreset(RR((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR
zs
cC`s8d|_d|_t|_d|_tjj|�dS(u1Reset this
instance. Loses all unprocessed
data.uu???N( trawdatatlasttagtinteresting_normaltinterestingRt
cdata_elemRt
ParserBaseR(R((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR�s
cC`s!|j||_|jd�dS(u�Feed data to the parser.
Call this as often as you want, with as little or as much text
as you want (may include '\n').
iN(Rtgoahead(Rtdata((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytfeed�scC`s|jd�dS(uHandle
any buffered
data.iN(R!(R((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytclose�scC`st||j���dS(N(Rtgetpos(Rtmessage((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyterror�scC`s|jS(u)Return
full source of start tag:
'<...>'.(t_HTMLParser__starttag_text(R((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytget_starttag_text�scC`s2|j�|_tjd|jtj�|_dS(Nu</\s*%s\s*>(tlowerRtretcompiletIR(Rtelem((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytset_cdata_mode�scC`st|_d|_dS(N(RRRR(R((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytclear_cdata_mode�s c
C`s�|j}d}t|�}xk||kr�|jj||�}|rT|j�}n|jraPn|}||kr�|j|||!�n|j||�}||kr�Pn|j}|d|�rkt j
||�r�|j|�}n�|d|�r |j|�}n�|d|�r*|j
|�}n�|d|�rK|j|�}ng|d|�r�|jru|j|�}q�|j|�}n+|d|kr�|jd�|d}nP|dkrV|s�Pn|jr�|jd�n|jd |d�}|dkr5|jd|d�}|dkr?|d}q?n
|d7}|j|||!�n|j||�}q|d
|�r3tj
||�}|r�|j�dd!} |j| �|j�}|d
|d�s�|d}n|j||�}qq�d
||kr/|j|dd!�|j|d�}nPq|d|�rstj
||�}|r�|jd�} |j| �|j�}|d
|d�s�|d}n|j||�}qntj
||�}|r9|r5|j�||kr5|jr|jd�q5||kr|}n|j||d�}nPq�|d|kro|jd�|j||d�}q�Pqdstd��qW|r�||kr�|jr�|j|||!�|j||�}n|||_dS(Niu<u</u<!--u<?u<!iuEOF
in middle of constructu>u&#ii����u;u&u#EOF in
middle of entity or char refuinteresting.search()
lied(RtlenRtsearchtstartRthandle_datat updatepost
startswithtstarttagopentmatchtparse_starttagtparse_endtagt
parse_commenttparse_piRtparse_declarationtparse_html_declarationR'tfindtcharreftgroupthandle_charreftendt entityrefthandle_entityreft
incompleteR(
RRCRtitnR8tjR6tktname((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR!�s�
cC`s�|j}|||d!dks,td��|||d!dkrP|j|�S|||d!dkrt|j|�S|||d!j�d kr�|jd
|d�}|dkr�dS|j||d|!�|dS|j|�SdS(
Niu<!u+unexpected
call to
parse_html_declaration()iu<!--iu<![i u <!doctypeu>i����i(RRR;tparse_marked_sectionR*R?thandle_decltparse_bogus_comment(RRGRtgtpos((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR>s #
icC`s{|j}|||d!dks,td��|jd|d�}|dkrRdS|rs|j||d|!�n|dS( Niu<!u</u"unexpected
call to
parse_comment()u>i����i(u<!u</(RRR?thandle_comment(RRGtreportRtpos((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRN-s #cC`s�|j}|||d!dks,td��tj||d�}|sLdS|j�}|j||d|!�|j�}|S(Niu<?uunexpected
call to
parse_pi()i����(RRtpicloseR2R3t handle_piRC(RRGRR8RI((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR<9s #cC`s�d|_|j|�}|dkr(|S|j}|||!|_g}tj||d�}|sotd��|j�}|jd�j �|_
}x||kr�|jr�tj||�}nt
j||�}|s�Pn|jddd�\} }
}|
s
d}nX|d dko,|dknsU|d
dkoP|dknre|dd!}n|r}|j|�}n|j| j �|f�|j�}q�W|||!j�}|dkrt|j�\}
}d|jkr|
|jjd�}
t|j�|jjd�}n|t|j�}|jr\|jd|||!d
f�n|j|||!�|S|jd
�r�|j||�n/|j||�||jkr�|j|�n|S(Niiu#unexpected
call to parse_starttag()iiu'i����u"u>u/>u
u junk characters in start tag:
%ri(u>u/>(RR(tcheck_for_whole_start_tagRttagfindR8RRCRAR*RRtattrfindtattrfind_toleranttunescapetappendtstripR%tcountR1trfindR'R4tendswiththandle_startendtagthandle_starttagtCDATA_CONTENT_ELEMENTSR/(RRGtendposRtattrsR8RJttagtmtattrnametrestt attrvalueRCR R
((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR9Es\ $$ cC`sh|j}|jr'tj||�}ntj||�}|rX|j�}|||d!}|dkrp|dS|dkr�|jd|�r�|dS|jd|�r�dS|jr�|j||d�|jd�n||kr�|S|dSn|dkrdS|d krdS|jr=|j||�|jd
�n||krM|S|dSnt d��dS(Niu>u/u/>ii����umalformed
empty start
taguu6abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZumalformed
start taguwe should not get here!(
RRtlocatestarttagendR8tlocatestarttagend_tolerantRCR6R5R'R(RRGRReRItnext((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRU~s> cC`s�|j}|||d!dks,td��tj||d�}|sLdS|j�}tj||�}|sH|jdk r�|j |||!�|S|j
r�|jd|||!f�ntj||d�}|s |||d!dkr�|dS|j
|�Sn|j�j�}|jd |j��}|j|�|dS|jd�j�}|jdk r�||jkr�|j |||!�|Sn|j|j��|j�|S(
Niu</uunexpected call to parse_endtagii����ubad end tag:
%riu</>u>(RRt endendtagR2RCt
endtagfindR8RRR4RR'ttagfind_tolerantRNRAR*R?t
handle_endtagR0(RRGRR8ROt namematchttagnameR.((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR:�s< #
cC`s!|j||�|j|�dS(N(R`Ro(RRdRc((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR_�scC`sdS(N((RRdRc((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR`�scC`sdS(N((RRd((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRo�scC`sdS(N((RRK((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRB�scC`sdS(N((RRK((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRE�scC`sdS(N((RR"((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR4�scC`sdS(N((RR"((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRP�scC`sdS(N((Rtdecl((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRM�scC`sdS(N((RR"((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRT�scC`s$|jr
|jd|f�ndS(Nuunknown declaration:
%r(RR'(RR"((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytunknown_decl�s cC`s,d|kr|Sd�}tjd||�S(Nu&cS`s
|j�d}yl|ddkr{|d}|ddkr\t|djd�d�}nt|jd��}t|�SWntk
r�d|SXdd lm}||kr�||S|jd�r�d
|SxItdt |��D]*}|| |kr�||| ||Sq�Wd
|SdS(
Niu#iuxuXu;iu&#(thtml5u&i(uxuX(
tgroupstinttrstriptchrt
ValueErrortfuture.backports.html.entitiesRtR^trangeR1(tstcRttx((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytreplaceEntities�s&
u&&(#?[xX]?(?:[0-9a-fA-F]+;|\w{1,32};?))(R+tsub(RR|R((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRY�s
(uscriptustyleN(!RRRRatFalseR
RR#R$R'RR(R)R/R0R!R>RNR<R9RUR:R_R`RoRBRER4RPRMRTRsRY(((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRds:
h 9 + * (
Rt
__future__RRRRtfuture.builtinstfuture.backportsRR+RR,RRFRDR@R7RStcommentcloseRVRnRWRXtVERBOSERiRjRlRmt ExceptionRR
R(((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyt<module>s4 "