��
���Lc@s}dZddkZeid�iZeid�iZeid�Zeid�Zeid�Z[dd
d ��YZ dS(s�Shared support for scanning document type declarations in HTML and XHTML.
This module is used as a foundation for the HTMLParser and sgmllib
modules (indirectly, for htmllib as well). It has no documented
public API and should not be used directly.
i����Ns[a-zA-Z][-_.a-zA-Z0-9]*\s*s(\'[^\']*\'|"[^"]*")\s*s--\s*>s ]\s*]\s*>s]\s*>t
ParserBasecBs�eZdZd�Zd�Zd�Zd�Zd�ZdZd�Z dd �Z
dd
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�ZRS(siParser base class which provides some common support methods used
by the SGML/HTML and XHTML parsers.cCs$|itjotd��ndS(Ns(markupbase.ParserBase must be subclassed(t __class__RtRuntimeError(tself((s /usr/lib/python2.6/markupbase.pyt__init__scCstd��dS(Ns.subclasses of ParserBase must override error()(tNotImplementedError(Rtmessage((s /usr/lib/python2.6/markupbase.pyterror!scCsd|_d|_dS(Nii(tlinenotoffset(R((s /usr/lib/python2.6/markupbase.pytreset%s cCs|i|ifS(s&Return current line number and offset.(RR (R((s /usr/lib/python2.6/markupbase.pytgetpos)scCs�||jo|S|i}|id||�}|o:|i||_|id||�}||d|_n|i|||_|S(Ns
i(trawdatatcountRtrindexR (RtitjRtnlinestpos((s /usr/lib/python2.6/markupbase.pyt updatepos1s
tc
Cs�|i}|d}|||!djp
td�|||d!djo |dS|||d!djodSt|�}|||d!d jo|i|�S||d
jo|i|�S|i||�\}}|djo|S|djo
d|_nx{||jom||}|djoE||d|!}|djo|i|�n|i|�|dS|d
jo+t ||�}|pdS|i
�}n�|djo|i||�\} }n�||ijo|d}n}|d
joZ|djo|i|d|�}qk|djo|id|�qk|id�n|id||�|djo|SqWdS(Nis<!s$unexpected call to parse_declarationit>t-Ri����s--t[itdoctypes"'t4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZtattlisttlinktypetlinktelements&unsupported '[' char in %s declarations"unexpected '[' char in declarations!unexpected %r char in declaration(RR(RRslinkR(
RtAssertionErrortlent
parse_commenttparse_marked_sectiont
_scan_namet_decl_othercharsthandle_decltunknown_declt_declstringlit_matchtendt_parse_doctype_subsetR(
RRRRtntdecltypetctdatatmtname((s /usr/lib/python2.6/markupbase.pytparse_declarationAs\
icCs|i}|||d!djp
td�|i|d|�\}}|djo|S|djoti||d�}nD|djoti||d�}n|id
||d|!�|pdS|o+|id�}|i||d|!�n|i d�S(Nis<![s)unexpected call to parse_marked_section()ittemptcdatatignoretincludetrcdatatiftelsetendifs+unknown status keyword %r in marked sectioni����(R0R1signoreR3R4(R5R6R7(
RRR"t_markedsectionclosetsearcht_msmarkedsectioncloseRtstartR%R'(RRtreportRtsectNameRtmatch((s /usr/lib/python2.6/markupbase.pyR!�s "
cCs�|i}|||d!djo|id�nti||d�}|pdS|o+|id�}|i||d|!�n|id�S(Nis<!--s"unexpected call to parse_comment()i����i(RRt
_commentcloseR9R;thandle_commentR'(RRR<RR>R((s /usr/lib/python2.6/markupbase.pyR �s c
Cs�|i}t|�}|}x�||jo�||}|djog|||d!}|djodS|djo)|i||d�|id|�n|d|jodS|d|jodS|||d!djo.|i|d d
�}|d
jo|Sqn|i|d|�\}}|djodS|djo)|i||d�|id|�nt|d|�} | ||�}|d
jo|Sq|djog|d|jodS|i|d|�\}}|d
jo|S||djo|d}q�q|djo�|d}x-||jo||i�o|d}q7W||jo7||djo|S|i||�|id�q�dSq|i�o|d}q|i||�|id|�qWdS(Nt<ii����s<!is*unexpected char in internal subset (in %r)is<!--R<iRRtentitytnotations)unknown declaration %r in internal subsett_parse_doctype_t%t;t]Rs%unexpected char after internal subsets%unexpected char %r in internal subset(sattlistselementRBRC(RRRRR R"tgetattrtisspace(
RRtdeclstartposRR)RR+tsR.tmeth((s /usr/lib/python2.6/markupbase.pyR(�sr
cCs]|i||�\}}|djodS|i}d||jo|id|�dSdS(Ni����Ri(R"Rtfind(RRRJR.RR((s /usr/lib/python2.6/markupbase.pyt_parse_doctype_element�s
cCs@|i}|i||�\}}|||d!}|djodS|djo |dSx�|i||�\}}|djo|S|||d!}|djodS|djomd||jo|id|�d}ndSx'|||d!i�o|d}q�W||pdSn|i||�\}}|||d!}|pdS|djoKt||�}|o|i�}ndS|||d!}|pdSn|d joe||d jodS|i|d|�\}}|djo|S|||d!}|pdSn|djo |dSq]dS(
NiRi����Rit(t)s'"t#(RR"RMRIR&R'(RRRJRR.RR+R-((s /usr/lib/python2.6/markupbase.pyt_parse_doctype_attlists\
cCs�|i||�\}}|djo|S|i}x�|||d!}|pdS|djo |dS|djo+t||�}|pdS|i�}q6|i||�\}}|djo|Sq6dS(Niii����Rs'"(R"RR&R'(RRRJR.RRR+R-((s /usr/lib/python2.6/markupbase.pyt_parse_doctype_notation:s$
cCsC|i}|||d!djoM|d}xF|||d!}|pdS|i�o|d}q.Pq.n|}|i||�\}}|djo|Sx�|i||d!}|pdS|djo.t||�}|o|i�}q<dSq�|djo |dS|i||�\}}|djo|Sq�dS(NiREi����is'"R(RRIR"R&R'(RRRJRRR+R.R-((s /usr/lib/python2.6/markupbase.pyt_parse_doctype_entityQs8
cCs�|i}t|�}||jodSt||�}|oK|i�}|i�}|t|�|jodS|i�|i�fS|i||�|i d|||d!�dS(Ni����sexpected name token at %ri(Ni����(Ni����(
RRtNonet_declname_matchtgrouptstriptlowerR'RR(RRRJRR)R-RKR.((s /usr/lib/python2.6/markupbase.pyR"us
cCsdS(N((RR,((s /usr/lib/python2.6/markupbase.pyR%�s(t__name__t
__module__t__doc__RRR
RRR#R/R!R R(RNRRRSRTR"R%(((s /usr/lib/python2.6/markupbase.pyRs"
N C 9 $ ((
R\tretcompileR>RVR&R?R8R:R(((s /usr/lib/python2.6/markupbase.pyt<module>s