
Ic           @   s  d  Z  d d k l Z d Z d Z d Z d Z d d k l Z l	 Z	 d d k
 Z
 d d k Z d d k Z d d k Z d d k Z y d d	 k l Z Wn e j
 o h  Z n Xy e Wn# e j
 o d d
 k l Z n Xe i d  e _ e i d  i e _ d Z d f  d     YZ d e e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d e f d     YZ! d f  d     YZ" d e# f d     YZ$ d    Z% d!   Z& d"   Z' d# e! e f d$     YZ( d% e( f d&     YZ) d' e* f d(     YZ+ d) e) f d*     YZ, d+ e) f d,     YZ- d- e( f d.     YZ. d/ e( f d0     YZ/ d1 e) f d2     YZ0 d3 e, f d4     YZ1 d5 e- f d6     YZ2 d7 e. f d8     YZ3 y d d k4 Z4 Wn e j
 o e5 Z4 n Xy d d k6 Z7 Wn e j
 o n Xy d d k8 Z8 Wn e j
 o n Xd9 f  d:     YZ9 e: d; j o* d d k; Z; e) e; i<  Z= e= i>   GHn d S(<   s  Beautiful Soup
Elixir and Tonic
"The Screen-Scraper's Friend"
http://www.crummy.com/software/BeautifulSoup/

Beautiful Soup parses a (possibly invalid) XML or HTML document into a
tree representation. It provides methods and Pythonic idioms that make
it easy to navigate, search, and modify the tree.

A well-formed XML/HTML document yields a well-formed data
structure. An ill-formed XML/HTML document yields a correspondingly
ill-formed data structure. If your document is only locally
well-formed, you can use this library to find and process the
well-formed part of it.

Beautiful Soup works with Python 2.2 and up. It has no external
dependencies, but you'll have more success at converting data to UTF-8
if you also install these three packages:

* chardet, for auto-detecting character encodings
  http://chardet.feedparser.org/
* cjkcodecs and iconv_codec, which add more encodings to the ones supported
  by stock Python.
  http://cjkpython.i18n.org/

Beautiful Soup defines classes for two main parsing strategies:

 * BeautifulStoneSoup, for parsing XML, SGML, or your domain-specific
   language that kind of looks like XML.

 * BeautifulSoup, for parsing run-of-the-mill HTML code, be it valid
   or invalid. This class has web browser-like heuristics for
   obtaining a sensible parse tree in the face of common HTML errors.

Beautiful Soup also defines a class (UnicodeDammit) for autodetecting
the encoding of an HTML or XML document, and converting it to
Unicode. Much of this code is taken from Mark Pilgrim's Universal Feed Parser.

For more than you ever wanted to know about Beautiful Soup, see the
documentation:
http://www.crummy.com/software/BeautifulSoup/documentation.html

Here, have some legalese:

Copyright (c) 2004-2008, Leonard Richardson

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above
    copyright notice, this list of conditions and the following
    disclaimer in the documentation and/or other materials provided
    with the distribution.

  * Neither the name of the the Beautiful Soup Consortium and All
    Night Kosher Bakery nor the names of its contributors may be
    used to endorse or promote products derived from this software
    without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE, DAMMIT.

i(   t
   generatorss*   Leonard Richardson (leonardr@segfault.org)s   3.0.7as*   Copyright (c) 2004-2008 Leonard Richardsons   New-style BSD(   t
   SGMLParsert   SGMLParseErrorN(   t   name2codepoint(   t   Sets   [a-zA-Z][-_.:a-zA-Z0-9]*s   [a-zA-Z][-_.:a-zA-Z0-9]*\s*s   utf-8t   PageElementc           B   sv  e  Z d  Z e e d  Z d   Z d   Z d   Z d   Z d   Z	 e h  e d  Z
 e h  e e d  Z e h  e d	  Z e h  e e d
  Z e Z e h  e d  Z e h  e e d  Z e Z e h  e d  Z e h  e e d  Z e Z e h  d  Z e h  e d  Z e Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e d  Z e d  Z  RS(   se   Contains the navigational information for some part of the page
    (either a tag or a piece of text)c         C   sk   | |  _  | |  _ d |  _ d |  _ d |  _ |  i  o0 |  i  i o# |  i  i d |  _ |  |  i _ n d S(   sN   Sets up the initial relations between this element and
        other elements.iN(   t   parentt   previoust   Nonet   nextt   previousSiblingt   nextSiblingt   contents(   t   selfR   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   setupq   s    					c         C   s   |  i  } |  i  i i |   } t | d  oN | i  |  i  j o; |  i  i i |  } | o | | j  o | d } q| n |  i   | i | |  d  S(   NR   i   (   R   R   t   indext   hasattrt   extractt   insert(   R   t   replaceWitht	   oldParentt   myIndexR   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR   }   s    	#
c         C   s   |  i  o1 y |  i  i i |   Wq; t j
 o q; Xn |  i   } | i } |  i o | |  i _ n | o |  i | _ n t |  _ t | _ t |  _  |  i o |  i	 |  i _	 n |  i	 o |  i |  i	 _ n t |  _ |  _	 |  S(   s0   Destructively rips this element out of the tree.(
   R   R   t   removet
   ValueErrort   _lastRecursiveChildR	   R   R   R
   R   (   R   t	   lastChildt   nextElement(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR      s(    
		
			

c         C   s9   |  } x, t  | d  o | i o | i d } q	 W| S(   s8   Finds the last element beneath this object to be parsed.R   i(   R   R   (   R   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR      s    c   	      C   s<  t  | t  p t  | t  o! t  | t  o t |  } n t | t |  i   } t | d  oc | i d  j oS | i |  j o5 |  i
 |  } | o | | j  o | d } q n | i   n |  | _ d  } | d j o d  | _ |  | _ n6 |  i | d } | | _ | | i _ | i   | _ | i o | | i _ n | i   } | t |  i  j oc d  | _ |  } d  } x* | p" | i } | i } | p PqqW| o | | _ qd  | _ n: |  i | } | | _ | i o | | i _ n | | _ | i o | | i _ n |  i i | |  d  S(   NR   i   i    (   t
   isinstancet
   basestringt   unicodet   NavigableStringt   mint   lenR   R   R   R   t   findR   R
   R   R   R   R	   R   (	   R   t   positiont   newChildR   t   previousChildt   newChildsLastElementR   t   parentsNextSiblingt	   nextChild(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR      sV     			
	
		
	
	
c         C   s   |  i  t |  i  |  d S(   s2   Appends the given tag to the contents of this tag.N(   R   R    R   (   R   t   tag(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   append   s    c         K   s   |  i  |  i | | | |  S(   sj   Returns the first item that matches the given criteria and
        appears after this Tag in the document.(   t   _findOnet   findAllNext(   R   t   namet   attrst   textt   kwargs(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   findNext   s    c         K   s   |  i  | | | | |  i |  S(   sb   Returns all items that match the given criteria and appear
        after this Tag in the document.(   t   _findAllt   nextGenerator(   R   R,   R-   R.   t   limitR/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR+      s    c         K   s   |  i  |  i | | | |  S(   s{   Returns the closest sibling to this Tag that matches the
        given criteria and appears after this Tag in the document.(   R*   t   findNextSiblings(   R   R,   R-   R.   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   findNextSibling   s    c         K   s   |  i  | | | | |  i |  S(   sq   Returns the siblings of this Tag that match the given
        criteria and appear after this Tag in the document.(   R1   t   nextSiblingGenerator(   R   R,   R-   R.   R3   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR4     s    c         K   s   |  i  |  i | | | |  S(   sk   Returns the first item that matches the given criteria and
        appears before this Tag in the document.(   R*   t   findAllPrevious(   R   R,   R-   R.   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   findPrevious	  s    c         K   s   |  i  | | | | |  i |  S(   sc   Returns all items that match the given criteria and appear
        before this Tag in the document.(   R1   t   previousGenerator(   R   R,   R-   R.   R3   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR7     s    c         K   s   |  i  |  i | | | |  S(   s|   Returns the closest sibling to this Tag that matches the
        given criteria and appears before this Tag in the document.(   R*   t   findPreviousSiblings(   R   R,   R-   R.   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   findPreviousSibling  s    c         K   s   |  i  | | | | |  i |  S(   sr   Returns the siblings of this Tag that match the given
        criteria and appear before this Tag in the document.(   R1   t   previousSiblingGenerator(   R   R,   R-   R.   R3   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR:     s    c         K   s4   t  } |  i | | d  } | o | d } n | S(   sO   Returns the closest parent of this Tag that matches the given
        criteria.i   i    (   R   t   findParents(   R   R,   R-   R/   t   rt   l(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt
   findParent$  s
    c         K   s   |  i  | | t | |  i |  S(   sF   Returns the parents of this Tag that match the given
        criteria.(   R1   R   t   parentGenerator(   R   R,   R-   R3   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR=   /  s    c         K   s7   d  } | | | | d |  } | o | d } n | S(   Ni   i    (   R   (   R   t   methodR,   R-   R.   R/   R>   R?   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR*   9  s
    c         K   s   t  | t  o
 | } n t | | | |  } t |  } |   }	 x t o| y |	 i   }
 Wn t j
 o Pn X|
 oJ | i |
  } | o0 | i |  | o t |  | j o Pq q qG qG W| S(   s8   Iterates over a generator looking for things that match.(	   R   t   SoupStrainert	   ResultSett   TrueR	   t   StopIterationt   searchR)   R    (   R   R,   R-   R.   R3   t	   generatorR/   t   strainert   resultst   gt   it   found(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR1   @  s"    
	
c         c   s'   |  } x | o | i  } | Vq	 Wd  S(   N(   R	   (   R   RL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR2   Y  s    
	c         c   s'   |  } x | o | i  } | Vq	 Wd  S(   N(   R   (   R   RL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR6   _  s    
	c         c   s'   |  } x | o | i  } | Vq	 Wd  S(   N(   R   (   R   RL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR9   e  s    
	c         c   s'   |  } x | o | i  } | Vq	 Wd  S(   N(   R
   (   R   RL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR<   k  s    
	c         c   s'   |  } x | o | i  } | Vq	 Wd  S(   N(   R   (   R   RL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRA   q  s    
	c         C   s   | p d } | i  d |  S(   Ns   utf-8s   %SOUP-ENCODING%(   t   replace(   R   t   strt   encoding(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   substituteEncodingx  s    c         C   s   t  | t  o | o | i |  } q nj t  | t  o* | o | i |  } q t |  } n0 | o |  i t |  |  } n t |  } | S(   sH   Encodes an object to a string in some encoding, or to Unicode.
        .(   R   R   t   encodeRO   t
   toEncoding(   R   t   sRP   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRS   |  s    (!   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R)   R0   R+   R5   R4   t   fetchNextSiblingsR8   R7   t   fetchPreviousR;   R:   t   fetchPreviousSiblingsR@   R=   t   fetchParentsR*   R1   R2   R6   R9   R<   RA   RQ   RS   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR   m   s>   				<									R   c           B   s8   e  Z d    Z d   Z d   Z d   Z e d  Z RS(   c         C   s7   t  | t  o t i |  |  Sn t i |  | t  S(   s-  Create a new NavigableString.

        When unpickling a NavigableString, this method is called with
        the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be
        passed in to the superclass's __new__ or the superclass won't know
        how to handle non-ASCII characters.
        (   R   R   t   __new__t   DEFAULT_OUTPUT_ENCODING(   t   clst   value(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR\     s    c         C   s   t  i |   f S(   N(   R   t   __str__(   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __getnewargs__  s    c         C   s2   | d j o |  Sn t  d |  i i | f  d S(   s   text.string gives you text. This is for backwards
        compatibility for Navigable*String, but for CData* it lets you
        get the string without the CData wrapper.t   strings!   '%s' object has no attribute '%s'N(   t   AttributeErrort	   __class__RU   (   R   t   attr(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __getattr__  s    c         C   s   t  |   i t  S(   N(   RO   t   decodeR]   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __unicode__  s    c         C   s    | o |  i  |  Sn |  Sd  S(   N(   RR   (   R   RP   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR`     s    (   RU   RV   R\   Ra   Rf   Rh   R]   R`   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s
   					t   CDatac           B   s   e  Z e d   Z RS(   c         C   s   d t  i |  |  S(   Ns   <![CDATA[%s]]>(   R   R`   (   R   RP   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR`     s    (   RU   RV   R]   R`   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRi     s   t   ProcessingInstructionc           B   s   e  Z e d   Z RS(   c         C   s=   |  } d | j o |  i  | |  } n d |  i | |  S(   Ns   %SOUP-ENCODING%s   <?%s?>(   RQ   RS   (   R   RP   t   output(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR`     s    (   RU   RV   R]   R`   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRj     s   t   Commentc           B   s   e  Z e d   Z RS(   c         C   s   d t  i |  |  S(   Ns	   <!--%s-->(   R   R`   (   R   RP   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR`     s    (   RU   RV   R]   R`   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRl     s   t   Declarationc           B   s   e  Z e d   Z RS(   c         C   s   d t  i |  |  S(   Ns   <!%s>(   R   R`   (   R   RP   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR`     s    (   RU   RV   R]   R`   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRm     s   t   Tagc           B   s  e  Z d  Z d   Z h  d d <d d <d d <d d	 <d
 d <Z e e  Z d   Z e e e d  Z e 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 e d  Z d   Z e i d d d  Z d    Z e e d! d"  Z d#   Z e d$  Z  e e d! d%  Z! e h  e" e d&  Z# e# Z$ e h  e" e e d'  Z% e% Z& e# Z' e% Z( e e" e d(  Z) e e" d)  Z* d*   Z+ d+   Z, d,   Z- RS(-   s=   Represents a found HTML tag with its attributes and contents.c         C   s1   h  } x$ |  i    D] \ } } | | | <q W| S(   s    Cheap function to invert a hash.(   t   items(   t   hRL   t   kt   v(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   _invert  s
     t   't   apost   "t   quott   &t   ampt   <t   ltt   >t   gtc         C   s
  | i  d  } |  i o | t j o t t |  Sn | |  i j o% |  i o |  i | Sqd | Sn t |  d j oh | d d j oW t |  d j o, | d d j o t t | d d   Sqt t | d   Sn |  i o d | Sn	 d | Sd	 S(
   s   Used in a call to re.sub to replace HTML, XML, and numeric
        entities with the appropriate Unicode characters. If HTML
        entities are being converted, any unrecognized entities are
        escaped.i   u   &%s;i    t   #t   xi   i   u   &amp;%s;N(	   t   groupt   convertHTMLEntitiesR   t   unichrt   XML_ENTITIES_TO_SPECIAL_CHARSt   convertXMLEntitiesR    t   intt   escapeUnrecognizedEntities(   R   t   matchR   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   _convertEntities  s    
$$
c            s   | i    _ | i |    _ |   _ | d j o
 g  } n |   _ g    _   i | |  t	   _
 t	   _ | i   _ | i   _ | i   _   f d   } t |   i    _ d S(   s   Basic constructor.c            s(   |  \ } } | t  i d    i |  f S(   s   &(#\d+|#x[0-9a-fA-F]+|\w+);(   t   ret   subR   (   t   .0Rq   t   val(   R   (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   <lambda>  s   	N(   Rd   t   parserClasst   isSelfClosingTagt   isSelfClosingR,   R   R-   R   R   t   Falset   hiddent   containsSubstitutionsR   R   R   t   map(   R   t   parserR,   R-   R   R   t   convert(    (   R   s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __init__  s    	
				c         C   s   |  i    i | |  S(   s   Returns the value of the 'key' attribute for the tag, or
        the value given for 'default' if it doesn't have that
        attribute.(   t   _getAttrMapt   get(   R   t   keyt   default(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    c         C   s   |  i    i |  S(   N(   R   t   has_key(   R   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    c         C   s   |  i    | S(   sq   tag[key] returns the value of the 'key' attribute for the tag,
        and throws an exception if it's not there.(   R   (   R   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __getitem__  s    c         C   s   t  |  i  S(   s0   Iterating over a tag iterates over its contents.(   t   iterR   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __iter__  s    c         C   s   t  |  i  S(   s:   The length of a tag is the length of its list of contents.(   R    R   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __len__  s    c         C   s   | |  i  j S(   N(   R   (   R   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __contains__"  s    c         C   s   t  S(   s-   A tag is non-None even if it has no contents.(   RE   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __nonzero__%  s    c         C   s   |  i    | |  i | <t } xU t d t |  i   D]; } |  i | d | j o | | f |  i | <t } q6 q6 W| p |  i i | | f  n | |  i    | <d S(   sK   Setting tag[key] sets the value of the 'key' attribute for the
        tag.i    N(   R   t   attrMapR   t   rangeR    R-   RE   R)   (   R   R   R_   RM   RL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __setitem__)  s    
 c         C   sh   xa |  i  D]V } | d | j o |  i  i |  n |  i   |  i i |  o |  i | =q
 q
 Wd S(   s;   Deleting tag[key] deletes all 'key' attributes for the tag.i    N(   R-   R   R   R   R   (   R   R   t   item(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __delitem__7  s    
 
c         O   s   t  |  i | |  S(   s   Calling a tag like a function is the same as calling its
        findAll() method. Eg. tag('a') returns a list of all the A tags
        found within this tag.(   t   applyt   findAll(   R   t   argsR/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __call__B  s    c         C   s   t  |  d j o5 | i d  t  |  d j o |  i | d   Sn( | i d  d j o |  i |  Sn t d |  i | f  d  S(   Ni   Rn   it   __i    s!   '%s' object has no attribute '%s'(   R    t   rfindR!   Rc   Rd   (   R   R(   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRf   H  s
    3c         C   s   t  | d  pa t  | d  pP t  | d  p? |  i | i j p, |  i | i j p t |   t |  j o t Sn xC t d t |  i   D]) } |  i | | i | j o t Sq q Wt S(   s  Returns true iff this tag has the same name, the same attributes,
        and the same contents (recursively) as the given tag.

        NOTE: right now this will return false if two tags have the
        same attributes in a different order. Should this be fixed?R,   R-   R   i    (   R   R,   R-   R    R   R   R   RE   (   R   t   otherRL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __eq__P  s    r c         C   s   |  | j S(   sZ   Returns true iff this tag is not identical to the other tag,
        as defined in __eq__.(    (   R   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __ne__]  s    c         C   s   |  i  |  S(   s   Renders this tag as a string.(   R`   (   R   RP   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   __repr__b  s    c         C   s   |  i  d   S(   N(   R`   R   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRh   f  s    s   ([<>]|s   &(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)t   )c         C   s    d |  i  | i d  d d S(   sm   Used with a regular expression to substitute the
        appropriate XML entity for an XML special character.Rx   i    t   ;(   t   XML_SPECIAL_CHARS_TO_ENTITIESR   (   R   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   _sub_entitym  s    i    c         C   s  |  i  |  i |  } g  } |  i o x |  i D] \ } } d } t |  o |  i o# d | j o |  i | |  } n d | j o- d } d | j o | i d d  } q n |  i i |  i	 |  } n | i
 | |  i  | |  |  i  | |  f  q/ Wn d }	 d }
 |  i o
 d }	 n d	 | }
 d \ } } | o" | } d | d } | d } n |  i | | |  } |  i o
 | } ng  } d } | o d d i |  } n | o | i
 |  n | i
 d | | |	 f  | o | i
 d  n | i
 |  | o) | o" | d d j o | i
 d  n | o |
 o | i
 |  n | i
 |
  | o" |
 o |  i o | i
 d  n d i |  } | S(   s  Returns a string or Unicode representation of this tag and
        its contents. To get Unicode, pass None for encoding.

        NOTE: since Python's HTML parser consumes whitespace, this
        method is not certain to reproduce the whitespace present in
        the original string.s   %s="%s"s   %SOUP-ENCODING%Rv   s   %s='%s'Rt   s   &squot;t    s    /s   </%s>i    t    i   s   <%s%s%s>s   
i(   i    i    (   RS   R,   R-   t   isStringR   RQ   RN   t   BARE_AMPERSAND_OR_BRACKETR   R   R)   R   t   renderContentsR   t   joinR   (   R   RP   t   prettyPrintt   indentLevelt   encodedNameR-   R   R   t   fmtt   closet   closeTagt	   indentTagt   indentContentst   spaceR   RT   t   attributeString(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR`   r  s`    	

 




c         C   sk   g  } |  i  D] } | | q ~ } x6 | D]. } t | t  o | i   q+ | i   q+ W|  i   d S(   s/   Recursively destroys the contents of this tree.N(   R   R   Rn   t	   decomposeR   (   R   t   _[1]RL   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    $ c         C   s   |  i  | t  S(   N(   R`   RE   (   R   RP   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   prettify  s    c         C   s   g  } x |  D] } t  } t | t  o | i |  } n1 t | t  o  | i | i | | |   n | o | o | i   } n | oI | o | i d | d  n | i |  | o | i d  q q q Wd i |  S(   s{   Renders the contents of this tag as a string in the given
        encoding. If encoding is None, returns a Unicode string..R   i   s   
R   (   R   R   R   R`   Rn   R)   t   stripR   (   R   RP   R   R   RT   t   cR.   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s"      c         K   s=   t  } |  i | | | | d |  } | o | d } n | S(   sL   Return only the first child of this Tag matching the given
        criteria.i   i    (   R   R   (   R   R,   R-   t	   recursiveR.   R/   R>   R?   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR!     s
    c         K   s9   |  i  } | p |  i } n |  i | | | | | |  S(   s  Extracts a list of Tag objects that match the given
        criteria.  You can specify the name of the Tag and any
        attributes you want the Tag to have.

        The value of a key-value pair in the 'attrs' map can be a
        string, a list of strings, a regular expression object, or a
        callable that takes a string and returns whether or not the
        string matches for some custom definition of 'matches'. The
        same is true of the tag name.(   t   recursiveChildGeneratort   childGeneratorR1   (   R   R,   R-   R   R.   R3   R/   RH   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    	c         C   s   |  i  d | d | d |  S(   NR.   R   R3   (   R   (   R   R.   R   R3   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt	   fetchText  s    c         C   s   |  i  d | d |  S(   NR.   R   (   R!   (   R   R.   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt	   firstText  s    c         C   sK   t  |  d  p4 h  |  _ x( |  i D] \ } } | |  i | <q# Wn |  i S(   s^   Initializes a map representation of this tag's attributes,
        if not already initialized.R   (   t   getattrR   R-   (   R   R   R_   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    	
 c         c   s9   x, t  d t |  i   D] } |  i | Vq Wt  d  S(   Ni    (   R   R    R   RF   (   R   RL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s     c         c   s   |  d f g } x | o | i    \ } } t | t  o x t | t | i   D] } | i | } | Vt | t  oW | i oM | t | i  d j  o | i | | d f  n | i | d f  PqT qT Wq q Wt  d  S(   Ni    i   (   t   popR   Rn   R   R    R   R)   RF   (   R   t   stackR(   t   startRL   t   a(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR   "  s    
 (.   RU   RV   RW   Rs   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   Rf   R   R   R]   R   Rh   R   t   compileR   R   R   R`   R   R   R   RE   R!   t	   findChildR   t   findChildrent   firstt   fetchR   R   R   R   R   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRn     s^   																			T	
		
	RC   c           B   sJ   e  Z d  Z e h  e d  Z d   Z e h  d  Z d   Z d   Z RS(   sM   Encapsulates a number of ways of matching a markup element (tag or
    text).c         K   su   | |  _  t |  o | | d <d  } n | o. | o | i   } | i |  q_ | } n | |  _ | |  _ d  S(   Nt   class(   R,   R   R   t   copyt   updateR-   R.   (   R   R,   R-   R.   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR   6  s    	


	c         C   s-   |  i  o |  i  Sn d |  i |  i f Sd  S(   Ns   %s|%s(   R.   R,   R-   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR`   D  s    
c         C   s  d  } d  } t | t  o | } | } n t |  i  o t | t  } |  i pB | p; | o |  i | |  i  p | o |  i | |  i  o | o |  i | |  } n t } d  } x |  i i   D] \ } }	 | pE t	 | d  o
 | } q*h  } x" | D] \ }
 } | | |
 <qWn | i
 |  } |  i | |	  p t } Pq q W| o | o
 | } q}| } qn | S(   NR   (   R   R   Rn   t   callableR,   t   _matchesRE   R-   Ro   R   R   R   (   R   t
   markupNamet   markupAttrsRM   t   markupt   callFunctionWithTagDataR   t   markupAttrMapRe   t   matchAgainstRq   Rr   t	   attrValue(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt	   searchTagJ  sB    
 
 	
c         C   s   d  } t |  oQ t | t  o@ x | D]1 } t | t  o |  i |  o | } Pq+ q+ Wn t | t  o! |  i p |  i |  } q nR t | t  p t |  o$ |  i	 | |  i  o
 | } q n t
 d | i  | S(   Ns&   I don't know how to match against a %s(   R   t   isListR   Rn   R   RG   R.   R   R   R   t	   ExceptionRd   (   R   R   RM   t   element(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRG   o  s$     

c         C   sa  t  } | t j o& t |  t i j o | d  j } n%t |  o | |  } nt | t  o | i	 } n | o t
 |  o t |  } n t | d  o | o | i |  } n t |  o | | j } nh t | d  o | i |  } nE | o= t
 |  o0 t | t  o t |  } qFt |  } n | p | | j } n | S(   NR   Ro   (   R   RE   t   typet   typest   BooleanTypeR   R   R   Rn   R,   R   R   R   RG   R   R   RO   (   R   R   R   t   result(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s,    #(	   RU   RV   RW   R   R   R`   R   RG   R   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRC   2  s   	%	RD   c           B   s   e  Z d  Z d   Z RS(   sT   A ResultSet is just a list that keeps track of the SoupStrainer
    that created it.c         C   s   t  i g   | |  _ d  S(   N(   t   listR   t   source(   R   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    (   RU   RV   RW   R   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRD     s   c         C   s,   t  |  d  p t |   t i t i f j S(   st   Convenience method that works with all 2.x versions of Python
    to determine whether or not something is listlike.R   (   R   R   R   t   ListTypet	   TupleType(   R?   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    c         C   sH   y! t  |  t  p t  |  t  SWn  t j
 o t  |  t  Sn Xd S(   sv   Convenience method that works with all 2.x versions of Python
    to determine whether or not something is stringlike.N(   R   R   R   t	   NameErrorRO   (   RT   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    !c         G   s   h  } x | D]w } t  | d  o+ x^ | i   D] \ } } | | | <q0 Wq t |  o x& | D] } |  | | <qb Wq |  | | <q W| S(   s   Turns a list of maps, lists, or scalars into a single map.
    Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and
    NESTING_RESET_TAGS maps out of lists and partial maps.Ro   (   R   Ro   R   (   R   R   t   builtt   portionRq   Rr   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   buildTagMap  s       t   BeautifulStoneSoupc        	   B   s  e  Z d  Z h  Z h  Z h  Z h  Z g  Z e i	 d  d   f e i	 d  d   f g Z
 d Z d Z d Z d Z e Z h  e d	 <e d
 <e d <e d <e d <Z d e e e e e e e d  Z d   Z e e d  Z d   Z d   Z d   Z d   Z d   Z e d  Z e 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) RS(%   sb  This class contains the basic parser and search code. It defines
    a parser that knows nothing about tag behavior except for the
    following:

      You can't close a tag without closing all the tags it encloses.
      That is, "<foo><bar></foo>" actually means
      "<foo><bar></bar></foo>".

    [Another possible explanation is "<foo><bar /></foo>", but since
    this class defines no SELF_CLOSING_TAGS, it will never use that
    explanation.]

    This class is useful for parsing XML or made-up markup languages,
    or when BeautifulSoup makes an assumption counter to what you were
    expecting.s   (<[^<>]*)/>c         C   s   |  i  d   d S(   i   s    />(   R   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    s   <!\s+([^<>]*)>c         C   s   d  |  i  d  d S(   s   <!i   R|   (   R   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    u
   [document]t   htmlt   xmlt   xhtmli	   i
   i   i   i    R   c	   	      C   sk  | |  _  | |  _ | |  _ | |  _ |  i o d |  _ | |  i j o t |  _ t |  _	 t |  _
 q | |  i j o t |  _ t |  _	 t |  _
 q | |  i j o t |  _ t |  _	 t |  _
 q n t |  _ t |  _	 t |  _
 t d |  |  _ t i |   t | d  o | i   } n | |  _ | |  _ y |  i d |  Wn t j
 o n Xd |  _ d S(   sV  The Soup object is initialized as the 'root tag', and the
        provided markup (which can be a string or a file-like object)
        is fed into the underlying parser.

        sgmllib will process most bad HTML, and the BeautifulSoup
        class has some tricks for dealing with some HTML that kills
        sgmllib, but Beautiful Soup can nonetheless choke or lose data
        if your data uses self-closing tags or declarations
        incorrectly.

        By default, Beautiful Soup uses regexes to sanitize input,
        avoiding the vast majority of these problems. If the problems
        don't apply to you, pass in False for markupMassage, and
        you'll get better performance.

        The default parser massage techniques fix the two most common
        instances of invalid HTML that choke sgmllib:

         <br/> (No space between name of closing tag and tag close)
         <! --Comment--> (Extraneous whitespace in declaration)

        You can pass in a custom list of (RE object, replace method)
        tuples to get Beautiful Soup to scrub your input the way you
        want.t   readt   isHTMLN(   t   parseOnlyTheset   fromEncodingt   smartQuotesTot   convertEntitiesR   t   HTML_ENTITIESR   R   RE   R   R   t   XHTML_ENTITIESt   XML_ENTITIESR   t   instanceSelfClosingTagsR   R   R   R   R   t   markupMassaget   _feedt   StopParsing(	   R   R   R   R   R  R   R   t   selfClosingTagsR   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.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/   This method fixes a bug in Python's SGMLParser.Ni    i   (   R   R   t   convert_codepoint(   R   R,   t   n(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   convert_charrefF  s    	c         C   s=  |  i  } t | t  o! t |  d  p d  |  _ q nI t | |  i | g d |  i d | } | i } | i |  _ | i	 |  _	 | od |  i
 oV t |  i
  p |  i |  _
 n x) |  i
 D] \ } } | i | |  } q W|  `
 q n |  i   t i |  |  |  i   x% |  i i |  i j o |  i   qWd  S(   Nt   originalEncodingR   R   (   R   R   R   R   R   R  t   UnicodeDammitR   R   t   declaredHTMLEncodingR  R   t   MARKUP_MASSAGER   t   resetR   t   feedt   endDatat
   currentTagR,   t   ROOT_TAG_NAMEt   popTag(   R   t   inDocumentEncodingR   R   t   dammitt   fixt   m(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  P  s.    		

 

c         C   s   | i  d  d j p, | i  d  d j p | i  d  d j o t i |  |  Sn1 | i  d  d j o t i |  |  Sn t  d S(   s   This method routes method call requests to either the SGMLParser
        superclass or the Tag superclass, depending on the method name.t   start_i    t   end_t   do_R   N(   R!   R   Rf   Rn   Rc   (   R   t
   methodName(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRf   q  s    ,c         C   s#   |  i  i |  p |  i i |  S(   se   Returns true iff the given string is the name of a
        self-closing tag according to this parser.(   t   SELF_CLOSING_TAGSR   R  (   R   R,   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR   ~  s    c         C   sa   t  i |  |  |  i  d |  _ t i |   g  |  _ d  |  _ g  |  _	 g  |  _
 |  i |   d  S(   Ni   (   Rn   R   R  R   R   R  t   currentDataR   R  t   tagStackt
   quoteStackt   pushTag(   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s    					c         C   s   |  i  i   } t |  i i  d j o4 t |  i i d t  o |  i i d |  i _ n |  i  o |  i  d |  _ n |  i S(   Ni   i    i(   R  R   R    R  R   R   R   Rb   (   R   R(   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s    
c         C   sE   |  i  o |  i  i i |  n |  i i |  |  i d |  _  d  S(   Ni(   R  R   R)   R  (   R   R(   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR!    s    
c         C   sD  |  i  o6d i |  i   } | i |  i  d j o\ t g  } |  i D] } | | i qF ~  i |  i  o! d | j o
 d } q d } n g  |  _  |  i	 o@ t
 |  i  d j o* |  i	 i p |  i	 i |  o d  Sn | |  } | i |  i |  i  |  i o | |  i _ n | |  _ |  i i i |  n d  S(   Nu    R   s   
R   i   (   R  R   t	   translatet   STRIP_ASCII_SPACESt   setR  R,   t   intersectiont   PRESERVE_WHITESPACE_TAGSR   R    R.   RG   R   R  R   R	   R   R)   (   R   t   containerClassR  R   R(   t   o(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s&    
-

	 
	c         C   s   | |  i  j o d Sn d } d } xV t t |  i  d d d  D]5 } | |  i | i j o t |  i  | } PqD qD W| p | d } n x# t d |  D] } |  i   } q W| S(   s   Pops the tag stack up to and including the most recent
        instance of the given tag. If inclusivePop is false, pops the tag
        stack up to but *not* including the most recent instqance of
        the given tag.Ni    i   i(   R  R   R   R    R  R,   R  (   R   R,   t   inclusivePopt   numPopst   mostRecentTagRL   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt	   _popToTag  s      	 c   	      C   s!  |  i  i |  } | d j } |  i i |  } d } t } x t t |  i  d d d  D] } |  i | } | p | i	 | j o | o | } Pn | d j o | i	 | j p* | d j o1 | o* |  i i | i	  o | i	 } t
 } Pn | i } q\ W| o |  i | |  n d S(   s  We need to pop up to the previous tag of this type, unless
        one of this tag's nesting reset triggers comes between this
        tag and the previous tag of this type, OR unless this tag is a
        generic nesting trigger and another generic nesting trigger
        comes between this tag and the previous tag of this type.

        Examples:
         <p>Foo<b>Bar *<p>* should pop to 'p', not 'b'.
         <p>Foo<table>Bar *<p>* should pop to 'table', not 'p'.
         <p>Foo<table><tr>Bar *<p>* should pop to 'tr', not 'p'.

         <li><ul><li> *<li>* should pop to 'ul', not the first 'li'.
         <tr><table><tr> *<tr>* should pop to 'table', not the first 'tr'
         <td><tr><td> *<td>* should pop to 'tr', not the first 'td'
        i   i    iN(   t   NESTABLE_TAGSR   R   t   RESET_NESTING_TAGSR   RE   R   R    R  R,   R   R   R,  (	   R   R,   t   nestingResetTriggerst
   isNestablet   isResetNestingt   popTot	   inclusiveRL   t   p(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt	   _smartPop  s*       	i    c         C   sh  |  i  o: d i t d   |   } |  i d | | f  d  Sn |  i   |  i |  o | o |  i |  n |  i oB t |  i	  d j o, |  i i
 p |  i i | |  o d  Sn t |  | | |  i |  i  } |  i o | |  i _ n | |  _ |  i |  | p |  i |  o |  i   n | |  i j o |  i  i |  d |  _ n | S(   NR   c         S   s   |  \ } } d  | | f S(   s    %s="%s"(    (   R   R   t   y(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    s   <%s%s>i   (   R   R   R   t   handle_dataR  R   R5  R   R    R  R.   R   Rn   R  R   R	   R!  R  t
   QUOTE_TAGSR)   t   literal(   R   R,   R-   t   selfClosingR(   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   unknown_starttag  s*    

 $
	c         C   s   |  i  o- |  i  d | j o |  i d |  d  Sn |  i   |  i |  |  i  o= |  i  d | j o) |  i  i   t |  i   d j |  _ n d  S(   Nis   </%s>i    (   R   R7  R  R,  R   R    R9  (   R   R,   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   unknown_endtag  s    
c         C   s   |  i  i |  d  S(   N(   R  R)   (   R   t   data(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR7  )  s    c         C   s(   |  i    |  i |  |  i  |  d S(   sO   Adds a certain piece of text to the tree as a NavigableString
        subclass.N(   R  R7  (   R   R.   t   subclass(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   _toStringSubclass,  s    
c         C   s/   | d  d j o
 d } n |  i  | t  d S(   s   Handle a processing instruction as a ProcessingInstruction
        object, possibly one with a %SOUP-ENCODING% slot into which an
        encoding will be plugged later.i   R   u,   xml version='1.0' encoding='%SOUP-ENCODING%'N(   R?  Rj   (   R   R.   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt	   handle_pi3  s    
c         C   s   |  i  | t  d S(   s#   Handle comments as Comment objects.N(   R?  Rl   (   R   R.   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   handle_comment;  s    c         C   s;   |  i  o t t |   } n d | } |  i |  d S(   s$   Handle character references as data.s   &#%s;N(   R   R   R   R7  (   R   t   refR=  (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   handle_charref?  s    

c         C   s   d } |  i o. y t t |  } Wq> t j
 o q> Xn | o  |  i o |  i i |  } n | o, |  i o" |  i i |  o d | } n | p d | } n |  i |  d S(   s   Handle entity references as data, possibly converting known
        HTML and/or XML entity references to the corresponding Unicode
        characters.s   &amp;%ss   &%s;N(	   R   R   R   R   t   KeyErrorR   R   R   R7  (   R   RB  R=  (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   handle_entityrefG  s    
	c         C   s   |  i  | t  d S(   s4   Handle DOCTYPEs and the like as Declaration objects.N(   R?  Rm   (   R   R=  (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   handle_declr  s    c         C   s   t  } |  i | | d !d j og |  i i d |  } | d j o t |  i  } n |  i | d | !} | d } |  i | t  nW y t i |  |  } Wn= t j
 o1 |  i | } |  i	 |  | t |  } n X| S(   s`   Treat a bogus SGML declaration as raw data. Treat a CDATA
        declaration as a CData object.i	   s	   <![CDATA[s   ]]>ii   (
   R   t   rawdataR!   R    R?  Ri   R   t   parse_declarationR   R7  (   R   RL   t   jRq   R=  t   toHandle(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRH  v  s    
(*   RU   RV   RW   R  R-  R.  R8  R&  R   R   R  R  R   R  R  t   ALL_ENTITIESR   R#  RE   R   R   R
  R  Rf   R   R  R  R!  R   R  R,  R5  R;  R<  R7  R?  R@  RA  RC  RE  RF  RH  (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     sN   	3	C	
!			
			.							+	t   BeautifulSoupc           B   s  e  Z d  Z d   Z e e d d d d d d d d	 d
 g	  Z e d d g  Z h  e d <e d <Z	 d d d d d d d d g Z
 d d d d d g Z h  g  d <g  d <d d g d <g  d <d g d <d g d  <Z h  g  d! <d! d" d# d$ g d% <d% g d& <d% g d' <d! g d$ <d! g d" <d! g d# <Z d( d) d* d g Z e e e d+ e e e  Z e g  e
 e e e  Z e i d, e i  Z d-   Z RS(.   s  This parser knows the following facts about HTML:

    * Some tags have no closing tag and should be interpreted as being
      closed as soon as they are encountered.

    * The text inside some tags (ie. 'script') may contain tags which
      are not really part of the document and which should be parsed
      as text, not tags. If you want to parse the text as tags, you can
      always fetch it and parse it explicitly.

    * Tag nesting rules:

      Most tags can't be nested at all. For instance, the occurance of
      a <p> tag should implicitly close the previous <p> tag.

       <p>Para1<p>Para2
        should be transformed into:
       <p>Para1</p><p>Para2

      Some tags can be nested arbitrarily. For instance, the occurance
      of a <blockquote> tag should _not_ implicitly close the previous
      <blockquote> tag.

       Alice said: <blockquote>Bob said: <blockquote>Blah
        should NOT be transformed into:
       Alice said: <blockquote>Bob said: </blockquote><blockquote>Blah

      Some tags can be nested, but the nesting is reset by the
      interposition of other tags. For instance, a <tr> tag should
      implicitly close the previous <tr> tag within the same <table>,
      but not close a <tr> tag in another table.

       <table><tr>Blah<tr>Blah
        should be transformed into:
       <table><tr>Blah</tr><tr>Blah
        but,
       <tr>Blah<table><tr>Blah
        should NOT be transformed into
       <tr>Blah<table></tr><tr>Blah

    Differing assumptions about tag nesting rules are a major source
    of problems with the BeautifulSoup class. If BeautifulSoup is not
    treating as nestable a tag your page author treats as nestable,
    try ICantBelieveItsBeautifulSoup, MinimalSoup, or
    BeautifulStoneSoup before writing your own subclass.c         O   sB   | i  d  p |  i | d <n t | d <t i |  | |  d  S(   NR   R   (   R   R   RE   R   R   (   R   R   R/   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    
t   brt   hrt   inputt   imgt   metat   spacert   linkt   framet   baset   pret   textareat   scriptt   spant   fontt   qt   objectt   bdoR   t   supt   centert
   blockquotet   divt   fieldsett   inst   delt   olt   ult   lit   dlt   ddt   dtt   tablet   tbodyt   tfoott   theadt   trt   tdt   tht   addresst   formR4  t   noscripts   ((^|;)\s*charset=)([^;]*)c         C   s  d } d } d } t } xm t d t |   D]V } | | \ } } | i   } | d j o
 | } q. | d j o | } | } q. q. W| o | o |  i i |  }	 |	 o |  i d j	 p |  i |  i	 j o@ d   }
 |  i i
 |
 |  } | | d | f | | <t } q_|	 i d  } | o3 | |  i j o# | |  _ |  i |  i  t  q_qcn |  i d |  } | o | o t | _ n d S(   s   Beautiful Soup can detect a charset included in a META tag,
        try to convert the document to that charset, and re-parse the
        document from the beginning.i    s
   http-equivt   contentc         S   s   |  i  d  d S(   Ni   s   %SOUP-ENCODING%(   R   (   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt   rewrite  s    i   RQ  N(   R   R   R   R    t   lowert
   CHARSET_RERG   R  R  R   R   RE   R   R  R  R;  R   (   R   R-   t	   httpEquivt   contentTypet   contentTypeIndext   tagNeedsEncodingSubstitutionRL   R   R_   R   Rv  t   newAttrt
   newCharsetR(   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt
   start_meta  s@     
	
	
(   RU   RV   RW   R   R   R   R  R$  R&  R8  t   NESTABLE_INLINE_TAGSt   NESTABLE_BLOCK_TAGSt   NESTABLE_LIST_TAGSt   NESTABLE_TABLE_TAGSt   NON_NESTABLE_BLOCK_TAGSR.  R-  R   R   t   MRx  R  (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyRL    s@   .					R  c           B   s   e  Z RS(    (   RU   RV   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  #  s   t   ICantBelieveItsBeautifulSoupc           B   sh   e  Z d  Z d d d d d d d d d	 d
 d d d d d d d g Z d g Z e g  e i e e  Z RS(   sy  The BeautifulSoup class is oriented towards skipping over
    common HTML errors like unclosed tags. However, sometimes it makes
    errors of its own. For instance, consider this fragment:

     <b>Foo<b>Bar</b></b>

    This is perfectly valid (if bizarre) HTML. However, the
    BeautifulSoup class will implicitly close the first b tag when it
    encounters the second 'b'. It will think the author wrote
    "<b>Foo<b>Bar", and didn't close the first 'b' tag, because
    there's no real-world reason to bold something that's already
    bold. When it encounters '</b></b>' it will close two more 'b'
    tags, for a grand total of three tags closed instead of two. This
    can throw off the rest of your document structure. The same is
    true of a number of other tags, listed below.

    It's much more common for someone to forget to close a 'b' tag
    than to actually use nested 'b' tags, and the BeautifulSoup class
    handles the common case. This class handles the not-co-common
    case: where you can't believe someone wrote what they did, but
    it's valid HTML and BeautifulSoup screwed up by assuming it
    wouldn't be.t   emt   bigRL   t   smallt   ttt   abbrt   acronymt   strongt   citet   codet   dfnt   kbdt   sampt   vart   bRt  (   RU   RV   RW   t*   I_CANT_BELIEVE_THEYRE_NESTABLE_INLINE_TAGSt)   I_CANT_BELIEVE_THEYRE_NESTABLE_BLOCK_TAGSR   RL  R-  (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  &  s   		t   MinimalSoupc           B   s    e  Z d  Z e d  Z h  Z RS(   s  The MinimalSoup class is for parsing HTML that contains
    pathologically bad markup. It makes no assumptions about tag
    nesting, but it does know which tags are self-closing, that
    <script> tags contain Javascript and should not be parsed, that
    META tags may contain encoding information, and so on.

    This also makes it better for subclassing than BeautifulStoneSoup
    or BeautifulSoup.Rt  (   RU   RV   RW   R   R.  R-  (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  J  s   t   BeautifulSOAPc           B   s   e  Z d  Z d   Z RS(   s  This class will push a tag with only a single string child into
    the tag's parent as an attribute. The attribute's name is the tag
    name, and the value is the string child. An example should give
    the flavor of the change:

    <foo><bar>baz</bar></foo>
     =>
    <foo bar="baz"><bar>baz</bar></foo>

    You can then access fooTag['bar'] instead of fooTag.barTag.string.

    This is, of course, useful for scraping structures that tend to
    use subelements instead of attributes, such as SOAP messages. Note
    that it modifies its input, so don't print the modified version
    out.

    I'm not sure how many people really want to use this class; let me
    know if you do. Mainly I like the name.c         C   s   t  |  i  d j o |  i d } |  i d } | i   t | t  o\ t  | i  d j oF t | i d t  o/ | i i | i	  o | i d | | i	 <q n t
 i |   d  S(   Ni   iii    (   R    R  R   R   Rn   R   R   R   R   R,   R   R  (   R   R(   R   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  k  s    
&(   RU   RV   RW   R  (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  W  s   t   RobustXMLParserc           B   s   e  Z RS(    (   RU   RV   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  ~  s   t   RobustHTMLParserc           B   s   e  Z RS(    (   RU   RV   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s   t   RobustWackAssHTMLParserc           B   s   e  Z RS(    (   RU   RV   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s   t   RobustInsanelyWackAssHTMLParserc           B   s   e  Z RS(    (   RU   RV   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s   t   SimplifyingSOAPParserc           B   s   e  Z RS(    (   RU   RV   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s   R  c           B   s  e  Z d  Z h  d d <d d <Z g  d e d  Z d   Z d   Z d	   Z e d
  Z	 d   Z
 d   Z e Z d   Z h  df d <d d <dg d <dh d <di d <dj d <dk d! <dl d$ <dm d' <dn d* <do d- <dp d0 <dq d3 <d4 d5 <dr d8 <d4 d9 <d4 d: <ds d= <dt d@ <du dC <dv dF <dw dI <dx dL <dy dO <dz dR <d{ dU <d| dX <d} d[ <d~ d^ <d4 d_ <d db <d de <Z RS(   s   A class for detecting the encoding of a *ML document and
    converting it to a Unicode string. If the source encoding is
    windows-1252, can replace MS smart quotes with their HTML or XML
    equivalents.s	   mac-romant	   macintoshs	   shift-jiss   x-sjisR   c   
      C   s  d  |  _ |  i | |  \ |  _ } } | |  _ g  |  _ | d j p t | t  o  d  |  _ t |  |  _ d  Sn d  } x) | D]! } |  i	 |  } | o Pq q W| p6 x3 | | f D]! } |  i	 |  } | o Pq q Wn | o> t
 o7 t |  i t  o# |  i	 t
 i |  i  d  } n | p0 x- d D]! }	 |  i	 |	  } | o Pq9q9Wn | |  _ | p d  |  _ n d  S(   NR   RP   s   utf-8s   windows-1252(   s   utf-8s   windows-1252(   R   R  t   _detectEncodingR   R   t   triedEncodingsR   R   R  t   _convertFromt   chardett   detect(
   R   R   t   overrideEncodingsR   R   t   documentEncodingt   sniffedEncodingt   ut   proposedEncodingt   proposed_encoding(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s6    				  ## 	c         C   s`   |  i  i |  } t |  t i j o4 |  i d j o d | d } q\ d | d } n | S(   sD   Changes a MS smart quote character to an XML or HTML
        entity.R   s   &#x%s;i   s   &%s;i    (   t   MS_CHARSR   R   R   R   R   (   R   t   origR   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyt
   _subMSChar  s    c            s     i  |  } | p |   i j o d  Sn   i i |    i }   i o; | i   d j o( t i d  i	   f d   |  } n y(   i
 | |  } |   _ |   _ Wn t j
 o } d  Sn X  i S(   Ns   windows-1252s
   iso-8859-1s
   iso-8859-2s   ([-])c            s     i  |  i d    S(   i   (   R  R   (   R   (   R   (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR     s    (   s   windows-1252s
   iso-8859-1s
   iso-8859-2(   t
   find_codecR  R   R)   R   R   Rw  R   R   R   t
   _toUnicodeR  R   (   R   t   proposedR   R  t   e(    (   R   s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s$    	 
		c         C   s  t  |  d j o9 | d  d j o( | d d !d j o d } | d } n t  |  d j o9 | d  d j o( | d d !d j o d } | d } np | d  d	 j o d
 } | d } nK | d  d j o d } | d } n& | d  d j o d } | d } n t | |  } | S(   s   Given a string and its encoding, decodes the string into Unicode.
        %encoding is a string recognized by encodings.aliasesi   i   s   t     s   utf-16bes   s   utf-16lei   s   ﻿s   utf-8t     s   utf-32bes     s   utf-32le(   R    R   (   R   R=  RP   t   newdata(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    s&    $$c         C   s*  t  } } y[| d  d j o |  i |  } n4| d  d j o" d } t | d  i d  } nt |  d j oK | d  d j o: | d d !d j o& d } t | d d  i d  } n| d  d	 j o" d
 } t | d
  i d  } npt |  d j oK | d  d j o: | d d !d j o& d
 } t | d d
  i d  } n| d  d j o" d } t | d  i d  } n | d  d j o" d } t | d  i d  } n | d  d j o& d } t | d d  i d  } nu | d  d j o& d } t | d d  i d  } n> | d  d j o& d } t | d d  i d  } n d } Wn t  } n Xt i d  i |  } | o/ | o( t i d t i  } | i	 |  } n | t  j	 oL | i
   d i   } | o | |  _ n | o | d$ j o
 | } qn | | | f S(%   s3   Given a document, tries to detect its XML encoding.i   s   Lot    < ?s   utf-16bes   utf-8i   s   R  s   < ? s   utf-16les   t      <s   utf-32bes   <   s   utf-32leR  s     i   s   ﻿t   asciis!   ^<\?.*encoding=['"](.*?)['"].*\?>s#   <\s*meta[^>]+charset=([^>]*?)[;'">]i    s   iso-10646-ucs-2s   ucs-2t	   csunicodes   iso-10646-ucs-4s   ucs-4t   csucs4s   utf-16s   utf-32t   utf_16t   utf_32t   utf16t   u16(   s   iso-10646-ucs-2s   ucs-2R  s   iso-10646-ucs-4s   ucs-4R  s   utf-16s   utf-32s   utf_16R  s   utf16s   u16(   R   t   _ebcdic_to_asciiR   RR   R    R   R   R   t   IRG   t   groupsRw  R  (   R   t   xml_dataR   t   xml_encodingt   sniffed_xml_encodingt   xml_encoding_matcht   regexp(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    sj    
$ $    
  
c         C   si   |  i  |  i i | |   pJ | o |  i  | i d d   p' | o |  i  | i d d   p | S(   Nt   -R   t   _(   t   _codect   CHARSET_ALIASESR   RN   (   R   t   charset(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  [  s    ##c         C   sL   | p | Sn d  } y t i |  | } Wn t t f j
 o n X| S(   N(   R   t   codecst   lookupt   LookupErrorR   (   R   R  t   codec(    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  a  s    
c         C   sx   |  i  } | i pU d} dd  k } | i di t t t d   di t t |    | _ n | i | i  S(  Ni    i   i   i   i   i	   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i
   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i    i   i   i   i   i   i   i   i   i   i[   i.   i<   i(   i+   i!   i&   i   i   i   i   i   i   i   i   i   i]   i$   i*   i)   i;   i^   i-   i/   i   i   i   i   i   i   i   i   i|   i,   i%   i_   i>   i?   i   i   i   i   i   i   i   i   i   i`   i:   i#   i@   i'   i=   i"   i   ia   ib   ic   id   ie   if   ig   ih   ii   i   i   i   i   i   i   i   ij   ik   il   im   in   io   ip   iq   ir   i   i   i   i   i   i   i   i~   is   it   iu   iv   iw   ix   iy   iz   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i{   iA   iB   iC   iD   iE   iF   iG   iH   iI   i   i   i   i   i   i   i}   iJ   iK   iL   iM   iN   iO   iP   iQ   iR   i   i   i   i   i   i   i\   i   iS   iT   iU   iV   iW   iX   iY   iZ   i   i   i   i   i   i   i0   i1   i2   i3   i4   i5   i6   i7   i8   i9   i   i   i   i   i   i   iR   i   (   i    i   i   i   i   i	   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i
   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i    i   i   i   i   i   i   i   i   i   i[   i.   i<   i(   i+   i!   i&   i   i   i   i   i   i   i   i   i   i]   i$   i*   i)   i;   i^   i-   i/   i   i   i   i   i   i   i   i   i|   i,   i%   i_   i>   i?   i   i   i   i   i   i   i   i   i   i`   i:   i#   i@   i'   i=   i"   i   ia   ib   ic   id   ie   if   ig   ih   ii   i   i   i   i   i   i   i   ij   ik   il   im   in   io   ip   iq   ir   i   i   i   i   i   i   i   i~   is   it   iu   iv   iw   ix   iy   iz   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i{   iA   iB   iC   iD   iE   iF   iG   iH   iI   i   i   i   i   i   i   i}   iJ   iK   iL   iM   iN   iO   iP   iQ   iR   i   i   i   i   i   i   i\   i   iS   iT   iU   iV   iW   iX   iY   iZ   i   i   i   i   i   i   i0   i1   i2   i3   i4   i5   i6   i7   i8   i9   i   i   i   i   i   i   (	   Rd   t   EBCDIC_TO_ASCII_MAPRb   t	   maketransR   R   t   chrR   R"  (   R   RT   R   t   emapRb   (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR  l  s.    	
                =t   eurot   20ACs   R   s   t   sbquot   201As   t   fnoft   192s   t   bdquot   201Es   t   hellipt   2026s   t   daggert   2020s   t   Daggert   2021s   t   circt   2C6s   t   permilt   2030s   t   Scaront   160s   t   lsaquot   2039s   t   OEligt   152s   t   ?s   s   #x17Dt   17Ds   s   s   t   lsquot   2018s   t   rsquot   2019s   t   ldquot   201Cs   t   rdquot   201Ds   t   bullt   2022s   t   ndasht   2013s   t   mdasht   2014s   t   tildet   2DCs   t   tradet   2122s   t   scaront   161s   t   rsaquot   203As   t   oeligt   153s   s   s   #x17Et   17Es   t   YumlR   s   (   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   #x17DR  (   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   #x17ER  (   R  R   (   RU   RV   RW   R  R   R   R  R  R  R  R  R  R   R  R  R  (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pyR    sZ   !			D		
																															t   __main__(?   RW   t
   __future__R    t
   __author__t   __version__t   __copyright__t   __license__t   sgmllibR   R   R  t
   markupbaseR   R   t   htmlentitydefsR   t   ImportErrorR$  R   t   setsR   R   t   tagfindR   t   _declname_matchR]   R   R   R   Ri   Rj   Rl   Rm   Rn   RC   R   RD   R   R   R   R   RL  R   R  R  R  R  R  R  R  R  R  R  R   t   cjkcodecs.aliasest	   cjkcodecst   iconv_codecR  RU   t   syst   stdint   soupR   (    (    (    s>   /afs/cs.wisc.edu/p/zhu/public/html/space2/TTP/BeautifulSoup.pys   <module>N   s    "# nw				 $' 