ó
P'^c           @   s3   d  Z  d d l m Z d 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	   DictMixint   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(    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/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(    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/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(    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/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(    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/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   (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt   __iter__&   s
    	
	c         c   s=   |  j  } | d } x# | | k	 r8 | d V| d } q Wd  S(   Ni   i    (   R   (   R   R   R   (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt   __reversed__-   s
    	
	c         C   sX   |  s t  d   n  | r- t |   j   n t |   j   } |  j |  } | | f S(   Ns   dictionary is empty(   t   KeyErrort   reversedR   t   iterR   (   R   t   lastR   R   (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt   popitem4   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(    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt
   __reduce__;   s    #c         C   s
   t  |   S(   N(   t   list(   R   (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt   keysE   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   (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt   __repr__Q   s    c         C   s   |  j  |   S(   N(   R!   (   R   (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyR    V   s    c         C   s(   |    } x | D] } | | | <q W| S(   N(    (   t   clst   iterableR   t   dR   (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt   fromkeysY   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(    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pys	   <genexpr>c   s    (   t
   isinstanceR   R   t   allt   zipR#   R   t   __eq__(   R   t   other(    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyR5   `   s    )c         C   s   |  | k S(   N(    (   R   R6   (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt   __ne__f   s    N(   R)   t
   __module__R   R   R   R   R   R   t   TrueR   R&   R(   R    t
   setdefaultR   R   t   valuesR#   t   iterkeyst
   itervaluest	   iteritemsR*   R    t   classmethodR   R.   R5   R7   (    (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyR      s.   								
												N(   t   __doc__t   UserDictR    R   R   (    (    (    s9   /tmp/pip-unpacked-wheel-9xjeDh/simplejson/ordered_dict.pyt   <module>   s   