Ńň
mČKc           @   s}   d  Z  d d k Z e i d  i Z e i d  i Z e i d  Z e i d  Z e i d  Z [ d d
 d	     YZ	 d S(   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
   ParserBasec           B   sĄ   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d Z d   Z	 d d	  Z
 d d
  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   si   Parser base class which provides some common support methods used
    by the SGML/HTML and XHTML parsers.c         C   s$   |  i  t j o t d   n d  S(   Ns(   markupbase.ParserBase must be subclassed(   t	   __class__R    t   RuntimeError(   t   self(    (    s    /usr/lib/python2.6/markupbase.pyt   __init__   s    c         C   s   t  d   d  S(   Ns.   subclasses of ParserBase must override error()(   t   NotImplementedError(   R   t   message(    (    s    /usr/lib/python2.6/markupbase.pyt   error!   s    c         C   s   d |  _  d |  _ d  S(   Ni   i    (   t   linenot   offset(   R   (    (    s    /usr/lib/python2.6/markupbase.pyt   reset%   s    	c         C   s   |  i  |  i f S(   s&   Return current line number and offset.(   R   R	   (   R   (    (    s    /usr/lib/python2.6/markupbase.pyt   getpos)   s    c         C   s   | | j o | S|  i  } | i d | |  } | o: |  i | |  _ | i d | |  } | | d |  _ n |  i | | |  _ | S(   Ns   
i   (   t   rawdatat   countR   t   rindexR	   (   R   t   it   jR   t   nlinest   pos(    (    s    /usr/lib/python2.6/markupbase.pyt	   updatepos1   s    	t    c   
   
   C   s  |  i  } | d } | | | !d j p
 t d  | | | d !d j o	 | d S| | | d !d j o d St |  } | | | d !d	 j o |  i |  S| | d
 j o |  i |  S|  i | |  \ } } | d j  o | S| d j o d |  _ n x{| | j  om| | } | d j oE | | d | !} | d j o |  i |  n |  i |  | d S| d j o+ t	 | |  } | p d S| i
   } nÄ | d j o |  i | |  \ }	 } n | |  i j o | d } n} | d
 j oZ | d j o |  i | d |  } qk| d j o |  i d |  qk|  i d  n |  i d | |  | d j  o | SqWd S(   Ni   s   <!s$   unexpected call to parse_declarationi   t   >t   -R   i˙˙˙˙s   --t   [i    t   doctypes   "'t4   abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZt   attlistt   linktypet   linkt   elements&   unsupported '[' char in %s declarations"   unexpected '[' char in declarations!   unexpected %r char in declaration(   R   R   (   R   R   s   linkR   (   R   t   AssertionErrort   lent   parse_commentt   parse_marked_sectiont
   _scan_namet   _decl_othercharst   handle_declt   unknown_declt   _declstringlit_matcht   endt   _parse_doctype_subsetR   (
   R   R   R   R   t   nt   decltypet   ct   datat   mt   name(    (    s    /usr/lib/python2.6/markupbase.pyt   parse_declarationA   s\    	
	 
	
i   c         C   s  |  i  } | | | d !d j p
 t d  |  i | d |  \ } } | d j  o | S| d j o t i | | d  } nD | d j o t i | | d  } n |  i d | | d | ! | p d S| o+ | i d  } |  i | | d | ! n | i	 d  S(   Ni   s   <![s)   unexpected call to parse_marked_section()i    t   tempt   cdatat   ignoret   includet   rcdatat   ift   elset   endifs+   unknown status keyword %r in marked sectioni˙˙˙˙(   R0   R1   s   ignoreR3   R4   (   R5   R6   R7   (
   R   R   R"   t   _markedsectioncloset   searcht   _msmarkedsectioncloseR   t   startR%   R'   (   R   R   t   reportR   t   sectNameR   t   match(    (    s    /usr/lib/python2.6/markupbase.pyR!      s     	"c         C   s   |  i  } | | | d !d j o |  i d  n t i | | d  } | p d S| o+ | i d  } |  i | | d | ! n | i d  S(   Ni   s   <!--s"   unexpected call to parse_comment()i˙˙˙˙i    (   R   R   t   _commentcloseR9   R;   t   handle_commentR'   (   R   R   R<   R   R>   R   (    (    s    /usr/lib/python2.6/markupbase.pyR    Ľ   s    	c   
      C   ső  |  i  } t |  } | } xÓ| | j  oĹ| | } | d j og| | | d !} | d j o d S| d j o) |  i | | d  |  i d |  n | d | j o d S| d | j o d S| | | d !d j o. |  i | d	 d
 } | d
 j  o | Sq n |  i | d |  \ } } | d j o d S| d j o) |  i | | d  |  i d |  n t |  d |  }	 |	 | |  } | d
 j  o | Sq | d j og | d | j o d S|  i | d |  \ } } | d
 j  o | S| | d j o | d } qěq | d j o | d } x- | | j  o | | i   o | d } q7W| | j  o7 | | d j o | S|  i | |  |  i d  qěd Sq | i   o | d } q |  i | |  |  i d |  q Wd S(   Nt   <i   i˙˙˙˙s   <!i   s*   unexpected char in internal subset (in %r)i   s   <!--R<   i    R   R   t   entityt   notations)   unknown declaration %r in internal subsett   _parse_doctype_t   %t   ;t   ]R   s%   unexpected char after internal subsets%   unexpected char %r in internal subset(   s   attlists   elementRB   RC   (   R   R   R   R   R    R"   t   getattrt   isspace(
   R   R   t   declstartposR   R)   R   R+   t   sR.   t   meth(    (    s    /usr/lib/python2.6/markupbase.pyR(   ł   sr    	 
	
 c         C   s]   |  i  | |  \ } } | d j o d S|  i } d | | j o | i d |  d Sd S(   Ni˙˙˙˙R   i   (   R"   R   t   find(   R   R   RJ   R.   R   R   (    (    s    /usr/lib/python2.6/markupbase.pyt   _parse_doctype_elementö   s    	c         C   s@  |  i  } |  i | |  \ } } | | | d !} | d j o d S| d j o	 | d Sxß|  i | |  \ } } | d j  o | S| | | d !} | d j o d S| d j om d | | j o | i d |  d } n d Sx' | | | d !i   o | d } qé W| | p d Sn |  i | |  \ } } | | | d !} | p d S| d j oK t | |  } | o | i   } n d S| | | d !} | p d Sn | d	 j oe | | d	 j o d S|  i | d |  \ } } | d j  o | S| | | d !} | p d Sn | d j o	 | d Sq] d  S(
   Ni   R   i˙˙˙˙R   i    t   (t   )s   '"t   #(   R   R"   RM   RI   R&   R'   (   R   R   RJ   R   R.   R   R+   R-   (    (    s    /usr/lib/python2.6/markupbase.pyt   _parse_doctype_attlist  s\    		 			c         C   sŇ   |  i  | |  \ } } | d j  o | S|  i } x | | | d !} | p d S| d j o	 | d S| d j o+ t | |  } | p d S| i   } q6 |  i  | |  \ } } | d j  o | Sq6 d  S(   Ni    i   i˙˙˙˙R   s   '"(   R"   R   R&   R'   (   R   R   RJ   R.   R   R   R+   R-   (    (    s    /usr/lib/python2.6/markupbase.pyt   _parse_doctype_notation:  s$    		c         C   sC  |  i  } | | | d !d j oM | d } xF | | | d !} | p d S| i   o | d } q. Pq. n | } |  i | |  \ } } | d j  o | Sx |  i  | | d !} | p d S| d j o. t | |  } | o | i   } q<d SqĄ | d j o	 | d S|  i | |  \ } } | d j  o | SqĄ d  S(   Ni   RE   i˙˙˙˙i    s   '"R   (   R   RI   R"   R&   R'   (   R   R   RJ   R   R   R+   R.   R-   (    (    s    /usr/lib/python2.6/markupbase.pyt   _parse_doctype_entityQ  s8    	
	c         C   s¸   |  i  } t |  } | | j o d St | |  } | oK | i   } | i   } | t |  | j o d S| i   | i   f S|  i | |  |  i	 d | | | d ! d  S(   Ni˙˙˙˙s   expected name token at %ri   (   Ni˙˙˙˙(   Ni˙˙˙˙(
   R   R   t   Nonet   _declname_matcht   groupt   stript   lowerR'   R   R   (   R   R   RJ   R   R)   R-   RK   R.   (    (    s    /usr/lib/python2.6/markupbase.pyR"   u  s    		c         C   s   d  S(   N(    (   R   R,   (    (    s    /usr/lib/python2.6/markupbase.pyR%     s    (   t   __name__t
   __module__t   __doc__R   R   R
   R   R   R#   R/   R!   R    R(   RN   RR   RS   RT   R"   R%   (    (    (    s    /usr/lib/python2.6/markupbase.pyR       s"   						N	C		9		$	(    (
   R\   t   ret   compileR>   RV   R&   R?   R8   R:   R    (    (    (    s    /usr/lib/python2.6/markupbase.pyt   <module>   s   