ó
jë\c           @  s<   d  d l  m Z d e f d     YZ d   Z d   Z d S(   i˙˙˙˙(   t   print_functiont   Curryc           B  sJ   e  Z d  Z d Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   s¤   
    Stores a callable and some arguments. When called, calls the
    callable with the stored arguments and the additional arguments
    supplied to the call.
    c         O  s7   | |  _  | |  _ | |  _ t |  j  d d   |  _ d  S(   Nt   __doc__(   t   callablet   argst   kwargst   getattrt   NoneR   (   t   selfR   R   R   (    (    s   renpy/curry.pyt   __init__#   s    			c         O  s0   |  j  |  j | t |  j j   | j      S(   N(   R   R   t   dictR   t   items(   R   R   R   (    (    s   renpy/curry.pyt   __call__)   s    c         C  s   d |  j  |  j |  j f S(   Ns   <curry %s %r %r>(   R   R   R   (   R   (    (    s   renpy/curry.pyt   __repr__-   s    c         C  sC   t  | t  oB |  j | j k oB |  j | j k oB |  j | j k S(   N(   t
   isinstanceR   R   R   R   (   R   t   other(    (    s   renpy/curry.pyt   __eq__0   s    c         C  s   |  | k S(   N(    (   R   R   (    (    s   renpy/curry.pyt   __ne__8   s    c         C  sm   |  j  d  k rf |  j  t  |  j  t  |  j  AN_  x/ |  j j   D] } |  j  t  |  N_  qD Wn  |  j  S(   N(   t   hashR   R   R   R   R   (   R   t   i(    (    s   renpy/curry.pyt   __hash__;   s
    %N(   t   __name__t
   __module__R   R   R   R	   R   R   R   R   R   (    (    (    s   renpy/curry.pyR      s   					c         C  s(   t  t  |   } t |  d d  | _ | S(   sü   
    Takes a callable, and returns something that, when called, returns
    something that when called again, calls the function. So
    basically, the thing returned from here when called twice does the
    same thing as the function called once.
    R   N(   R   R   R   R   (   t   fnt   rv(    (    s   renpy/curry.pyt   curryF   s    c         O  s   t  |  | |  S(   sÜ   
    Stores the arguments and keyword arguments of function, and
    returns something that, when called, calls the function with
    a combination of the supplied arguments and the arguments of
    the second call.
    (   R   (   t   functionR   R   (    (    s   renpy/curry.pyt   partialS   s    N(   t
   __future__R    t   objectR   R   R   (    (    (    s   renpy/curry.pyt   <module>   s   ,	