-í
æ¶<c       s  d  Z  d k Z d k 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 e i ƒ Z e i d ƒ Z e i d ƒ Z d e f d „  ƒ  YZ d e i f d „  ƒ  YZ d S(   s   A parser for HTML and XHTML.Ns   [&<]s   <(/|\Z)s
   &[a-zA-Z#]s%   &([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]s)   &#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]s	   <[a-zA-Z]s   >s   --\s*>s   [a-zA-Z][-.a-zA-Z0-9:_]*s]   \s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:;+*%?!&$\(\)_#=~]*))?sê  
  <[a-zA-Z][-.a-zA-Z0-9:_]*          # tag name
  (?:\s+                             # whitespace before attribute name
    (?:[a-zA-Z_][-.:a-zA-Z0-9_]*     # attribute name
      (?:\s*=\s*                     # value indicator
        (?:'[^']*'                   # LITA-enclosed value
          |\"[^\"]*\"                # LIT-enclosed value
          |[^'\">\s]+                # bare value
         )
       )?
     )
   )*
  \s*                                # trailing whitespace
s#   </\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>s   HTMLParseErrorc      s)   t  Z d  Z e e f d „ Z d „  Z RS(   s&   Exception raised for all parse errors.c    s'   | |  _  | d |  _ | d |  _ d  S(   Ni    i   (   s   msgs   selfs   positions   linenos   offset(   s   selfs   msgs   position(    (    s    /usr/lib/python2.2/HTMLParser.pys   __init__4 s     	c    s_   |  i } |  i t j	 o | d |  i } n |  i t j	 o | d |  i d } n | Sd  S(   Ns   , at line %ds   , column %di   (   s   selfs   msgs   results   linenos   Nones   offset(   s   selfs   result(    (    s    /usr/lib/python2.2/HTMLParser.pys   __str__: s    	(   s   __name__s
   __module__s   __doc__s   Nones   __init__s   __str__(    (    (    s    /usr/lib/python2.2/HTMLParser.pys   HTMLParseError1 s    s
   HTMLParserc      s  t  Z d  Z d d f Z d „  Z d „  Z d „  Z d „  Z d „  Z e	 Z
 d „  Z d	 „  Z d
 „  Z 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 RS(   sÇ  Find tags and other markup and call handler functions.

    Usage:
        p = HTMLParser()
        p.feed(data)
        ...
        p.close()

    Start tags are handled by calling self.handle_starttag() or
    self.handle_startendtag(); end tags by self.handle_endtag().  The
    data between tags is passed from the parser to the derived class
    by calling self.handle_data() with the data as argument (the data
    may be split up in arbitrary chunks).  Entity references are
    passed by calling self.handle_entityref() with the entity
    reference as the argument.  Numeric character references are
    passed to self.handle_charref() with the string containing the
    reference as the argument.
    s   scripts   stylec    s   |  i ƒ  d S(   s#   Initialize and reset this instance.N(   s   selfs   reset(   s   self(    (    s    /usr/lib/python2.2/HTMLParser.pys   __init__Z s     c    s/   d |  _ d |  _ t |  _ t i i |  ƒ d S(   s1   Reset this instance.  Loses all unprocessed data.s    s   ???N(   s   selfs   rawdatas   lasttags   interesting_normals   interestings
   markupbases
   ParserBases   reset(   s   self(    (    s    /usr/lib/python2.2/HTMLParser.pys   reset^ s
     			c    s!   |  i | |  _ |  i d ƒ d S(   s   Feed data to the parser.

        Call this as often as you want, with as little or as much text
        as you want (may include '
').
        i    N(   s   selfs   rawdatas   datas   goahead(   s   selfs   data(    (    s    /usr/lib/python2.2/HTMLParser.pys   feede s     c    s   |  i d ƒ d S(   s   Handle any buffered data.i   N(   s   selfs   goahead(   s   self(    (    s    /usr/lib/python2.2/HTMLParser.pys   closen s     c    s   t  | |  i ƒ  ƒ ‚ d  S(   N(   s   HTMLParseErrors   messages   selfs   getpos(   s   selfs   message(    (    s    /usr/lib/python2.2/HTMLParser.pys   errorr s    c    s   |  i Sd S(   s)   Return full source of start tag: '<...>'.N(   s   selfs   _HTMLParser__starttag_text(   s   self(    (    s    /usr/lib/python2.2/HTMLParser.pys   get_starttag_textw s     c    s   t  |  _ d  S(   N(   s   interesting_cdatas   selfs   interesting(   s   self(    (    s    /usr/lib/python2.2/HTMLParser.pys   set_cdata_mode{ s    c    s   t  |  _ d  S(   N(   s   interesting_normals   selfs   interesting(   s   self(    (    s    /usr/lib/python2.2/HTMLParser.pys   clear_cdata_mode~ s    c 
   sú  |  i } d } t | ƒ } x| | j  o|  i i | | ƒ }	 |	 o |	 i ƒ  } n | } | | j  o |  i
 | | | !ƒ n |  i | | ƒ } | | j o Pn | i } | d | ƒ o:t i | | ƒ o |  i | ƒ } nÕ | d | ƒ o. |  i | ƒ } | d j o |  i ƒ  n n— | d | ƒ o |  i | ƒ } nt | d | ƒ o |  i | ƒ } nQ | d | ƒ o |  i | ƒ } n. | d | j  o |  i
 d ƒ | d } n P| d j  o | o |  i d ƒ n Pn |  i | | ƒ } n®| d	 | ƒ o† t i | | ƒ }	 |	 oh |	 i ƒ  d
 d !} |  i | ƒ |	 i ƒ  } | d | d ƒ o | d } n |  i | | ƒ } q n Pn| d | ƒ ot i | | ƒ }	 |	 od |	 i d ƒ } |  i | ƒ |	 i ƒ  } | d | d ƒ o | d } n |  i | | ƒ } q n t i | | ƒ }	 |	 o4 | o |	 i ƒ  | | j o |  i d ƒ n Pn: | d | j  o' |  i
 d ƒ |  i | | d ƒ } n Pn q W| o
 | | j  o* |  i
 | | | !ƒ |  i | | ƒ } n | | |  _ d  S(   Ni    s   <s   </s   <!--s   <?s   <!i   s   EOF in middle of constructs   &#i   iÿÿÿÿs   ;s   &s#   EOF in middle of entity or char ref(   s   selfs   rawdatas   is   lens   ns   interestings   searchs   matchs   starts   js   handle_datas	   updateposs
   startswiths   starttagopens   parse_starttags   ks   parse_endtags   clear_cdata_modes   parse_comments   parse_pis   parse_declarations   ends   errors   charrefs   groups   names   handle_charrefs	   entityrefs   handle_entityrefs
   incomplete(
   s   selfs   ends
   startswiths   names   is   js   ns   rawdatas   ks   match(    (    s    /usr/lib/python2.2/HTMLParser.pys   goahead„ s    	   	i   c    sr   |  i } t i | | d ƒ } | o d Sn | o( | i ƒ  } |  i	 | | d | !ƒ n | i
 ƒ  } | Sd  S(   Ni   iÿÿÿÿ(   s   selfs   rawdatas   commentcloses   searchs   is   matchs   reports   starts   js   handle_comments   end(   s   selfs   is   reports   rawdatas   js   match(    (    s    /usr/lib/python2.2/HTMLParser.pys   parse_commentÖ s    	 c    sg   |  i } t i | | d ƒ } | o d Sn | i ƒ  } |  i | | d | !ƒ | i	 ƒ  } | Sd  S(   Ni   iÿÿÿÿ(
   s   selfs   rawdatas   picloses   searchs   is   matchs   starts   js	   handle_pis   end(   s   selfs   is   rawdatas   js   match(    (    s    /usr/lib/python2.2/HTMLParser.pys   parse_piã s    	 c    s  t  |  _ |  i | ƒ } | d j  o | Sn |  i } | | | !|  _ g  } t i	 | | d ƒ } | i
 ƒ  } | | d | !i ƒ  |  _ } xò | | j  oä t i	 | | ƒ } | o Pn | i d d d ƒ \ } }
 } |
 o
 t  } nm | d  d j o | d j n p# | d  d j o | d j n o  | d d !} |  i | ƒ } n | i | i ƒ  | f ƒ | i
 ƒ  } q W| | | !i ƒ  } | d d	 f j o |  i ƒ  \ } }	 d
 |  i j o9 | |  i i d
 ƒ } t |  i ƒ |  i i d
 ƒ }	 n |	 t |  i ƒ }	 |  i d | | | !d  ƒ n | i d	 ƒ o |  i  | | ƒ n/ |  i! | | ƒ | |  i" j o |  i# ƒ  n | Sd  S(   Ni    i   i   i   s   'iÿÿÿÿs   "s   >s   />s   
s    junk characters in start tag: %si   ($   s   Nones   selfs   _HTMLParser__starttag_texts   check_for_whole_start_tags   is   endposs   rawdatas   attrss   tagfinds   matchs   ends   ks   lowers   lasttags   tags   attrfinds   ms   groups   attrnames   rests	   attrvalues   unescapes   appends   strips   getposs   linenos   offsets   counts   lens   rfinds   errors   endswiths   handle_startendtags   handle_starttags   CDATA_CONTENT_ELEMENTSs   set_cdata_mode(   s   selfs   is   ends	   attrvalues   ms   attrnames   linenos   tags   rawdatas   offsets   rests   attrss   ks   matchs   endpos(    (    s    /usr/lib/python2.2/HTMLParser.pys   parse_starttagï sL    		  
L#!c    s  |  i } t i | | ƒ } | oí | i ƒ  } | | | d !} | d j o | d Sn | d j o_ | i	 d | ƒ o | d Sn | i	 d | ƒ o d Sn |  i
 | | d ƒ |  i d ƒ n | d j o d Sn | d	 j o d Sn |  i
 | | ƒ |  i d
 ƒ n t d ƒ ‚ d  S(   Ni   s   >s   /s   />i   iÿÿÿÿs   malformed empty start tags    s6   abcdefghijklmnopqrstuvwxyz=/ABCDEFGHIJKLMNOPQRSTUVWXYZs   malformed start tags   we should not get here!(   s   selfs   rawdatas   locatestarttagends   matchs   is   ms   ends   js   nexts
   startswiths	   updateposs   errors   AssertionError(   s   selfs   is   rawdatas   js   ms   next(    (    s    /usr/lib/python2.2/HTMLParser.pys   check_for_whole_start_tag"s*    	c    sœ   |  i } t i | | d ƒ } | o d Sn | i ƒ  } t i | | ƒ } | o |  i	 d | | | !ƒ n | i
 d ƒ } |  i | i ƒ  ƒ | Sd  S(   Ni   iÿÿÿÿs   bad end tag: %s(   s   selfs   rawdatas	   endendtags   searchs   is   matchs   ends   js
   endtagfinds   errors   groups   tags   handle_endtags   lower(   s   selfs   is   tags   rawdatas   js   match(    (    s    /usr/lib/python2.2/HTMLParser.pys   parse_endtag@s    	 c    s!   |  i | | ƒ |  i | ƒ d  S(   N(   s   selfs   handle_starttags   tags   attrss   handle_endtag(   s   selfs   tags   attrs(    (    s    /usr/lib/python2.2/HTMLParser.pys   handle_startendtagOs    c    s   d  S(   N(    (   s   selfs   tags   attrs(    (    s    /usr/lib/python2.2/HTMLParser.pys   handle_starttagTs    c    s   d  S(   N(    (   s   selfs   tag(    (    s    /usr/lib/python2.2/HTMLParser.pys   handle_endtagXs    c    s   d  S(   N(    (   s   selfs   name(    (    s    /usr/lib/python2.2/HTMLParser.pys   handle_charref\s    c    s   d  S(   N(    (   s   selfs   name(    (    s    /usr/lib/python2.2/HTMLParser.pys   handle_entityref`s    c    s   d  S(   N(    (   s   selfs   data(    (    s    /usr/lib/python2.2/HTMLParser.pys   handle_datads    c    s   d  S(   N(    (   s   selfs   data(    (    s    /usr/lib/python2.2/HTMLParser.pys   handle_commenths    c    s   d  S(   N(    (   s   selfs   decl(    (    s    /usr/lib/python2.2/HTMLParser.pys   handle_declls    c    s   d  S(   N(    (   s   selfs   data(    (    s    /usr/lib/python2.2/HTMLParser.pys	   handle_pips    c    s   |  i d | ƒ d  S(   Ns   unknown declaration: (   s   selfs   errors   data(   s   selfs   data(    (    s    /usr/lib/python2.2/HTMLParser.pys   unknown_declss    c    sw   d | j o | Sn | i d d ƒ } | i d d ƒ } | i d d ƒ } | i d d	 ƒ } | i d
 d ƒ } | Sd  S(   Ns   &s   &lt;s   <s   &gt;s   >s   &apos;s   's   &quot;s   "s   &amp;(   s   ss   replace(   s   selfs   s(    (    s    /usr/lib/python2.2/HTMLParser.pys   unescapews    (   s   __name__s
   __module__s   __doc__s   CDATA_CONTENT_ELEMENTSs   __init__s   resets   feeds   closes   errors   Nones   _HTMLParser__starttag_texts   get_starttag_texts   set_cdata_modes   clear_cdata_modes   goaheads   parse_comments   parse_pis   parse_starttags   check_for_whole_start_tags   parse_endtags   handle_startendtags   handle_starttags   handle_endtags   handle_charrefs   handle_entityrefs   handle_datas   handle_comments   handle_decls	   handle_pis   unknown_decls   unescape(    (    (    s    /usr/lib/python2.2/HTMLParser.pys
   HTMLParserC s8    										R		3												(   s   __doc__s
   markupbases   res   compiles   interesting_normals   interesting_cdatas
   incompletes	   entityrefs   charrefs   starttagopens   picloses   commentcloses   tagfinds   attrfinds   VERBOSEs   locatestarttagends	   endendtags
   endtagfinds	   Exceptions   HTMLParseErrors
   ParserBases
   HTMLParser(   s   starttagopens   HTMLParseErrors   locatestarttagends
   markupbases   charrefs   tagfinds	   endendtags   interesting_cdatas
   HTMLParsers	   entityrefs   attrfinds   res
   endtagfinds   interesting_normals   picloses   commentcloses
   incomplete(    (    s    /usr/lib/python2.2/HTMLParser.pys   ? s"   
		