ó
ÓnäZc           @   s   y d  d l  m Z Wn! e k
 r7 d  d l m Z n Xy  d  d l m Z m Z m Z Wn e k
 rk n Xd e	 f d     YZ
 d S(   i’’’’(   t	   get_ident(   t   KeysViewt
   ValuesViewt	   ItemsViewt   OrderedDictc           B   s  e  Z d  Z d   Z e j d  Z e j d  Z d   Z d   Z d   Z	 e
 d  Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z e Z e   Z e d  Z d d  Z i  d  Z d   Z d   Z e d d   Z d   Z d   Z d   Z  d   Z! d   Z" RS(   s)   Dictionary that remembers insertion orderc         O   s   t  |  d k r+ t d t  |    n  y |  j Wn7 t k
 ro g  |  _ } | | d g | (i  |  _ n X|  j | |   d S(   sÅ   Initialize an ordered dictionary.  Signature is the same as for
        regular dictionaries, but keyword arguments are not recommended
        because their insertion order is arbitrary.

        i   s$   expected at most 1 arguments, got %dN(   t   lent	   TypeErrort   _OrderedDict__roott   AttributeErrort   Nonet   _OrderedDict__mapt   _OrderedDict__update(   t   selft   argst   kwdst   root(    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   __init__7   s    c         C   s\   | |  k rH |  j  } | d } | | | g | d <| d <|  j | <n  | |  | |  d S(   s!   od.__setitem__(i, y) <==> od[i]=yi    i   N(   R   R
   (   R   t   keyt   valuet   dict_setitemR   t   last(    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   __setitem__G   s
    	
)c         C   s@   | |  |  |  j  j |  \ } } } | | d <| | d <d S(   s    od.__delitem__(y) <==> del od[y]i   i    N(   R
   t   pop(   R   R   t   dict_delitemt	   link_prevt	   link_next(    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   __delitem__Q   s    
c         c   s=   |  j  } | d } x# | | k	 r8 | d V| d } q Wd S(   s   od.__iter__() <==> iter(od)i   i   N(   R   (   R   R   t   curr(    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   __iter__Z   s
    	
	c         c   s=   |  j  } | d } x# | | k	 r8 | d V| d } q Wd S(   s#   od.__reversed__() <==> reversed(od)i    i   N(   R   (   R   R   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   __reversed__b   s
    	
	c         C   sm   yH x |  j  j   D]
 } | 2q W|  j } | | d g | (|  j  j   Wn t k
 r[ n Xt j |   d S(   s.   od.clear() -> None.  Remove all items from od.N(   R
   t
   itervaluesR   R	   t   clearR   t   dict(   R   t   nodeR   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyR   j   s    	c         C   s§   |  s t  d   n  |  j } | rO | d } | d } | | d <| | d <n( | d } | d } | | d <| | d <| d } |  j | =t j |  |  } | | f S(   s   od.popitem() -> (k, v), return and remove a (key, value) pair.
        Pairs are returned in LIFO order if last is true or FIFO order if false.

        s   dictionary is emptyi    i   i   (   t   KeyErrorR   R
   R    R   (   R   R   R   t   linkR   R   R   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   popitemv   s     	








c         C   s
   t  |   S(   s   od.keys() -> list of keys in od(   t   list(   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   keys   s    c         C   s   g  |  D] } |  | ^ q S(   s#   od.values() -> list of values in od(    (   R   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   values   s    c         C   s!   g  |  D] } | |  | f ^ q S(   s.   od.items() -> list of (key, value) pairs in od(    (   R   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   items   s    c         C   s
   t  |   S(   s0   od.iterkeys() -> an iterator over the keys in od(   t   iter(   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   iterkeys   s    c         c   s   x |  D] } |  | Vq Wd S(   s2   od.itervalues -> an iterator over the values in odN(    (   R   t   k(    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyR      s    c         c   s$   x |  D] } | |  | f Vq Wd S(   s=   od.iteritems -> an iterator over the (key, value) items in odN(    (   R   R+   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt	   iteritems¤   s    c          O   s&  t  |   d k r. t d t  |   f   n |  sC t d   n  |  d } d } t  |   d k rr |  d } n  t | t  r£ xw | D] } | | | | <q WnX t | d  rŚ xF | j   D] } | | | | <qæ Wn! x | D] \ } } | | | <qį Wx$ | j   D] \ } } | | | <qWd S(	   s  od.update(E, **F) -> None.  Update od from dict/iterable E and F.

        If E is a dict instance, does:           for k in E: od[k] = E[k]
        If E has a .keys() method, does:         for k in E.keys(): od[k] = E[k]
        Or if E is an iterable of items, does:   for k, v in E: od[k] = v
        In either case, this is followed by:     for k, v in F.items(): od[k] = v

        i   s8   update() takes at most 2 positional arguments (%d given)s,   update() takes at least 1 argument (0 given)i    i   R&   N(    (   R   R   t
   isinstanceR    t   hasattrR&   R(   (   R   R   R   t   otherR   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   update«   s&    	
c         C   sC   | |  k r! |  | } |  | =| S| |  j  k r? t |   n  | S(   s©   od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
        If key is not found, d is returned if given, otherwise KeyError is raised.

        (   t   _OrderedDict__markerR"   (   R   R   t   defaultt   result(    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyR   Ī   s    
c         C   s"   | |  k r |  | S| |  | <| S(   sD   od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od(    (   R   R   R2   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt
   setdefaultŪ   s    
c         C   ss   t  |   t   f } | | k r% d Sd | | <z5 |  sI d |  j j f Sd |  j j |  j   f SWd | | =Xd S(   s   od.__repr__() <==> repr(od)s   ...i   s   %s()s   %s(%r)N(   t   idt
   _get_identt	   __class__t   __name__R(   (   R   t   _repr_runningt   call_key(    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   __repr__ā   s    
c         C   s   g  |  D] } | |  | g ^ q } t  |   j   } x' t  t    D] } | j | d  qE W| rx |  j | f | f S|  j | f f S(   s%   Return state information for picklingN(   t   varst   copyR   R   R	   R7   (   R   R+   R(   t	   inst_dict(    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt
   __reduce__ļ   s    #c         C   s   |  j  |   S(   s!   od.copy() -> a shallow copy of od(   R7   (   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyR=   ł   s    c         C   s(   |    } x | D] } | | | <q W| S(   s   OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
        and values equal to v (which defaults to None).

        (    (   t   clst   iterableR   t   dR   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   fromkeysż   s    	c         C   sM   t  | t  r= t |   t |  k o< |  j   | j   k St j |  |  S(   s   od.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
        while comparison to a regular mapping is order-insensitive.

        (   R-   R   R   R(   R    t   __eq__(   R   R/   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyRD     s    .c         C   s   |  | k S(   N(    (   R   R/   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   __ne__  s    c         C   s
   t  |   S(   s@   od.viewkeys() -> a set-like object providing a view on od's keys(   R   (   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   viewkeys  s    c         C   s
   t  |   S(   s<   od.viewvalues() -> an object providing a view on od's values(   R   (   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt
   viewvalues  s    c         C   s
   t  |   S(   sB   od.viewitems() -> a set-like object providing a view on od's items(   R   (   R   (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt	   viewitems  s    N(#   R8   t
   __module__t   __doc__R   R    R   R   R   R   R   t   TrueR$   R&   R'   R(   R*   R   R,   R0   R   t   objectR1   R   R	   R4   R;   R?   R=   t   classmethodRC   RD   RE   RF   RG   RH   (    (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyR   +   s:   	
													
	
					N(   t   threadR    R6   t   ImportErrort   dummy_threadt   _abcollR   R   R   R    R   (    (    (    s4   /usr/lib/python2.7/dist-packages/gyp/ordered_dict.pyt   <module>    s    