³ò
™›\Kc           @   s<  d  Z  d d k Z d d k Z d d g Z e i d ƒ Z e i d ƒ Z e i d ƒ Z e i d ƒ Z e i d	 ƒ Z	 e i d
 ƒ Z
 e i d ƒ Z e i d ƒ Z e i d ƒ Z e i d ƒ Z e i d ƒ Z d e f d „  ƒ  YZ d e i f d „  ƒ  YZ d e f d „  ƒ  YZ e d „ Z e d j o e ƒ  n d S(   s;   A parser for SGML, using the derived class as a static DTD.iÿÿÿÿNt
   SGMLParsert   SGMLParseErrors   [&<]sN   &([a-zA-Z][a-zA-Z0-9]*|#[0-9]*)?|<([a-zA-Z][^<>]*|/([a-zA-Z][^<>]*)?|![^<>]*)?s%   &([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]s   &#([0-9]+)[^0-9]s
   <[>a-zA-Z]s   <[a-zA-Z][-.a-zA-Z0-9]*/s"   <([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/t   >s   [<>]s   [a-zA-Z][-_.a-zA-Z0-9]*se   \s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*(\'[^\']*\'|"[^"]*"|[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*))?c           B   s   e  Z d  Z RS(   s&   Exception raised for all parse errors.(   t   __name__t
   __module__t   __doc__(    (    (    s   /usr/lib/python2.5/sgmllib.pyR   '   s   c           B   ss  e  Z e i d  ƒ Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z h  d d <d d <d d <d d  <d! d" <Z d# „  Z d$ „  Z d% „  Z d& „  Z  d' „  Z! d( „  Z" d) „  Z# d* „  Z$ d+ „  Z% d, „  Z& RS(-   s+   &(?:([a-zA-Z][-.a-zA-Z0-9]*)|#([0-9]+))(;?)i    c         C   s   | |  _  |  i ƒ  d S(   s#   Initialize and reset this instance.N(   t   verboset   reset(   t   selfR   (    (    s   /usr/lib/python2.5/sgmllib.pyt   __init__=   s    	c         C   sJ   d |  _ d |  _ g  |  _ d |  _ d |  _ d |  _ t i i	 |  ƒ d S(   s0   Reset this instance. Loses all unprocessed data.t    s   ???i    N(
   t   Nonet   _SGMLParser__starttag_textt   rawdatat   stackt   lasttagt
   nomoretagst   literalt
   markupbaset
   ParserBaseR   (   R   (    (    s   /usr/lib/python2.5/sgmllib.pyR   B   s    						c         C   s   d |  _  |  _ d S(   sY   Enter literal mode (CDATA) till EOF.

        Intended for derived classes only.
        i   N(   R   R   (   R   (    (    s   /usr/lib/python2.5/sgmllib.pyt   setnomoretagsL   s    c         G   s   d |  _  d S(   sP   Enter literal mode (CDATA).

        Intended for derived classes only.
        i   N(   R   (   R   t   args(    (    s   /usr/lib/python2.5/sgmllib.pyt
   setliteralS   s    c         C   s!   |  i  | |  _  |  i d ƒ d S(   sã   Feed some data to the parser.

        Call this as often as you want, with as little or as much text
        as you want (may include '
').  (This just saves the text,
        all the processing is done by goahead().)
        i    N(   R   t   goahead(   R   t   data(    (    s   /usr/lib/python2.5/sgmllib.pyt   feedZ   s    c         C   s   |  i  d ƒ d S(   s   Handle the remaining data.i   N(   R   (   R   (    (    s   /usr/lib/python2.5/sgmllib.pyt   closee   s    c         C   s   t  | ƒ ‚ d  S(   N(   R   (   R   t   message(    (    s   /usr/lib/python2.5/sgmllib.pyt   errori   s    c   	      C   sy  |  i  } d } t | ƒ } x| | j  o
|  i o |  i | | | !ƒ | } Pn t i | | ƒ } | o | i ƒ  } n | } | | j  o |  i | | | !ƒ n | } | | j o Pn | | d j oÀt i | | ƒ oZ |  i	 o" |  i | | ƒ | d } q n |  i
 | ƒ } | d j  o Pn | } q n | i d | ƒ o7 |  i | ƒ } | d j  o Pn | } d |  _	 q n |  i	 o4 | | d j o |  i d ƒ | d } q Pq n | i d | ƒ o. |  i | ƒ } | d j  o Pn | } q n | i d | ƒ o2 |  i | ƒ } | d j  o Pn | | } q n | i d | ƒ o. |  i | ƒ } | d j  o Pn | } q q»n+| | d j o|  i	 o" |  i | | ƒ | d } q n t i | | ƒ } | oU | i d ƒ } |  i | ƒ | i d ƒ } | | d d	 j o | d } q q n t i | | ƒ } | oU | i d ƒ } |  i | ƒ | i d ƒ } | | d d	 j o | d } q q q»n |  i d
 ƒ t i | | ƒ } | p" |  i | | ƒ | d } q n | i d ƒ } | | j o Pn |  i | | | !ƒ | } q W| o+ | | j  o |  i | | | !ƒ | } n | | |  _  d  S(   Ni    t   <i   s   </s   <!--s   <?s   <!t   &t   ;s   neither < nor & ??(   R   t   lenR   t   handle_datat   interestingt   searcht   startt   starttagopent   matchR   t   parse_starttagt
   startswitht   parse_endtagt   parse_commentt   parse_pit   parse_declarationt   charreft   groupt   handle_charreft   endt	   entityreft   handle_entityrefR   t
   incomplete(	   R   R0   R   t   it   nR&   t   jt   kt   name(    (    s   /usr/lib/python2.5/sgmllib.pyR   o   sÀ    	 
  

  	
  
 

  

t   =c         C   s•   |  i  } | | | d !d j o |  i d ƒ n t i | | d ƒ } | p d Sn | i d ƒ } |  i | | d | !ƒ | i d ƒ } | | S(   Ni   s   <?s   unexpected call to parse_pi()iÿÿÿÿi    (   R   R   t   picloseR#   R$   t	   handle_piR0   (   R   R4   R   R&   R6   (    (    s   /usr/lib/python2.5/sgmllib.pyR+   Ù   s    	c         C   s   |  i  S(   N(   R   (   R   (    (    s   /usr/lib/python2.5/sgmllib.pyt   get_starttag_textå   s    c         C   sÅ  d  |  _ | } |  i } t i | | ƒ o– t i | | ƒ } | p d Sn | i d d ƒ \ } } d | |  _ | i ƒ  } | i d ƒ } |  i	 | | ƒ | | | i d ƒ d !|  _ | Sn t
 i | | d ƒ } | p d Sn | i d ƒ } g  }	 | | | d !d j o | } |  i } n^ t i | | d ƒ } | p |  i d ƒ n | i d ƒ } | | d | !i ƒ  } | |  _ xü | | j  oî t i | | ƒ } | p Pn | i d d d ƒ \ }
 } } | p
 |
 } nv | d  d	 j o | d j n p& | d  d
 j o | d j n o | d d !} n |  i i |  i | ƒ } |	 i |
 i ƒ  | f ƒ | i d ƒ } q†W| | d j o | d } n | | | !|  _ |  i | |	 ƒ | S(   Niÿÿÿÿi   i   s   <%s/i    s   <>s!   unexpected call to parse_starttagi   t   't   "R   (   R   R   R   t   shorttagopenR&   t   shorttagR.   t   lowerR0   t   finish_shorttagt
   endbracketR#   R$   R   t   tagfindR   t   attrfindt   entity_or_charreft   subt   _convert_reft   appendt   finish_starttag(   R   R4   t	   start_posR   R&   t   tagR   R7   R6   t   attrst   attrnamet   restt	   attrvalue(    (    s   /usr/lib/python2.5/sgmllib.pyR'   é   s`    			  
&&	c         C   s’   | i  d ƒ o/ |  i | i  d ƒ ƒ p d | i ƒ  d SnP | i  d ƒ o. |  i | i  d ƒ ƒ p d | i  d ƒ Sn d | i  d ƒ Sd  S(   Ni   s   &#%s%si   i   s   &%s;s   &%s(   R.   t   convert_charreft   groupst   convert_entityref(   R   R&   (    (    s   /usr/lib/python2.5/sgmllib.pyRH   '  s    c         C   sŠ   |  i  } t i | | d ƒ } | p d Sn | i d ƒ } | | d | !i ƒ  i ƒ  } | | d j o | d } n |  i | ƒ | S(   Ni   iÿÿÿÿi    i   R   (   R   RC   R#   R$   t   stripRA   t   finish_endtag(   R   R4   R   R&   R6   RL   (    (    s   /usr/lib/python2.5/sgmllib.pyR)   2  s    	c         C   s.   |  i  | g  ƒ |  i | ƒ |  i | ƒ d  S(   N(   RJ   R!   RU   (   R   RL   R   (    (    s   /usr/lib/python2.5/sgmllib.pyRB   ?  s    c         C   s°   y t  |  d | ƒ } Wnk t j
 o_ y t  |  d | ƒ } Wn' t j
 o |  i | | ƒ d Sq¬ X|  i | | | ƒ d Sn) X|  i i | ƒ |  i | | | ƒ d Sd  S(   Nt   start_t   do_iÿÿÿÿi    i   (   t   getattrt   AttributeErrort   unknown_starttagt   handle_starttagR   RI   (   R   RL   RM   t   method(    (    s   /usr/lib/python2.5/sgmllib.pyRJ   F  s    		c         C   sw  | p9 t  |  i ƒ d } | d j  o |  i | ƒ d  Sqã n¤ | |  i j oO y t |  d | ƒ } Wn  t j
 o |  i | ƒ n X|  i | ƒ d  Sn t  |  i ƒ } x2 t | ƒ D]$ } |  i | | j o
 | } q» q» Wx t  |  i ƒ | j ov |  i d } y t |  d | ƒ } Wn t j
 o d  } n X| o |  i | | ƒ n |  i | ƒ |  i d =qæ Wd  S(   Ni   i    t   end_iÿÿÿÿ(	   R    R   t   unknown_endtagRX   RY   t   report_unbalancedt   rangeR   t   handle_endtag(   R   RL   t   foundR\   R4   (    (    s   /usr/lib/python2.5/sgmllib.pyRU   X  s8       c         C   s   | | ƒ d  S(   N(    (   R   RL   R\   RM   (    (    s   /usr/lib/python2.5/sgmllib.pyR[   w  s    c         C   s   | ƒ  d  S(   N(    (   R   RL   R\   (    (    s   /usr/lib/python2.5/sgmllib.pyRa   {  s    c         C   s+   |  i  o d | d GHd G|  i GHn d  S(   Ns   *** Unbalanced </R   s
   *** Stack:(   R   R   (   R   RL   (    (    s   /usr/lib/python2.5/sgmllib.pyR_     s    
c         C   s]   y t  | ƒ } Wn t j
 o d Sn Xd | j o
 d j n p d Sn |  i | ƒ S(   s/   Convert character reference, may be overridden.Ni    iÿ   (   t   intt
   ValueErrort   convert_codepoint(   R   R8   R5   (    (    s   /usr/lib/python2.5/sgmllib.pyRQ   „  s    	c         C   s
   t  | ƒ S(   N(   t   chr(   R   t	   codepoint(    (    s   /usr/lib/python2.5/sgmllib.pyRe   Ž  s    c         C   s>   |  i  | ƒ } | d j o |  i | ƒ n |  i | ƒ d S(   s0   Handle character reference, no need to override.N(   RQ   R   t   unknown_charrefR!   (   R   R8   t   replacement(    (    s   /usr/lib/python2.5/sgmllib.pyR/   ‘  s    R   t   ltR   t   gtR   t   ampR>   t   quots   't   aposc         C   s*   |  i  } | | j o | | Sn d Sd S(   sµ   Convert entity references.

        As an alternative to overriding this method; one can tailor the
        results by setting up the self.entitydefs mapping appropriately.
        N(   t
   entitydefs(   R   R8   t   table(    (    s   /usr/lib/python2.5/sgmllib.pyRS     s    	c         C   sG   |  i  | ƒ } | d j o |  i | ƒ n |  i |  i  | ƒ ƒ d S(   s.   Handle entity references, no need to override.N(   RS   R   t   unknown_entityrefR!   (   R   R8   Ri   (    (    s   /usr/lib/python2.5/sgmllib.pyR2   ©  s    c         C   s   d  S(   N(    (   R   R   (    (    s   /usr/lib/python2.5/sgmllib.pyR!   ²  s    c         C   s   d  S(   N(    (   R   R   (    (    s   /usr/lib/python2.5/sgmllib.pyt   handle_comment¶  s    c         C   s   d  S(   N(    (   R   t   decl(    (    s   /usr/lib/python2.5/sgmllib.pyt   handle_declº  s    c         C   s   d  S(   N(    (   R   R   (    (    s   /usr/lib/python2.5/sgmllib.pyR;   ¾  s    c         C   s   d  S(   N(    (   R   RL   RM   (    (    s   /usr/lib/python2.5/sgmllib.pyRZ   Â  s    c         C   s   d  S(   N(    (   R   RL   (    (    s   /usr/lib/python2.5/sgmllib.pyR^   Ã  s    c         C   s   d  S(   N(    (   R   t   ref(    (    s   /usr/lib/python2.5/sgmllib.pyRh   Ä  s    c         C   s   d  S(   N(    (   R   Ru   (    (    s   /usr/lib/python2.5/sgmllib.pyRq   Å  s    ('   R   R   t   ret   compileRF   R	   R   R   R   R   R   R   R   t   _decl_othercharsR+   R<   R'   RH   R)   RB   RJ   RU   R[   Ra   R_   RQ   Re   R/   Ro   RS   R2   R!   Rr   Rt   R;   RZ   R^   Rh   Rq   (    (    (    s   /usr/lib/python2.5/sgmllib.pyR    7   sF   	
						g			>									
		
3										t   TestSGMLParserc           B   se   e  Z d  d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z RS(   i    c         C   s   d |  _  t i |  | ƒ d  S(   NR
   (   t   testdataR    R	   (   R   R   (    (    s   /usr/lib/python2.5/sgmllib.pyR	   Ê  s    	c         C   s>   |  i  | |  _  t t |  i  ƒ ƒ d j o |  i ƒ  n d  S(   NiF   (   Rz   R    t   reprt   flush(   R   R   (    (    s   /usr/lib/python2.5/sgmllib.pyR!   Î  s    c         C   s0   |  i  } | o d |  _  d Gt | ƒ GHn d  S(   NR
   s   data:(   Rz   R{   (   R   R   (    (    s   /usr/lib/python2.5/sgmllib.pyR|   Ó  s    		c         C   sP   |  i  ƒ  t | ƒ } t | ƒ d j o | d  d | d } n d G| GHd  S(   NiD   i    s   ...iàÿÿÿs   comment:(   R|   R{   R    (   R   R   t   r(    (    s   /usr/lib/python2.5/sgmllib.pyRr   Ù  s
    
c         C   s^   |  i  ƒ  | p d | d GHn9 d | Gx( | D]  \ } } | d d | d Gq1 Wd GHd  S(   Ns   start tag: <R   R9   R>   (   R|   (   R   RL   RM   R8   t   value(    (    s   /usr/lib/python2.5/sgmllib.pyRZ   à  s    
 c         C   s   |  i  ƒ  d | d GHd  S(   Ns   end tag: </R   (   R|   (   R   RL   (    (    s   /usr/lib/python2.5/sgmllib.pyR^   ê  s    
c         C   s   |  i  ƒ  d | d GHd  S(   Ns   *** unknown entity ref: &R   (   R|   (   R   Ru   (    (    s   /usr/lib/python2.5/sgmllib.pyRq   î  s    
c         C   s   |  i  ƒ  d | d GHd  S(   Ns   *** unknown char ref: &#R   (   R|   (   R   Ru   (    (    s   /usr/lib/python2.5/sgmllib.pyRh   ò  s    
c         C   s   |  i  ƒ  d | d GHd  S(   Ns   *** unknown decl: [t   ](   R|   (   R   R   (    (    s   /usr/lib/python2.5/sgmllib.pyt   unknown_declö  s    
c         C   s   t  i |  ƒ |  i ƒ  d  S(   N(   R    R   R|   (   R   (    (    s   /usr/lib/python2.5/sgmllib.pyR   ú  s    (   R   R   R	   R!   R|   Rr   RZ   R^   Rq   Rh   R€   R   (    (    (    s   /usr/lib/python2.5/sgmllib.pyRy   È  s   				
				c   	   	   C   s5  d d  k  } |  d  j o | i d }  n |  o% |  d d j o |  d }  t } n t } |  o |  d } n d } | d j o | i } nF y t | d ƒ } Wn/ t j
 o# } | Gd G| GH| i d ƒ n X| i	 ƒ  } | | i j	 o | i
 ƒ  n | ƒ  } x | D] } | i | ƒ qW| i
 ƒ  d  S(	   Niÿÿÿÿi   i    s   -ss	   test.htmlt   -R}   t   :(   t   sysR   t   argvR    Ry   t   stdint   opent   IOErrort   exitt   readR   R   (	   R   Rƒ   t   klasst   filet   ft   msgR   t   xt   c(    (    s   /usr/lib/python2.5/sgmllib.pyt   testÿ  s2    

	 t   __main__(   R   R   Rv   t   __all__Rw   R"   R3   R1   R-   R%   R?   R@   R:   RC   RD   RE   t   RuntimeErrorR   R   R    Ry   R   R   R   (    (    (    s   /usr/lib/python2.5/sgmllib.pys   <module>   s,   	ÿ ’7$