σ
Ψ(Sc           @` s  d  d l  m Z d  d l  m Z d  d l  m Z d  d l  m Z d  d l m Z d  d l m Z d  d l	 Z	 y d  d l m
 Z
 Wn! e k
 r£ d  d l
 m
 Z
 n Xy d  d	 l m Z Wn! e k
 rΫ d  d	 l m Z n Xy d  d
 l m Z WnI e k
 r;y d  d
 l m Z Wq<e k
 r7d  d
 l m Z q<Xn Xd d  Z d e f d     YZ d e
 f d     YZ d   Z d e f d     YZ d S(   i    (   t   absolute_import(   t   division(   t   print_function(   t   unicode_literals(   t   ABCMeta(   t   MutableMappingN(   t   UserDict(   t   OrderedDict(   t	   get_identu   ...c         ` s     f d   } | S(   uG   Decorator to make a repr function return fillvalue for a recursive callc         ` sm   t          f d   } t  d  | _ t  d  | _ t  d  | _ t  d i   | _ | S(   Nc         ` sW   t  |   t   f } |  k r%   S j |  z  |   } Wd   j |  X| S(   N(   t   idR   t   addt   discard(   t   selft   keyt   result(   t	   fillvaluet   repr_runningt   user_function(    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   wrapper#   s    u
   __module__u   __doc__u   __name__u   __annotations__(   t   sett   getattrt
   __module__t   __doc__t   __name__t   __annotations__(   R   R   (   R   (   R   R   s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   decorating_function    s    	(    (   R   R   (    (   R   s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   recursive_repr   s    t   ChainMapc           B` sΕ   e  Z d  Z d   Z d   Z d   Z d d  Z d   Z d   Z	 d   Z
 e   d    Z e d	    Z d
   Z e Z d   Z e d    Z d   Z d   Z d   Z d   Z d   Z RS(   u±   A ChainMap groups multiple dicts (or other mappings) together
    to create a single, updateable view.

    The underlying mappings are stored in a list.  That list is public and can
    accessed or updated using the *maps* attribute.  There is no other state.

    Lookups search the underlying mappings successively until a key is found.
    In contrast, writes, updates, and deletions only operate on the first
    mapping.

    c         G` s   t  |  p i  g |  _ d S(   u   Initialize a ChainMap by setting *maps* to the given mappings.
        If no mappings are provided, a single empty dictionary is used.

        N(   t   listt   maps(   R   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __init__E   s    c         C` s   t  |   d  S(   N(   t   KeyError(   R   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __missing__L   s    c         C` sA   x1 |  j  D]& } y | | SWq
 t k
 r/ q
 Xq
 W|  j |  S(   N(   R   R   R    (   R   R   t   mapping(    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __getitem__O   s    c         C` s   | |  k r |  | S| S(   N(    (   R   R   t   default(    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   getW   s    c         C` s   t  t   j |  j    S(   N(   t   lenR   t   unionR   (   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __len__Z   s    c         C` s   t  t   j |  j    S(   N(   t   iterR   R&   R   (   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __iter__]   s    c         ` s   t    f d   |  j D  S(   Nc         3` s   |  ] }   | k Vq d  S(   N(    (   t   .0t   m(   R   (    s5   lib/python2.7/site-packages/singledispatch_helpers.pys	   <genexpr>a   s    (   t   anyR   (   R   R   (    (   R   s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __contains__`   s    c         C` s%   d j  |  d j t t |  j    S(   Nu   {0.__class__.__name__}({1})u   , (   t   formatt   joint   mapt   reprR   (   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __repr__c   s    c         G` s   |  t  j | |   S(   u?   Create a ChainMap with a single dict created from the iterable.(   t   dictt   fromkeys(   t   clst   iterablet   args(    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyR4   h   s    c         C` s$   |  j  |  j d j   |  j d  S(   uH   New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]i    i   (   t	   __class__R   t   copy(   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyR9   m   s    c         C` s   |  j  i  |  j  S(   u;   New ChainMap with a new dict followed by all previous maps.(   R8   R   (   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt	   new_childs   s    c         C` s   |  j  |  j d   S(   u   New ChainMap from maps[1:].i   (   R8   R   (   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   parentsw   s    c         C` s   | |  j  d | <d  S(   Ni    (   R   (   R   R   t   value(    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __setitem__|   s    c         C` s?   y |  j  d | =Wn& t k
 r: t d j |    n Xd  S(   Ni    u(   Key not found in the first mapping: {!r}(   R   R   R.   (   R   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   __delitem__   s    c         C` s9   y |  j  d j   SWn t k
 r4 t d   n Xd S(   uP   Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.i    u#   No keys found in the first mapping.N(   R   t   popitemR   (   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyR?      s    c         G` sH   y |  j  d j | |  SWn& t k
 rC t d j |    n Xd S(   uW   Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].i    u(   Key not found in the first mapping: {!r}N(   R   t   popR   R.   (   R   R   R7   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyR@      s    c         C` s   |  j  d j   d S(   u'   Clear maps[0], leaving maps[1:] intact.i    N(   R   t   clear(   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyRA      s    N(   R   R   R   R   R    R"   t   NoneR$   R'   R)   R-   R   R2   t   classmethodR4   R9   t   __copy__R:   t   propertyR;   R=   R>   R?   R@   RA   (    (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyR   8   s&   												t   MappingProxyTypec           B` s   e  Z d    Z RS(   c         C` s   t  j |   | |  _ d  S(   N(   R   R   t   data(   R   RG   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyR      s    (   R   R   R   (    (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyRF      s   c           C` s   t  j S(   N(   R   t   _abc_invalidation_counter(    (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   get_cache_token   s    t   Supportc           B` s   e  Z d    Z d   Z RS(   c         C` s   d  S(   N(    (   R   (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   dummy€   s    c         C` s   d t  j k r |  j S| S(   Nu   PyPy(   t   syst   versionRK   (   R   t   func(    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   cpython_only§   s    (   R   R   RK   RO   (    (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyRJ   £   s   	(   t
   __future__R    R   R   R   t   abcR   t   collectionsR   RL   R   t   ImportErrorR   t   ordereddictt   threadR   t   _threadt   _dummy_threadR   R   RF   RI   t   objectRJ   (    (    (    s5   lib/python2.7/site-packages/singledispatch_helpers.pyt   <module>   s4   `	