³ò
™›\Kc           @   sˆ   d  Z  d d k Z d d k l Z d d g Z d e i f d „  ƒ  YZ d e i f d „  ƒ  YZ e	 d „ Z
 e d	 j o e
 ƒ  n d S(
   sv   HTML 2.0 parser.

See the HTML 2.0 specification:
http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
iÿÿÿÿN(   t   AS_ISt
   HTMLParsert   HTMLParseErrorc           B   s   e  Z d  Z RS(   s3   Error raised when an HTML document can't be parsed.(   t   __name__t
   __module__t   __doc__(    (    (    s   /usr/lib/python2.5/htmllib.pyR      s   c           B   s3  e  Z d  Z d d k l 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 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/ „  Z0 d0 „  Z1 d1 „  Z2 d2 „  Z3 d3 „  Z4 d4 „  Z5 d5 „  Z6 d6 „  Z7 d7 „  Z8 d8 „  Z9 d9 „  Z: d: „  Z; d; „  Z< d< „  Z= d= „  Z> d d> „ Z? d? „  Z@ d@ „  ZA dA „  ZB dB „  ZC dC „  ZD dD „  ZE dE „  ZF dF „  ZG dG „  ZH dH „  ZI dI „  ZJ dJ „  ZK dK „  ZL dL „  ZM dM „  ZN dN „  ZO dO „  ZP dP „  ZQ dQ „  ZR dR „  ZS dS „  ZT dT „  ZU dU „  ZV dV „  ZW dW „  ZX dX „  ZY dY „  ZZ dZ „  Z[ RS([   sÌ   This is the basic HTML parser class.

    It supports all entity names required by the XHTML 1.0 Recommendation.
    It also defines handlers for all HTML 2.0 and many HTML 3.0 and 3.2
    elements.

    iÿÿÿÿ(   t
   entitydefsi    c         C   s    t  i i |  | ƒ | |  _ d S(   s•   Creates an instance of the HTMLParser class.

        The formatter parameter is the formatter instance associated with
        the parser.

        N(   t   sgmllibt
   SGMLParsert   __init__t	   formatter(   t   selfR
   t   verbose(    (    s   /usr/lib/python2.5/htmllib.pyR	      s    c         C   s   t  | ƒ ‚ d  S(   N(   R   (   R   t   message(    (    s   /usr/lib/python2.5/htmllib.pyt   error'   s    c         C   s\   t  i i |  ƒ d  |  _ d |  _ d  |  _ d  |  _ d  |  _ g  |  _	 d |  _
 g  |  _ d  S(   Ni    (   R   R   t   resett   Nonet   savedatat   isindext   titlet   baset   anchort
   anchorlistt   nofillt
   list_stack(   R   (    (    s   /usr/lib/python2.5/htmllib.pyR   *   s    							c         C   sV   |  i  d  j	 o |  i  | |  _  n/ |  i o |  i i | ƒ n |  i i | ƒ d  S(   N(   R   R   R   R
   t   add_literal_datat   add_flowing_data(   R   t   data(    (    s   /usr/lib/python2.5/htmllib.pyt   handle_data:   s
    
c         C   s   d |  _  d S(   sê   Begins saving character data in a buffer instead of sending it
        to the formatter object.

        Retrieve the stored data via the save_end() method.  Use of the
        save_bgn() / save_end() pair may not be nested.

        t    N(   R   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   save_bgnE   s    c         C   s9   |  i  } d |  _  |  i p d i | i ƒ  ƒ } n | S(   sH  Ends buffering character data and returns all data saved since
        the preceding call to the save_bgn() method.

        If the nofill flag is false, whitespace is collapsed to single
        spaces.  A call to this method without a preceding call to the
        save_bgn() method will raise a TypeError exception.

        t    N(   R   R   R   t   joint   split(   R   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   save_endO   s
    			
c         C   s+   | |  _  |  i  o |  i i | ƒ n d S(   s}  This method is called at the start of an anchor region.

        The arguments correspond to the attributes of the <A> tag with
        the same names.  The default implementation maintains a list of
        hyperlinks (defined by the HREF attribute for <A> tags) within
        the document.  The list of hyperlinks is available as the data
        attribute anchorlist.

        N(   R   R   t   append(   R   t   hreft   namet   type(    (    s   /usr/lib/python2.5/htmllib.pyt
   anchor_bgn`   s    
	
c         C   s5   |  i  o' |  i d t |  i ƒ ƒ d |  _  n d S(   sØ   This method is called at the end of an anchor region.

        The default implementation adds a textual footnote marker using an
        index into the list of hyperlinks created by the anchor_bgn()method.

        s   [%d]N(   R   R   t   lenR   R   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt
   anchor_endn   s    
c         G   s   |  i  | ƒ d S(   s–   This method is called to handle images.

        The default implementation simply passes the alt value to the
        handle_data() method.

        N(   R   (   R   t   srct   altt   args(    (    s   /usr/lib/python2.5/htmllib.pyt   handle_image{   s    c         C   s   d  S(   N(    (   R   t   attrs(    (    s   /usr/lib/python2.5/htmllib.pyt
   start_html†   s    c         C   s   d  S(   N(    (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_html‡   s    c         C   s   d  S(   N(    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt
   start_head‰   s    c         C   s   d  S(   N(    (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_headŠ   s    c         C   s   d  S(   N(    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt
   start_bodyŒ   s    c         C   s   d  S(   N(    (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_body   s    c         C   s   |  i  ƒ  d  S(   N(   R   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_title‘   s    c         C   s   |  i  ƒ  |  _ d  S(   N(   R"   R   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt	   end_title”   s    c         C   s5   x. | D]& \ } } | d j o | |  _  q q Wd  S(   NR$   (   R   (   R   R.   t   at   v(    (    s   /usr/lib/python2.5/htmllib.pyt   do_base—   s     c         C   s   d |  _  d  S(   Ni   (   R   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt
   do_isindexœ   s    c         C   s   d  S(   N(    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_linkŸ   s    c         C   s   d  S(   N(    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_meta¢   s    c         C   s   d  S(   N(    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt	   do_nextid¥   s    c         C   s$   |  i  i d ƒ |  i  i d ƒ d  S(   Ni   t   h1i    (   R>   i    i   i    (   R
   t   end_paragrapht	   push_font(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_h1¬   s    c         C   s!   |  i  i d ƒ |  i  i ƒ  d  S(   Ni   (   R
   R?   t   pop_font(   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_h1°   s    c         C   s$   |  i  i d ƒ |  i  i d ƒ d  S(   Ni   t   h2i    (   RD   i    i   i    (   R
   R?   R@   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_h2´   s    c         C   s!   |  i  i d ƒ |  i  i ƒ  d  S(   Ni   (   R
   R?   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_h2¸   s    c         C   s$   |  i  i d ƒ |  i  i d ƒ d  S(   Ni   t   h3i    (   RG   i    i   i    (   R
   R?   R@   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_h3¼   s    c         C   s!   |  i  i d ƒ |  i  i ƒ  d  S(   Ni   (   R
   R?   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_h3À   s    c         C   s$   |  i  i d ƒ |  i  i d ƒ d  S(   Ni   t   h4i    (   RJ   i    i   i    (   R
   R?   R@   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_h4Ä   s    c         C   s!   |  i  i d ƒ |  i  i ƒ  d  S(   Ni   (   R
   R?   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_h4È   s    c         C   s$   |  i  i d ƒ |  i  i d ƒ d  S(   Ni   t   h5i    (   RM   i    i   i    (   R
   R?   R@   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_h5Ì   s    c         C   s!   |  i  i d ƒ |  i  i ƒ  d  S(   Ni   (   R
   R?   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_h5Ð   s    c         C   s$   |  i  i d ƒ |  i  i d ƒ d  S(   Ni   t   h6i    (   RP   i    i   i    (   R
   R?   R@   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_h6Ô   s    c         C   s!   |  i  i d ƒ |  i  i ƒ  d  S(   Ni   (   R
   R?   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_h6Ø   s    c         C   s   |  i  i d ƒ d  S(   Ni   (   R
   R?   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_pÞ   s    c         C   s@   |  i  i d ƒ |  i  i t t t d f ƒ |  i d |  _ d  S(   Ni   (   R
   R?   R@   R    R   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt	   start_preá   s    c         C   s:   |  i  i d ƒ |  i  i ƒ  t d |  i d ƒ |  _ d  S(   Ni   i    (   R
   R?   RB   t   maxR   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_preæ   s    c         C   s   |  i  | ƒ |  i d ƒ d  S(   Nt   xmp(   RT   t
   setliteral(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt	   start_xmpë   s    c         C   s   |  i  ƒ  d  S(   N(   RV   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_xmpï   s    c         C   s   |  i  | ƒ |  i d ƒ d  S(   Nt   listing(   RT   RX   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_listingò   s    c         C   s   |  i  ƒ  d  S(   N(   RV   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_listingö   s    c         C   s0   |  i  i d ƒ |  i  i t d t t f ƒ d  S(   Ni    i   (   R
   R?   R@   R    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_addressù   s    c         C   s!   |  i  i d ƒ |  i  i ƒ  d  S(   Ni    (   R
   R?   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_addressý   s    c         C   s$   |  i  i d ƒ |  i  i d ƒ d  S(   Ni   t
   blockquote(   R
   R?   t   push_margin(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_blockquote  s    c         C   s!   |  i  i d ƒ |  i  i ƒ  d  S(   Ni   (   R
   R?   t
   pop_margin(   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_blockquote  s    c         C   sA   |  i  i |  i ƒ |  i  i d ƒ |  i i d d d g ƒ d  S(   Nt   ult   *i    (   R
   R?   R   Ra   R#   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_ul  s    c         C   s=   |  i  o |  i  d =n |  i i |  i  ƒ |  i i ƒ  d  S(   Niÿÿÿÿ(   R   R
   R?   Rc   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_ul  s    
 c         C   sm   |  i  i d ƒ |  i o0 |  i d \ } } } } | d | d <} n d \ } } |  i  i | | ƒ d  S(   Ni    iÿÿÿÿi   i   Rf   (   Rf   i    (   R
   R?   R   t   add_label_data(   R   R.   t   dummyt   labelt   countert   top(    (    s   /usr/lib/python2.5/htmllib.pyt   do_li  s    
c         C   s–   |  i  i |  i ƒ |  i  i d ƒ d } xL | D]D \ } } | d j o+ t | ƒ d j o | d } n | } q1 q1 W|  i i d | d g ƒ d  S(   Nt   ols   1.R&   i   t   .i    (   R
   R?   R   Ra   R(   R#   (   R   R.   Rk   R7   R8   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_ol  s      c         C   s=   |  i  o |  i  d =n |  i i |  i  ƒ |  i i ƒ  d  S(   Niÿÿÿÿ(   R   R
   R?   Rc   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_ol(  s    
 c         C   s   |  i  | ƒ d  S(   N(   Rg   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt
   start_menu-  s    c         C   s   |  i  ƒ  d  S(   N(   Rh   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_menu0  s    c         C   s   |  i  | ƒ d  S(   N(   Rg   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt	   start_dir3  s    c         C   s   |  i  ƒ  d  S(   N(   Rh   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_dir6  s    c         C   s-   |  i  i d ƒ |  i i d d d g ƒ d  S(   Ni   t   dlR   i    (   R
   R?   R   R#   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_dl9  s    c         C   s)   |  i  d ƒ |  i o |  i d =n d  S(   Ni   iÿÿÿÿ(   t   ddpopR   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_dl=  s    
 c         C   s   |  i  ƒ  d  S(   N(   Ry   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_dtA  s    c         C   s7   |  i  ƒ  |  i i d ƒ |  i i d d d g ƒ d  S(   Nt   ddR   i    (   Ry   R
   Ra   R   R#   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_ddD  s    
c         C   sU   |  i  i | ƒ |  i o7 |  i d d d j o |  i d =|  i  i ƒ  qQ n d  S(   Niÿÿÿÿi    R|   (   R
   R?   R   Rc   (   R   t   bl(    (    s   /usr/lib/python2.5/htmllib.pyRy   I  s
    

c         C   s   |  i  | ƒ d  S(   N(   t   start_i(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt
   start_citeT  s    c         C   s   |  i  ƒ  d  S(   N(   t   end_i(   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_citeU  s    c         C   s   |  i  | ƒ d  S(   N(   t   start_tt(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt
   start_codeW  s    c         C   s   |  i  ƒ  d  S(   N(   t   end_tt(   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_codeX  s    c         C   s   |  i  | ƒ d  S(   N(   R   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_emZ  s    c         C   s   |  i  ƒ  d  S(   N(   R   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_em[  s    c         C   s   |  i  | ƒ d  S(   N(   Rƒ   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt	   start_kbd]  s    c         C   s   |  i  ƒ  d  S(   N(   R…   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_kbd^  s    c         C   s   |  i  | ƒ d  S(   N(   Rƒ   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt
   start_samp`  s    c         C   s   |  i  ƒ  d  S(   N(   R…   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_sampa  s    c         C   s   |  i  | ƒ d  S(   N(   t   start_b(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   start_strongc  s    c         C   s   |  i  ƒ  d  S(   N(   t   end_b(   R   (    (    s   /usr/lib/python2.5/htmllib.pyt
   end_strongd  s    c         C   s   |  i  | ƒ d  S(   N(   R   (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt	   start_varf  s    c         C   s   |  i  ƒ  d  S(   N(   R   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_varg  s    c         C   s    |  i  i t d t t f ƒ d  S(   Ni   (   R
   R@   R    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyR   k  s    c         C   s   |  i  i ƒ  d  S(   N(   R
   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyR   m  s    c         C   s    |  i  i t t d t f ƒ d  S(   Ni   (   R
   R@   R    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyR   p  s    c         C   s   |  i  i ƒ  d  S(   N(   R
   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyR   r  s    c         C   s    |  i  i t t t d f ƒ d  S(   Ni   (   R
   R@   R    (   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyRƒ   u  s    c         C   s   |  i  i ƒ  d  S(   N(   R
   RB   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyR…   w  s    c         C   s—   d } d } d } xk | D]c \ } } | i  ƒ  } | d j o
 | } n | d j o
 | } n | d j o | i ƒ  } q q W|  i | | | ƒ d  S(   NR   R$   R%   R&   (   t   stript   lowerR'   (   R   R.   R$   R%   R&   t   attrnamet   value(    (    s   /usr/lib/python2.5/htmllib.pyt   start_az  s     

c         C   s   |  i  ƒ  d  S(   N(   R)   (   R   (    (    s   /usr/lib/python2.5/htmllib.pyt   end_aˆ  s    c         C   s   |  i  i ƒ  d  S(   N(   R
   t   add_line_break(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_br  s    c         C   s   |  i  i ƒ  d  S(   N(   R
   t   add_hor_rule(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_hr’  s    c   
   	   C   s%  d } d } d } d } d } d } xÞ | D]Ö \ } }	 | d j o
 |	 } n | d j o
 |	 } n | d j o
 |	 } n | d j o
 |	 } n | d j o* y t  |	 ƒ } WqÊ t j
 o qÊ Xn | d	 j o* y t  |	 ƒ } Wqt j
 o qXq+ q+ W|  i | | | | | | ƒ d  S(
   NR   s   (image)i    t   alignR+   t   ismapR*   t   widtht   height(   t   intt
   ValueErrorR-   (
   R   R.   R   R+   Rž   R*   RŸ   R    R•   R–   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_img—  s6     



  	  c         C   s   |  i  | ƒ |  i ƒ  d  S(   N(   RT   t   setnomoretags(   R   R.   (    (    s   /usr/lib/python2.5/htmllib.pyt   do_plaintext±  s    c         C   s   d  S(   N(    (   R   t   tagR.   (    (    s   /usr/lib/python2.5/htmllib.pyt   unknown_starttag·  s    c         C   s   d  S(   N(    (   R   R¦   (    (    s   /usr/lib/python2.5/htmllib.pyt   unknown_endtagº  s    (\   R   R   R   t   htmlentitydefsR   R	   R   R   R   R   R"   R'   R)   R-   R/   R0   R1   R2   R3   R4   R5   R6   R9   R:   R;   R<   R=   RA   RC   RE   RF   RH   RI   RK   RL   RN   RO   RQ   RR   RS   RT   RV   RY   RZ   R\   R]   R^   R_   Rb   Rd   Rg   Rh   Rn   Rq   Rr   Rs   Rt   Ru   Rv   Rx   Rz   R{   R}   Ry   R€   R‚   R„   R†   R‡   Rˆ   R‰   RŠ   R‹   RŒ   RŽ   R   R‘   R’   R   R   R   R   Rƒ   R…   R—   R˜   Rš   Rœ   R£   R¥   R§   R¨   (    (    (    s   /usr/lib/python2.5/htmllib.pyR      s²   
				
																																													
																																				c   	   	   C   sP  d d  k  } d d  k } |  p | i d }  n |  o |  d d j } | o |  d =n |  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 | o | i	 ƒ  } n | i
 | i ƒ  ƒ } t | ƒ } | i | ƒ | i ƒ  d  S(	   Niÿÿÿÿi   i    s   -ss	   test.htmlt   -t   rt   :(   t   sysR
   t   argvt   stdint   opent   IOErrort   exitt   readt   closet   NullFormattert   AbstractFormattert
   DumbWriterR   t   feed(	   R,   R­   R
   t   silentt   filet   ft   msgR   t   p(    (    s   /usr/lib/python2.5/htmllib.pyt   test¾  s2    t   __main__(   R   R   R
   R    t   __all__t   SGMLParseErrorR   R   R   R   R¾   R   (    (    (    s   /usr/lib/python2.5/htmllib.pys   <module>   s   ÿ ­'