-
67Fc       s     d  k  Z  d Z  d Z 	 d   Z  d f  d     YZ + d e f d     YZ Z e d  Z j d	   Z	 u d
   Z
  d  k Z  d  k Z  d  k  Z  d  k Z  d  k Z  d  k Z  d k l Z  d e i i i f d     YZ  d f  d     YZ d  S(   Ni   i    c    s   	 
 |  | j Sd  S(   N(   s   as   b(   s   as   b(    (    s   __init__.pys   _compare	 s   s   Datac      sD    d  Z    e d  Z  d   Z  e d  Z % d   Z RS(   s   An empty data structure.  Useful for data structures with dynamic
    member fields, i.e. adding new member variables at run time.
    c    s     |  i | |  d  S(   N(   s   selfs   updates   others   kw(   s   selfs   others   kw(    (    s   __init__.pys   __init__ s   c    s     |  i }  d | i | i f }  x= |  i i   D ]) \ } }  | d | t
 |  f 7} q; W | d 7}  | Sd  S(   Ns   %s.%s(s   %s=%s, s   )(   s   selfs	   __class__s   cs
   __module__s   __name__s   ss   __dict__s   itemss   ks   vs   repr(   s   selfs   ss   vs   cs   k(    (    s   __init__.pys   __repr__ s    !c    sD      | t j o ! |  i i | i  n " |  i i |  d  S(   N(   s   others   Nones   selfs   __dict__s   updates   kw(   s   selfs   others   kw(    (    s   __init__.pys   update s   c    s*   % & t    } ' | i |   ( | Sd  S(   N(   s   Datas   others   updates   self(   s   selfs   other(    (    s   __init__.pys   clone% s   (   s   __doc__s   Nones   __init__s   __repr__s   updates   clone(    (    (    s   __init__.pys   Data s
   		s   DefaultedDatac      sS   + d  Z  9 ; e   e d  Z A d   Z K d   Z O d   Z V d   Z RS(   s(  An empty data structure, like Data.  This one, however, returns a 
    specified default value for any undefined field.  This avoid having 
    to set up alot of exception handlers in order to test whether a given 
    field is present.  It also accepts a Data in its c'tor.  This is useful 
    for wrapping an existing Data when the 'defualted' behavior is desired.
    
    example:
        d = Data(x=1, y=2)
        dd = DefaultedData(data=d, a=100)
        dd.x  =>  1
        dd.y  =>  2
        dd.a  =>  100
        dd.b  =>  None        
    c    s:   ; < | i i |  = | |  i d <> | |  i d <d  S(   Ns	   __defaults   __data(   s   datas   __dict__s   updates   kws   defaults   self(   s   selfs   datas   defaults   kw(    (    s   __init__.pys   __init__; s   c    s   A B y C |  i d i | SWnY D t j
 oJ E | d d !d j o | d d j o F t  n H |  i d Sn Xd  S(   Ns   __datai    i   s   __is	   __default(   s   selfs   __dict__s   names   KeyErrors   AttributeError(   s   selfs   name(    (    s   __init__.pys   __getattr__A s   (c    s   K L | |  i d i | <d  S(   Ns   __data(   s   vals   selfs   __dict__s   name(   s   selfs   names   val(    (    s   __init__.pys   __setattr__K s   c    sL   O P |  i } Q t |  i d  } R d | i | i | f } S | Sd  S(   Ns   __datas	   %s.%s(%s)(	   s   selfs	   __class__s   cs   reprs   __dict__s   sdatas
   __module__s   __name__s   s(   s   selfs   ss   cs   sdata(    (    s   __init__.pys   __repr__O s   c    s   V W t  |  i d  Sd  S(   Ns   __data(   s   strs   selfs   __dict__(   s   self(    (    s   __init__.pys   __str__V s   (   s   __doc__s   Datas   Nones   __init__s   __getattr__s   __setattr__s   __repr__s   __str__(    (    (    s   __init__.pys   DefaultedData+ s   	
c    st   Z _ ` t    } a | t j o b | i i | i  n d x' |  Dd ] } e | i i | i  qF Wg | Sd S(   s   Take a list of Data() structures and merge into 1 structure
    containing the union of all fields of all structures.  In the 
    case of matching field names, the last item in the list takes 
    precedence.
    N(   s   Datas   ress   defaults   Nones   __dict__s   updates   dataLists   data(   s   dataLists   defaults   ress   data(    (    s   __init__.pys   mergeStructsZ s   
 	c    sG   j k m |  | j  o n d Sn# o |  | j o p d Sn r d Sd S(   s8   Compares 2 numbers in a way useful for the sort routine.ii   i    N(   s   ls   r(   s   ls   r(    (    s   __init__.pys   comparej s   c    s\   u z | xE | D| ]: } } d | |  f } ~ t i i |  o  | Sn q W t Sd S(   s  Find the 1st instance of the specified file name in the given directories.
    Search through the directories, in the list's order, for a file with the
    specified name.  The full path, including filename, of the first one found
    will be returned or None if one is not found.
    s   %s/%sN(   s   dirLists   ds   fnames   fullNames   oss   paths   existss   None(   s   fnames   dirLists   ds   fullName(    (    s   __init__.pys   findFirstFileu s   
 	(   s   finds
   SAXHandlerc      sV    d  Z    d   Z  d   Z  d   Z  d   Z  d   Z  d   Z RS(   su   Extend the start/end-Element methods of this class to use more tag-
    specific handlers provided in derived classesc    s     t  |  _ d  S(   N(   s   Nones   selfs   _SAXHandler__tag(   s   self(    (    s   __init__.pys   startDocument s   c    sP     | |  _  t |  d | f t  }  | t j o  | |  n d  S(   Ns   start%s(   s   tags   selfs   _SAXHandler__tags   getattrs   Nones   handlers   attrs(   s   selfs   tags   attrss   handler(    (    s   __init__.pys   startElement s   c    sM     t  |  d | f t  }  | t j o  |   n  t |  _ d  S(   Ns   end%s(   s   getattrs   selfs   tags   Nones   handlers   _SAXHandler__tag(   s   selfs   tags   handler(    (    s   __init__.pys
   endElement s   c    sD     t  |  d |  i t  }  | t j o  | |  n d  S(   Ns   characters%s(   s   getattrs   selfs   _SAXHandler__tags   Nones   handlers   content(   s   selfs   contents   handler(    (    s   __init__.pys
   characters s   c    sG     t  |  d |  i f t  }  | t j o  | |  n d  S(   Ns   ignoreableWhitespace%s(   s   getattrs   selfs   _SAXHandler__tags   Nones   handlers   content(   s   selfs   contents   handler(    (    s   __init__.pys   ignoreableWhitespace s   c    s     |  i Sd  S(   N(   s   selfs   _SAXHandler__tag(   s   self(    (    s   __init__.pys   getCurrentTag s   (   s   __doc__s   startDocuments   startElements
   endElements
   characterss   ignoreableWhitespaces   getCurrentTag(    (    (    s   __init__.pys
   SAXHandler s   	s
   SubHandlerc      s2    d  Z    d   Z  d   Z  d   Z RS(   s  This class implements a framework that allows a container class to be
    extended at runtime with various specialized "plug-ins".
    Basically, what you do is subclass this thing with whatever specialized
    handling methods a particular xml doc type needs.
    On init, this class will extend its (passed-in) container class with a bunch
    of tag-handling plug-in methods whose names begin with 'start' and 'end'.
    When you call deatch(), it removes these doc-specific tag handlers.
    To avoid run-time name conflicts, make sure the container class does not
    already have methods that begin with 'start' or 'end' AND have the same 
    name as methods in your derived class!c    s      | |  _  x t |   D ] }  t | d d d  d j p5 t | d d d  d j p t | d d d  d j oP  t | |  d j o  t d | f  n  t | | t	 |  |   n q" Wd	 S(
   sf   Look for subclassed methods that begin with 'start' or 'end'.
        Add them to the containter classs   starti    i   s   endi   s
   charactersi
   s   Method Name Conflict: %sN(
   s	   containers   selfs
   _containers   dirs   keys   finds   hasattrs   RuntimeErrors   setattrs   getattr(   s   selfs	   containers   key(    (    s   __init__.pys   __init__ s    	Wc    s
     d  S(   N(    (   s   self(    (    s   __init__.pys   finished s   c    s      x t  |   D ]t }  t | d d d  d j p5 t | d d d  d j p t | d d d  d j o  t |  i |  n q Wd S(	   s=   Delete all the methods that were added to the container classs   starti    i   s   endi   s
   charactersi
   N(   s   dirs   selfs   keys   finds   delattrs
   _container(   s   selfs   key(    (    s   __init__.pys   detach s
    	W(   s   __doc__s   __init__s   finisheds   detach(    (    (    s   __init__.pys
   SubHandler s   	
(   s   os.paths   oss   TRUEs   FALSEs   _compares   Datas   DefaultedDatas   Nones   mergeStructss   compares   findFirstFiles   urllibs   xml.saxs   xmls	   cStringIOs   strings   times   finds   saxs   handlers   ContentHandlers
   SAXHandlers
   SubHandler(   s   xmls	   cStringIOs   mergeStructss   FALSEs   strings   findFirstFiles   Datas   _compares   compares   urllibs
   SubHandlers
   SAXHandlers   times   DefaultedDatas   oss   finds   TRUE(    (    s   __init__.pys   ? s"   		/"!