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`s'||_|d|_|d|_dS(Nii(tmsgtlinenotoffset(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(RRtNoneR (R
tresult((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyt__str__[s N(NN(t__name__t
__module__t__doc__R
RR(((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(R
R((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRzs
cC`s8d|_d|_t|_d|_tjj|�dS(u1Reset this
instance. Loses all unprocessed
data.uu???N( trawdatatlasttagtinteresting_normaltinterestingR
t
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(R
tdata((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(R
tmessage((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(R
telem((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytset_cdata_mode�scC`st|_d|_dS(N(RRR
R(R
((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pytclear_cdata_mode�s c
C`s�|j}d}t|�}xY||krv|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||�}qqsd
||kr/|j|dd!�|j|d�}nPq|d|�rtj
||�}|r�|jd�} |j| �|j�}|d
|d�s�|d}n|j||�}qntj
||�}|r9|r5|j�||kr5|jr|jd�q5||kr|}n|j||d�}nPqs|d|kro|jd�|j||d�}qsPqqW|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
ref(RtlenRtsearchtstartRthandle_datat updatepost
startswithtstarttagopentmatchtparse_starttagtparse_endtagt
parse_commenttparse_piRtparse_declarationtparse_html_declarationR&tfindtcharreftgroupthandle_charreftendt entityrefthandle_entityreft
incomplete(
R
RBRtitnR7tjR5tktname((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR
�s�
cC`s�|j}|||d!dkr-|j|�S|||d!dkrQ|j|�S|||d!j�dkr�|jd|d�}|dkr�dS|j||d |!�|d
S|j|�SdS(Niu<!--iu<![i u <!doctypeu>i����ii(RR:tparse_marked_sectionR)R>thandle_decltparse_bogus_comment(R
RFRtgtpos((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR=s
icC`sX|j}|jd|d�}|dkr/dS|rP|j||d|!�n|dS(Nu>ii����i(RR>thandle_comment(R
RFtreportRtpos((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRM-s cC`s]|j}tj||d�}|s)dS|j�}|j||d|!�|j�}|S(Nii����(RtpicloseR1R2t handle_piRB(R
RFRR7RH((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR;9s cC`s�d|_|j|�}|dkr(|S|j}|||!|_g}tj||d�}|j�}|jd�j�|_ }x||kr�|j
r�tj||�}ntj||�}|s�Pn|jddd�\} }
}|
s�d}nX|d dko|dknsC|d
dko>|dknrS|dd!}n|rk|j
|�}n|j| j�|f�|j�}q�W|||!j�}|d
krb|j�\}
}d
|jkr|
|jjd
�}
t|j�|jjd
�}n|t|j�}|j
rJ|jd|||!d
f�n|j|||!�|S|jd �r�|j||�n/|j||�||jkr�|j|�n|S(Niiiiu'i����u"u>u/>u
u junk characters in start tag:
%ri(u>u/>(R
R'tcheck_for_whole_start_tagRttagfindR7RBR@R)RRtattrfindtattrfind_toleranttunescapetappendtstripR$tcountR0trfindR&R3tendswiththandle_startendtagthandle_starttagtCDATA_CONTENT_ELEMENTSR.(R
RFtendposRtattrsR7RIttagtmtattrnametrestt attrvalueRBRR ((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR8EsZ $$ 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!(
RRtlocatestarttagendR7tlocatestarttagend_tolerantRBR5R4R&tAssertionError(R
RFRRdRHtnext((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRT~s> cC`s�|j}tj||d�}|s)dS|j�}tj||�}|s%|jdk rt|j|||!�|S|j r�|j
d|||!f�ntj||d�}|s�|||d!dkr�|dS|j|�Sn|j
�j�}|jd|j��}|j|�|dS|j
d�j�}|jdk rs||jkrs|j|||!�|Sn|j|j��|j�|S(Nii����ubad
end tag: %riiu</>u>(Rt endendtagR1RBt
endtagfindR7RR
R3RR&ttagfind_tolerantRMR@R)R>t
handle_endtagR/(R
RFRR7RNt namematchttagnameR-((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR9�s:
cC`s!|j||�|j|�dS(N(R_Ro(R
RcRb((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR^�scC`sdS(N((R
RcRb((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR_�scC`sdS(N((R
Rc((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRo�scC`sdS(N((R
RJ((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRA�scC`sdS(N((R
RJ((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRD�scC`sdS(N((R
R!((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyR3�scC`sdS(N((R
R!((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRO�scC`sdS(N((R
tdecl((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRL�scC`sdS(N((R
R!((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRS�scC`s$|jr
|jd|f�ndS(Nuunknown declaration: %r(RR&(R
R!((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]trangeR0(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(R
R|R((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRX�s
(uscriptustyleN(!RRRR`tFalseRRR"R#R&R
R'R(R.R/R
R=RMR;R8RTR9R^R_RoRARDR3RORLRSRsRX(((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyRds:
h 9 + * (
Rt
__future__RRRRtfuture.builtinstfuture.backportsRR*RR+RRERCR?R6RRtcommentcloseRURnRVRWtVERBOSERhRiRlRmt ExceptionRRR(((s@/usr/lib/python2.7/site-packages/future/backports/html/parser.pyt<module>s4 "