
\c           @` s   d  Z  d d l m Z m Z m Z d d l Z d d l m Z d d l m	 Z	 e	 j	 Z
 e j   Z d   Z d d d d  Z d	 e f d
     YZ d S(   s$   
Control global computation context
i    (   t   absolute_importt   divisiont   print_functionN(   t   partiali   (   t   configc          O` s   t  d   d S(   s)    Deprecated: see dask.config.set instead s   The dask.set_options function has been deprecated.
Please use dask.config.set instead

  Before: with dask.set_options(foo='bar'):
              ...
  After:  with dask.config.set(foo='bar'):
              ...N(   t	   TypeError(   t   argst   kwargs(    (    s+   lib/python2.7/site-packages/dask/context.pyt   set_options   s    c         C` s;   |  d k r" t t d | d | St d |  d | d |  S(   s   Allow function to be taken over by globals

    This modifies a method so that occurrences of it may be taken over by
    functions registered in the global options. Can be used as a decorator or a
    function.

    Parameters
    ----------
    default : callable
        The default callable to use.
    key : str
        Key under which we register this function in the global parameters
    falsey : callable, None, optional
        A function to use if the option is falsey. If not provided, the default
        is used instead.

    Examples
    --------
    >>> import dask
    >>> class Foo(object):
    ...     @globalmethod(key='bar', falsey=lambda: 3)
    ...     def bar():
    ...         return 1
    >>> f = Foo()
    >>> f.bar()
    1
    >>> with dask.config.set(bar=lambda: 2):
    ...     print(f.bar())
    2
    >>> with dask.config.set(bar=False):
    ...     print(f.bar())
    3
    t   keyt   falseyt   defaultN(   t   NoneR   t   globalmethodt   GlobalMethod(   R   R	   R
   (    (    s+   lib/python2.7/site-packages/dask/context.pyR      s    "R   c           B` s    e  Z d d   Z d d  Z RS(   c         C` s   | |  _  | |  _ | |  _ d  S(   N(   t   _defaultt   _keyt   _falsey(   t   selfR   R	   R
   (    (    s+   lib/python2.7/site-packages/dask/context.pyt   __init__B   s    		c         C` sG   |  j  t k r@ t |  j  r' t |  j  S|  j d  k	 r@ |  j Sn  |  j S(   N(   R   t   _globalsR   R   R   (   R   t   instancet   owner(    (    s+   lib/python2.7/site-packages/dask/context.pyt   __get__G   s    
N(   t   __name__t
   __module__R   R   R   (    (    (    s+   lib/python2.7/site-packages/dask/context.pyR   A   s   (   t   __doc__t
   __future__R    R   R   t	   threadingt	   functoolsR   t    R   R   t   localt   thread_stateR   R   R   t   objectR   (    (    (    s+   lib/python2.7/site-packages/dask/context.pyt   <module>   s   		
'