Ńň
mČKc           @   sŤ   d  Z  d d k l Z e d d d [ 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˙˙˙˙(   t   warnpy3ks1   the htmllib module has been removed in Python 3.0t
   stackleveli   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.6/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.6/htmllib.pyR   "   s    c         C   s   t  |   d  S(   N(   R   (   R   t   message(    (    s   /usr/lib/python2.6/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.6/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.6/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.6/htmllib.pyt   save_bgnJ   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.6/htmllib.pyt   save_endT   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.6/htmllib.pyt
   anchor_bgne   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.6/htmllib.pyt
   anchor_ends   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.6/htmllib.pyt   handle_image   s    c         C   s   d  S(   N(    (   R   t   attrs(    (    s   /usr/lib/python2.6/htmllib.pyt
   start_html   s    c         C   s   d  S(   N(    (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_html   s    c         C   s   d  S(   N(    (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt
   start_head   s    c         C   s   d  S(   N(    (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_head   s    c         C   s   d  S(   N(    (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt
   start_body   s    c         C   s   d  S(   N(    (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_body   s    c         C   s   |  i    d  S(   N(   R    (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_title   s    c         C   s   |  i    |  _ d  S(   N(   R$   R   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt	   end_title   s    c         C   s5   x. | D]& \ } } | d j o | |  _  q q Wd  S(   NR&   (   R   (   R   R0   t   at   v(    (    s   /usr/lib/python2.6/htmllib.pyt   do_base   s     c         C   s   d |  _  d  S(   Ni   (   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt
   do_isindexĄ   s    c         C   s   d  S(   N(    (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   do_link¤   s    c         C   s   d  S(   N(    (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   do_meta§   s    c         C   s   d  S(   N(    (   R   R0   (    (    s   /usr/lib/python2.6/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   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_h1ą   s    c         C   s!   |  i  i d  |  i  i   d  S(   Ni   (   R   RA   t   pop_font(   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_h1ľ   s    c         C   s$   |  i  i d  |  i  i d  d  S(   Ni   t   h2i    (   RF   i    i   i    (   R   RA   RB   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_h2š   s    c         C   s!   |  i  i d  |  i  i   d  S(   Ni   (   R   RA   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_h2˝   s    c         C   s$   |  i  i d  |  i  i d  d  S(   Ni   t   h3i    (   RI   i    i   i    (   R   RA   RB   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_h3Á   s    c         C   s!   |  i  i d  |  i  i   d  S(   Ni   (   R   RA   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_h3Ĺ   s    c         C   s$   |  i  i d  |  i  i d  d  S(   Ni   t   h4i    (   RL   i    i   i    (   R   RA   RB   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_h4É   s    c         C   s!   |  i  i d  |  i  i   d  S(   Ni   (   R   RA   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_h4Í   s    c         C   s$   |  i  i d  |  i  i d  d  S(   Ni   t   h5i    (   RO   i    i   i    (   R   RA   RB   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_h5Ń   s    c         C   s!   |  i  i d  |  i  i   d  S(   Ni   (   R   RA   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_h5Ő   s    c         C   s$   |  i  i d  |  i  i d  d  S(   Ni   t   h6i    (   RR   i    i   i    (   R   RA   RB   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_h6Ů   s    c         C   s!   |  i  i d  |  i  i   d  S(   Ni   (   R   RA   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_h6Ý   s    c         C   s   |  i  i d  d  S(   Ni   (   R   RA   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   do_pă   s    c         C   s@   |  i  i d  |  i  i t t t d f  |  i d |  _ d  S(   Ni   (   R   RA   RB   R   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt	   start_preć   s    c         C   s:   |  i  i d  |  i  i   t d |  i d  |  _ d  S(   Ni   i    (   R   RA   RD   t   maxR   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_preë   s    c         C   s   |  i  |  |  i d  d  S(   Nt   xmp(   RV   t
   setliteral(   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt	   start_xmpđ   s    c         C   s   |  i    d  S(   N(   RX   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_xmpô   s    c         C   s   |  i  |  |  i d  d  S(   Nt   listing(   RV   RZ   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_listing÷   s    c         C   s   |  i    d  S(   N(   RX   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_listingű   s    c         C   s0   |  i  i d  |  i  i t d t t f  d  S(   Ni    i   (   R   RA   RB   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_addressţ   s    c         C   s!   |  i  i d  |  i  i   d  S(   Ni    (   R   RA   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_address  s    c         C   s$   |  i  i d  |  i  i d  d  S(   Ni   t
   blockquote(   R   RA   t   push_margin(   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_blockquote  s    c         C   s!   |  i  i d  |  i  i   d  S(   Ni   (   R   RA   t
   pop_margin(   R   (    (    s   /usr/lib/python2.6/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   RA   R   Rc   R%   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_ul  s    c         C   s=   |  i  o |  i  d =n |  i i |  i   |  i i   d  S(   Ni˙˙˙˙(   R   R   RA   Re   (   R   (    (    s   /usr/lib/python2.6/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   Rh   (   Rh   i    (   R   RA   R   t   add_label_data(   R   R0   t   dummyt   labelt   countert   top(    (    s   /usr/lib/python2.6/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   RA   R   Rc   R*   R%   (   R   R0   Rm   R9   R:   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_ol#  s      c         C   s=   |  i  o |  i  d =n |  i i |  i   |  i i   d  S(   Ni˙˙˙˙(   R   R   RA   Re   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_ol-  s    
 c         C   s   |  i  |  d  S(   N(   Ri   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt
   start_menu2  s    c         C   s   |  i    d  S(   N(   Rj   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_menu5  s    c         C   s   |  i  |  d  S(   N(   Ri   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt	   start_dir8  s    c         C   s   |  i    d  S(   N(   Rj   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_dir;  s    c         C   s-   |  i  i d  |  i i d d d g  d  S(   Ni   t   dlR   i    (   R   RA   R   R%   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_dl>  s    c         C   s)   |  i  d  |  i o |  i d =n d  S(   Ni   i˙˙˙˙(   t   ddpopR   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_dlB  s    
 c         C   s   |  i    d  S(   N(   R{   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   do_dtF  s    c         C   s7   |  i    |  i i d  |  i i d d d g  d  S(   Nt   ddR   i    (   R{   R   Rc   R   R%   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   do_ddI  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   RA   R   Re   (   R   t   bl(    (    s   /usr/lib/python2.6/htmllib.pyR{   N  s
    

c         C   s   |  i  |  d  S(   N(   t   start_i(   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt
   start_citeY  s    c         C   s   |  i    d  S(   N(   t   end_i(   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_citeZ  s    c         C   s   |  i  |  d  S(   N(   t   start_tt(   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt
   start_code\  s    c         C   s   |  i    d  S(   N(   t   end_tt(   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_code]  s    c         C   s   |  i  |  d  S(   N(   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_em_  s    c         C   s   |  i    d  S(   N(   R   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_em`  s    c         C   s   |  i  |  d  S(   N(   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt	   start_kbdb  s    c         C   s   |  i    d  S(   N(   R   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_kbdc  s    c         C   s   |  i  |  d  S(   N(   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt
   start_sampe  s    c         C   s   |  i    d  S(   N(   R   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_sampf  s    c         C   s   |  i  |  d  S(   N(   t   start_b(   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   start_strongh  s    c         C   s   |  i    d  S(   N(   t   end_b(   R   (    (    s   /usr/lib/python2.6/htmllib.pyt
   end_strongi  s    c         C   s   |  i  |  d  S(   N(   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt	   start_vark  s    c         C   s   |  i    d  S(   N(   R   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_varl  s    c         C   s    |  i  i t d t t f  d  S(   Ni   (   R   RB   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyR   p  s    c         C   s   |  i  i   d  S(   N(   R   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyR   r  s    c         C   s    |  i  i t t d t f  d  S(   Ni   (   R   RB   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyR   u  s    c         C   s   |  i  i   d  S(   N(   R   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyR   w  s    c         C   s    |  i  i t t t d f  d  S(   Ni   (   R   RB   R   (   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyR   z  s    c         C   s   |  i  i   d  S(   N(   R   RD   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyR   |  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   R0   R&   R'   R(   t   attrnamet   value(    (    s   /usr/lib/python2.6/htmllib.pyt   start_a  s     

c         C   s   |  i    d  S(   N(   R+   (   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   end_a  s    c         C   s   |  i  i   d  S(   N(   R   t   add_line_break(   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   do_br  s    c         C   s   |  i  i   d  S(   N(   R   t   add_hor_rule(   R   R0   (    (    s   /usr/lib/python2.6/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   R0   R   R-   R    R,   RĄ   R˘   R   R   (    (    s   /usr/lib/python2.6/htmllib.pyt   do_img  s6     



  	  c         C   s   |  i  |  |  i   d  S(   N(   RV   t   setnomoretags(   R   R0   (    (    s   /usr/lib/python2.6/htmllib.pyt   do_plaintextś  s    c         C   s   d  S(   N(    (   R   t   tagR0   (    (    s   /usr/lib/python2.6/htmllib.pyt   unknown_starttagź  s    c         C   s   d  S(   N(    (   R   R¨   (    (    s   /usr/lib/python2.6/htmllib.pyt   unknown_endtagż  s    (\   R   R   R   t   htmlentitydefsR   R   R   R   R   R    R$   R)   R+   R/   R1   R2   R3   R4   R5   R6   R7   R8   R;   R<   R=   R>   R?   RC   RE   RG   RH   RJ   RK   RM   RN   RP   RQ   RS   RT   RU   RV   RX   R[   R\   R^   R_   R`   Ra   Rd   Rf   Ri   Rj   Rp   Rs   Rt   Ru   Rv   Rw   Rx   Rz   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   RĽ   R§   RŠ   RŞ   (    (    (    s   /usr/lib/python2.6/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.6/htmllib.pyt   testĂ  s2    t   __main__(   R   t   warningsR    R	   R   R   t   __all__t   SGMLParseErrorR   R
   R   R   RŔ   R   (    (    (    s   /usr/lib/python2.6/htmllib.pyt   <module>   s   	˙ ­'