ó
ìUzMc           @   sX   d  Z  d d l m Z y e Wn e k
 r: d „  Z n Xd e e f d „  ƒ  YZ d S(   ss   Drop-in replacement for collections.OrderedDict by Raymond Hettinger

http://code.activestate.com/recipes/576693/

iÿÿÿÿ(   t	   DictMixinc         C   s   x |  D] } | s t  Sq Wt S(   N(   t   Falset   True(   t   seqt   elem(    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   all   s    t   OrderedDictc           B   sÚ   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z	 d „  Z
 d „  Z e j Z e j Z e j Z e j Z e j Z e j Z e j Z e j Z d	 „  Z d
 „  Z e d d „ ƒ Z d „  Z d „  Z RS(   c         O   sh   t  | ƒ d k r+ t d t  | ƒ ƒ ‚ n  y |  j Wn t k
 rS |  j ƒ  n X|  j | | Ž  d  S(   Ni   s$   expected at most 1 arguments, got %d(   t   lent	   TypeErrort   _OrderedDict__endt   AttributeErrort   cleart   update(   t   selft   argst   kwds(    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   __init__   s    c         C   s:   g  |  _  } | d  | | g 7} i  |  _ t j |  ƒ d  S(   N(   R	   t   Nonet   _OrderedDict__mapt   dictR   (   R   t   end(    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyR      s    	c         C   s_   | |  k rH |  j  } | d } | | | g | d <| d <|  j | <n  t j |  | | ƒ d  S(   Ni   i   (   R	   R   R   t   __setitem__(   R   t   keyt   valueR   t   curr(    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyR   $   s
    	
)c         C   sC   t  j |  | ƒ |  j j | ƒ \ } } } | | d <| | d <d  S(   Ni   i   (   R   t   __delitem__R   t   pop(   R   R   t   prevt   next(    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyR   +   s    
c         c   s=   |  j  } | d } x# | | k	 r8 | d V| d } q Wd  S(   Ni   i    (   R	   (   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   __iter__1   s
    	
	c         c   s=   |  j  } | d } x# | | k	 r8 | d V| d } q Wd  S(   Ni   i    (   R	   (   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   __reversed__8   s
    	
	c         C   s[   |  s t  d ƒ ‚ n  | r0 t |  ƒ j ƒ  } n t |  ƒ j ƒ  } |  j | ƒ } | | f S(   Ns   dictionary is empty(   t   KeyErrort   reversedR   t   iterR   (   R   t   lastR   R   (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   popitem?   s    c         C   sŽ   g  |  D] } | |  | g ^ q } |  j  |  j f } |  `  |  ` t |  ƒ j ƒ  } | \ |  _  |  _ | r~ |  j | f | f S|  j | f f S(   N(   R   R	   t   varst   copyt	   __class__(   R   t   kt   itemst   tmpt	   inst_dict(    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt
   __reduce__K   s    #c         C   s
   t  |  ƒ S(   N(   t   list(   R   (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   keysU   s    c         C   s1   |  s d |  j  j f Sd |  j  j |  j ƒ  f S(   Ns   %s()s   %s(%r)(   R&   t   __name__R(   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   __repr__a   s    c         C   s   |  j  |  ƒ S(   N(   R&   (   R   (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyR%   f   s    c         C   s(   |  ƒ  } x | D] } | | | <q W| S(   N(    (   t   clst   iterableR   t   dR   (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   fromkeysi   s    	c         C   s`   t  | t ƒ rP t |  ƒ t | ƒ k oO t d „  t |  j ƒ  | j ƒ  ƒ Dƒ ƒ St j |  | ƒ S(   Nc         s   s!   |  ] \ } } | | k Vq d  S(   N(    (   t   .0t   pt   q(    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pys	   <genexpr>s   s    (   t
   isinstanceR   R   R   t   zipR(   R   t   __eq__(   R   t   other(    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyR9   p   s    )c         C   s   |  | k S(   N(    (   R   R:   (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   __ne__v   s    N(   R.   t
   __module__R   R   R   R   R   R   R   R#   R+   R-   R    t
   setdefaultR   R   t   valuesR(   t   iterkeyst
   itervaluest	   iteritemsR/   R%   t   classmethodR   R3   R9   R;   (    (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyR      s.   								
												N(   t   __doc__t   UserDictR    R   t	   NameErrorR   R   (    (    (    s;   /usr/lib/python2.7/dist-packages/simplejson/ordered_dict.pyt   <module>   s   