ó
Ý²k^c           @   sò   d  d l  Z  d  d l Z d d l m Z m Z m Z m Z m Z m Z d Z	 d „  Z
 d „  Z d „  Z e d „ Z e d „ Z e d „ Z e d „ Z e d „ Z e d „ Z e d „ Z d „  Z e d „ Z d e d „ Z d e d „ Z d S(    iÿÿÿÿNi   (   t   mapt   zipt	   iteritemst   iterkeyst
   itervaluest   reducet   merget
   merge_witht   valmapt   keymapt   itemmapt	   valfiltert	   keyfiltert
   itemfiltert   assoct   dissoct   assoc_int	   update_int   get_inc         C   sD   | j  d t ƒ } | r@ t d j |  j | j ƒ  d ƒ ƒ ‚ n  | S(   Nt   factorys.   {0}() got an unexpected keyword argument '{1}'i    (   t   popt   dictt	   TypeErrort   formatt   __name__t   popitem(   t   ft   kwargsR   (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyt   _get_factory
   s
    	c          O   sm   t  |  ƒ d k r3 t |  d t ƒ r3 |  d }  n  t t | ƒ } | ƒ  } x |  D] } | j | ƒ qR W| S(   sô    Merge a collection of dictionaries

    >>> merge({1: 'one'}, {2: 'two'})
    {1: 'one', 2: 'two'}

    Later dictionaries have precedence

    >>> merge({1: 2, 3: 4}, {3: 3, 4: 4})
    {1: 2, 3: 3, 4: 4}

    See Also:
        merge_with
    i   i    (   t   lent
   isinstanceR   R   R   t   update(   t   dictsR   R   t   rvt   d(    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR      s    &	c         O   s¶   t  | ƒ d k r3 t | d t ƒ r3 | d } n  t t | ƒ } | ƒ  } xX | D]P } xG t | ƒ D]9 \ } } | | k r | g | | <qe | | j | ƒ qe WqR Wt |  | | ƒ S(   s¦   Merge dictionaries and apply function to combined values

    A key may occur in more than one dict, and all values mapped from the key
    will be passed to the function as a list, such as func([val1, val2, ...]).

    >>> merge_with(sum, {1: 1, 2: 2}, {1: 10, 2: 20})
    {1: 11, 2: 22}

    >>> merge_with(first, {1: 1, 2: 2}, {2: 20, 3: 30})  # doctest: +SKIP
    {1: 1, 2: 2, 3: 30}

    See Also:
        merge
    i   i    (   R   R   R   R   R   R   t   appendR   (   t   funcR    R   R   t   resultR"   t   kt   v(    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   *   s    &	c         C   s8   | ƒ  } | j  t t | ƒ t |  t | ƒ ƒ ƒ ƒ | S(   sÞ    Apply function to values of dictionary

    >>> bills = {"Alice": [20, 15, 30], "Bob": [10, 35]}
    >>> valmap(sum, bills)  # doctest: +SKIP
    {'Alice': 65, 'Bob': 45}

    See Also:
        keymap
        itemmap
    (   R   R   R   R    R   (   R$   R"   R   R!   (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   G   s    	+c         C   s8   | ƒ  } | j  t t |  t | ƒ ƒ t | ƒ ƒ ƒ | S(   sò    Apply function to keys of dictionary

    >>> bills = {"Alice": [20, 15, 30], "Bob": [10, 35]}
    >>> keymap(str.lower, bills)  # doctest: +SKIP
    {'alice': [20, 15, 30], 'bob': [10, 35]}

    See Also:
        valmap
        itemmap
    (   R   R   R    R   R   (   R$   R"   R   R!   (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR	   W   s    	+c         C   s)   | ƒ  } | j  t |  t | ƒ ƒ ƒ | S(   sÜ    Apply function to items of dictionary

    >>> accountids = {"Alice": 10, "Bob": 20}
    >>> itemmap(reversed, accountids)  # doctest: +SKIP
    {10: "Alice", 20: "Bob"}

    See Also:
        keymap
        valmap
    (   R   R    R   (   R$   R"   R   R!   (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR
   g   s    	c         C   sC   | ƒ  } x3 t  | ƒ D]% \ } } |  | ƒ r | | | <q q W| S(   sæ    Filter items in dictionary by value

    >>> iseven = lambda x: x % 2 == 0
    >>> d = {1: 2, 2: 3, 3: 4, 4: 5}
    >>> valfilter(iseven, d)
    {1: 2, 3: 4}

    See Also:
        keyfilter
        itemfilter
        valmap
    (   R   (   t	   predicateR"   R   R!   R&   R'   (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   w   s
    	c         C   sC   | ƒ  } x3 t  | ƒ D]% \ } } |  | ƒ r | | | <q q W| S(   sä    Filter items in dictionary by key

    >>> iseven = lambda x: x % 2 == 0
    >>> d = {1: 2, 2: 3, 3: 4, 4: 5}
    >>> keyfilter(iseven, d)
    {2: 3, 4: 5}

    See Also:
        valfilter
        itemfilter
        keymap
    (   R   (   R(   R"   R   R!   R&   R'   (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   ‹   s
    	c         C   sI   | ƒ  } x9 t  | ƒ D]+ } |  | ƒ r | \ } } | | | <q q W| S(   s   Filter items in dictionary by item

    >>> def isvalid(item):
    ...     k, v = item
    ...     return k % 2 == 0 and v < 4

    >>> d = {1: 2, 2: 3, 3: 4, 4: 5}
    >>> itemfilter(isvalid, d)
    {2: 3}

    See Also:
        keyfilter
        valfilter
        itemmap
    (   R   (   R(   R"   R   R!   t   itemR&   R'   (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   Ÿ   s    	c         C   s&   | ƒ  } | | | <t  |  | d | ƒS(   sô    Return a new dict with new key value pair

    New dict has d[key] set to value. Does not modify the initial dictionary.

    >>> assoc({'x': 1}, 'x', 2)
    {'x': 2}
    >>> assoc({'x': 1}, 'y', 3)   # doctest: +SKIP
    {'x': 1, 'y': 3}
    R   (   R   (   R"   t   keyt   valueR   t   d2(    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   ·   s    
	
c         G   s:   t  j  |  ƒ } x$ | D] } | | k r | | =q q W| S(   sB   Return a new dict with the given key(s) removed.

    New dict has d[key] deleted for each supplied key.
    Does not modify the initial dictionary.

    >>> dissoc({'x': 1, 'y': 2}, 'y')
    {'x': 1}
    >>> dissoc({'x': 1, 'y': 2}, 'y', 'x')
    {}
    >>> dissoc({'x': 1}, 'y') # Ignores missing keys
    {'x': 1}
    (   t   copy(   R"   t   keysR,   R*   (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   Æ   s
    c            s   t  |  | ‡  f d †  ˆ  | ƒ S(   sê   Return a new dict with new, potentially nested, key value pair

    >>> purchase = {'name': 'Alice',
    ...             'order': {'items': ['Apple', 'Orange'],
    ...                       'costs': [0.50, 1.25]},
    ...             'credit card': '5555-1234-1234-1234'}
    >>> assoc_in(purchase, ['order', 'costs'], [0.25, 1.00]) # doctest: +SKIP
    {'credit card': '5555-1234-1234-1234',
     'name': 'Alice',
     'order': {'costs': [0.25, 1.00], 'items': ['Apple', 'Orange']}}
    c            s   ˆ  S(   N(    (   t   x(   R+   (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyt   <lambda>æ   s    (   R   (   R"   R.   R+   R   (    (   R+   s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   Ú   s    c      	   C   s°   t  | ƒ d k s t ‚ | d | d } } | rq t |  | t | |  k rU |  | n | ƒ  | | | | ƒ | ƒ S| |  k r | |  | ƒ n	 | | ƒ } t |  | | | ƒ Sd S(   s	   Update value in a (potentially) nested dictionary

    inputs:
    d - dictionary on which to operate
    keys - list or tuple giving the location of the value to be changed in d
    func - function to operate on that value

    If keys == [k0,..,kX] and d[k0]..[kX] == v, update_in returns a copy of the
    original dictionary with v replaced by func(v), but does not mutate the
    original dictionary.

    If k0 is not a key in d, update_in creates nested dictionaries to the depth
    specified by the keys, with the innermost value set to func(default).

    >>> inc = lambda x: x + 1
    >>> update_in({'a': 0}, ['a'], inc)
    {'a': 1}

    >>> transaction = {'name': 'Alice',
    ...                'purchase': {'items': ['Apple', 'Orange'],
    ...                             'costs': [0.50, 1.25]},
    ...                'credit card': '5555-1234-1234-1234'}
    >>> update_in(transaction, ['purchase', 'costs'], sum) # doctest: +SKIP
    {'credit card': '5555-1234-1234-1234',
     'name': 'Alice',
     'purchase': {'costs': 1.75, 'items': ['Apple', 'Orange']}}

    >>> # updating a value when k0 is not in d
    >>> update_in({}, [1, 2, 3], str, default="bar")
    {1: {2: {3: 'bar'}}}
    >>> update_in({1: 'foo'}, [2, 3, 4], inc, 0)
    {1: 'foo', 2: {3: {4: 1}}}
    i    i   N(   R   t   AssertionErrorR   R   (   R"   R.   R$   t   defaultR   R&   t   kst	   innermost(    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR   é   s    "((c         C   sE   y t  t j |  | ƒ SWn' t t t f k
 r@ | r< ‚  n  | SXd S(   s4   Returns coll[i0][i1]...[iX] where [i0, i1, ..., iX]==keys.

    If coll[i0][i1]...[iX] cannot be found, returns ``default``, unless
    ``no_default`` is specified, then it raises KeyError or IndexError.

    ``get_in`` is a generalization of ``operator.getitem`` for nested data
    structures such as dictionaries and lists.

    >>> transaction = {'name': 'Alice',
    ...                'purchase': {'items': ['Apple', 'Orange'],
    ...                             'costs': [0.50, 1.25]},
    ...                'credit card': '5555-1234-1234-1234'}
    >>> get_in(['purchase', 'items', 0], transaction)
    'Apple'
    >>> get_in(['name'], transaction)
    'Alice'
    >>> get_in(['purchase', 'total'], transaction)
    >>> get_in(['purchase', 'items', 'apple'], transaction)
    >>> get_in(['purchase', 'items', 10], transaction)
    >>> get_in(['purchase', 'total'], transaction, 0)
    0
    >>> get_in(['y'], {}, no_default=True)
    Traceback (most recent call last):
        ...
    KeyError: 'y'

    See Also:
        itertoolz.get
        operator.getitem
    N(   R   t   operatort   getitemt   KeyErrort
   IndexErrorR   (   R.   t   collR2   t
   no_default(    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyR     s    (   R   R   R   R	   R
   R   R   R   R   R   R   R   R   (   R-   R5   t   compatibilityR    R   R   R   R   R   t   __all__R   R   R   R   R   R	   R
   R   R   R   R   R   R   t   NoneR   t   FalseR   (    (    (    s<   lib/python2.7/site-packages/conda/_vendor/toolz/dicttoolz.pyt   <module>   s&   .  				-