Ñò
mÈKc           @   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 o5d d k l Z l Z e d d e ƒ Z e d d d d ƒ Z e e e e ƒ ƒ j p t ‚ 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   sŠ  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 |  d e d e ƒ } y |	 | UWn, e j
 o  } e | i d |	 ƒ ‚ n X| |  } e e d ƒ o% e i d ƒ i i d 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!   /usr/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!   /usr/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!   /usr/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))
t   _itemgettert   __name__s   namedtuple_%st	   _propertyt   _tuples   :
t	   _getframet   __main__(   t
   isinstancet
   basestringt   replacet   splitt   tuplet   mapt   strt   allt
   ValueErrort
   _iskeywordt   isdigitt   sett
   startswitht   addt   lent   reprt   joint	   enumeratet   localst   dictR   t   propertyt   SyntaxErrort   messaget   hasattrt   _sysR   t	   f_globalst   gett
   __module__(   t   typenamet   field_namest   verboseR   t
   seen_namest	   numfieldst   argtxtt   reprtxtt   dicttxtt   templatet   it	   namespacet   et   result(    (    s!   /usr/lib/python2.6/collections.pyR      sN     	  	
%R   (   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      à?(   RB   RC   (   t   self(    (    s!   /usr/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(   RB   RC   RE   (   RD   (    (    s!   /usr/lib/python2.6/collections.pyt   __str__   s    (    (   R   R1   t	   __slots__R*   RE   RF   (    (    (    s!   /usr/lib/python2.6/collections.pyRA   |   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(   NRB   RC   (   RB   RC   (   t   _makeR0   (   RD   t   _mapt   kwds(    (    s!   /usr/lib/python2.6/collections.pyt   _replace‹   s    (    (
   R   R1   t   __doc__RG   t   classmethodR   t   __new__RH   R   RK   (    (    (    s!   /usr/lib/python2.6/collections.pyRA   ‡   s   i   i   id   t   Point3Dt   zt   TestResultss   failed attempted(   RP   (   t   __all__t   _abcollt   _collectionsR    R   t   operatorR   R   t   keywordR   R   t   sysR.   t   FalseR   R   t   cPickleR?   R@   t   TrueRA   t   pt   AssertionErrorRK   t   _fieldsRO   RL   t   doctestRQ   t   testmod(    (    (    s!   /usr/lib/python2.6/collections.pyt   <module>   s0   
g # 	