Ñò
à"Ic           @   s¦  d  d d g Z  d d k Td d k Z e  e i  7Z  d d k l Z l Z d d k l Z d d k l	 Z
 d d k Z e d	 „ Z e d
 j od d k l Z l Z e d d e ƒ Z e d d d d ƒ Z d e d d ƒ f d „  ƒ  YZ x/ e d d ƒ e d d d ƒ f D] Z e GHqWd e d d ƒ f d „  ƒ  YZ e d d ƒ i d d ƒ GHe d e i d! ƒ Z e i GHd d k Z e d d  ƒ Z e e i ƒ  Œ  GHn d S("   t   dequet   defaultdictt
   namedtupleiÿÿÿÿ(   t   *N(   R    R   (   t
   itemgetter(   t	   iskeywordc         B   sv  e  | e ƒ o | i d d ƒ i ƒ  } n e e e | ƒ ƒ } x† |  f | D]w } e d „  | Dƒ ƒ p e d | ƒ ‚ n e	 | ƒ o e d | ƒ ‚ n | d i
 ƒ  o e d | ƒ ‚ qO qO We ƒ  } x` | D]X } | i d ƒ o e d	 | ƒ ‚ n | | j o e d
 | ƒ ‚ n | i | ƒ qÚ We | ƒ } e | ƒ i d d ƒ d d !} d i d „  | Dƒ ƒ } d i d „  e | ƒ Dƒ ƒ } d e ƒ  }	 x. e | ƒ D]  \ }
 } |	 d | |
 f 7}	 q³W| o	 |	 GHn e d e d d |  ƒ } y |	 | UWn, e j
 o  } e | i d |	 ƒ ‚ n X| |  } e e d ƒ o e i d ƒ i d | _ n | S(   s>  Returns a new subclass of tuple with named fields.

    >>> Point = namedtuple('Point', 'x y')
    >>> Point.__doc__                   # docstring for the new class
    'Point(x, y)'
    >>> p = Point(11, y=22)             # instantiate with positional args or keywords
    >>> p[0] + p[1]                     # indexable like a plain tuple
    33
    >>> x, y = p                        # unpack like a regular tuple
    >>> x, y
    (11, 22)
    >>> p.x + p.y                       # fields also accessable by name
    33
    >>> d = p._asdict()                 # convert to a dictionary
    >>> d['x']
    11
    >>> Point(**d)                      # convert from a dictionary
    Point(x=11, y=22)
    >>> p._replace(x=100)               # _replace() is like str.replace() but targets named fields
    Point(x=100, y=22)

    t   ,t    c         s   s,   x% |  ] } | i  ƒ  p
 | d  j Vq Wd S(   t   _N(   t   isalnum(   t   .0t   c(    (    s(   /mit/python/lib/python2.6/collections.pys	   <genexpr>+   s   	 sW   Type names and field names can only contain alphanumeric characters and underscores: %rs2   Type names and field names cannot be a keyword: %ri    s9   Type names and field names cannot start with a number: %rR   s/   Field names cannot start with an underscore: %rs$   Encountered duplicate field name: %rt   't    i   iÿÿÿÿs   , c         s   s   x |  ] } d  | Vq Wd S(   s   %s=%%rN(    (   R
   t   name(    (    s(   /mit/python/lib/python2.6/collections.pys	   <genexpr><   s   	 c         s   s)   x" |  ] \ } } d  | | f Vq Wd S(   s	   %r: t[%d]N(    (   R
   t   posR   (    (    s(   /mit/python/lib/python2.6/collections.pys	   <genexpr>=   s   	 s¤  class %(typename)s(tuple):
        '%(typename)s(%(argtxt)s)' 

        __slots__ = () 

        _fields = %(field_names)r 

        def __new__(cls, %(argtxt)s):
            return tuple.__new__(cls, (%(argtxt)s)) 

        @classmethod
        def _make(cls, iterable, new=tuple.__new__, len=len):
            'Make a new %(typename)s object from a sequence or iterable'
            result = new(cls, iterable)
            if len(result) != %(numfields)d:
                raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result))
            return result 

        def __repr__(self):
            return '%(typename)s(%(reprtxt)s)' %% self 

        def _asdict(t):
            'Return a new dict which maps field names to their values'
            return {%(dicttxt)s} 

        def _replace(self, **kwds):
            'Return a new %(typename)s object replacing specified fields with new values'
            result = self._make(map(kwds.pop, %(field_names)r, self))
            if kwds:
                raise ValueError('Got unexpected field names: %%r' %% kwds.keys())
            return result 

        def __getnewargs__(self):
            return tuple(self) 

s&           %s = property(itemgetter(%d))
R   t   __name__s   namedtuple_%ss   :
t	   _getframe(   t
   isinstancet
   basestringt   replacet   splitt   tuplet   mapt   strt   allt
   ValueErrort
   _iskeywordt   isdigitt   sett
   startswitht   addt   lent   reprt   joint	   enumeratet   localst   dictt   _itemgettert   SyntaxErrort   messaget   hasattrt   _sysR   t	   f_globalst
   __module__(   t   typenamet   field_namest   verboseR   t
   seen_namest	   numfieldst   argtxtt   reprtxtt   dicttxtt   templatet   it	   namespacet   et   result(    (    s(   /mit/python/lib/python2.6/collections.pyR      sL     	  	
t   __main__(   t   loadst   dumpst   Points   x, yt   xi
   t   yi   s   x yc           B   s&   e  Z d Z e d  „  ƒ Z d „  Z RS(   c         C   s   |  i  d |  i d d S(   Ni   g      à?(   R>   R?   (   t   self(    (    s(   /mit/python/lib/python2.6/collections.pyt   hypot}   s    c         C   s   d |  i  |  i |  i f S(   Ns$   Point: x=%6.3f  y=%6.3f  hypot=%6.3f(   R>   R?   RA   (   R@   (    (    s(   /mit/python/lib/python2.6/collections.pyt   __str__€   s    (    (   R   R,   t	   __slots__t   propertyRA   RB   (    (    (    s(   /mit/python/lib/python2.6/collections.pyR=   {   s   i   i   i   i   g      @c           B   s/   e  Z d  Z d Z e e i ƒ Z e d „ Z	 RS(   sH   Point class with optimized _make() and _replace() without error-checkingc         K   s   |  i  | | i d |  ƒ ƒ S(   NR>   R?   (   R>   R?   (   t   _maket   get(   R@   t   _mapt   kwds(    (    s(   /mit/python/lib/python2.6/collections.pyt   _replaceŠ   s    (    (
   R   R,   t   __doc__RC   t   classmethodR   t   __new__RE   R   RI   (    (    (    s(   /mit/python/lib/python2.6/collections.pyR=   †   s   i   i   id   t   Point3Dt   zt   TestResultss   failed attempted(   RN   (   t   __all__t   _abcollt   _collectionsR    R   t   operatorR   R&   t   keywordR   R   t   sysR*   t   FalseR   R   t   cPickleR;   R<   t   TrueR=   t   pRI   t   _fieldsRM   RJ   t   doctestRO   t   testmod(    (    (    s(   /mit/python/lib/python2.6/collections.pyt   <module>   s.   
f# 	