Ñò
~(àKc           @   s   d  „  Z  d Z d Z e e d „ Z e e d „ Z d „  Z d e f d	 „  ƒ  YZ d
 „  Z d „  Z	 d „  Z
 d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   c            s   ‡  ‡ ‡ f d †  } | S(   Nc             s   ˆ ˆ  |  t  ˆ |  Ž  S(   N(   t   dict(   t   moreargst
   morekwargs(   t   argst   kwargst   _curried_func(    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   _curried6   s    (    (   R   R   R   R   (    (   R   R   R   sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   curry5   s    t
   __module__t   __name__t   __doc__t   __dict__c         C   s^   x' | D] } t  |  | t | | ƒ ƒ q Wx- | D]% } t |  | ƒ i t | | ƒ ƒ q1 W|  S(   s  Update a wrapper function to look like the wrapped function

       wrapper is the function to be updated
       wrapped is the original function
       assigned is a tuple naming the attributes assigned directly
       from the wrapped function to the wrapper function (defaults to
       functools.WRAPPER_ASSIGNMENTS)
       updated is a tuple naming the attributes off the wrapper that
       are updated with the corresponding attribute from the wrapped
       function (defaults to functools.WRAPPER_UPDATES)
    (   t   setattrt   getattrt   update(   t   wrappert   wrappedt   assignedt   updatedt   attr(    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   update_wrapperJ   s      #c         C   s   t  t d |  d | d | ƒS(   s‰  Decorator factory to apply update_wrapper() to a wrapper function

       Returns a decorator that invokes update_wrapper() with the decorated
       function as the wrapper argument and the arguments to wraps() as the
       remaining arguments. Default arguments are as for update_wrapper().
       This is a convenience function to simplify applying curry() to
       update_wrapper().
    R   R   R   (   R   R   (   R   R   R   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   wraps`   s    c            s%   ‡  ‡ ‡ f d †  } t  ˆ ƒ | ƒ S(   sè   
    Wrap a function so that results for any argument tuple are stored in
    'cache'. Note that the args to the function must be usable as dictionary
    keys.

    Only the first num_args are considered when creating the key.
    c             s:   |  ˆ  } | ˆ  j o	 ˆ  | Sˆ |  Œ  } | ˆ  | <| S(   N(    (   R   t   mem_argst   result(   t   cachet   num_argst   func(    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR   x   s    
	
(   R   (   R   R   R   R   (    (   R   R   R   sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   memoizep   s    t   Promisec           B   s   e  Z d  Z RS(   sš   
    This is just a base class for the proxy class created in
    the closure of the lazy function. It can be used to recognize
    promises in code.
    (   R	   R   R
   (    (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR      s   c            s>   d t  f ‡ ‡ f d †  ƒ  Y‰  ‡  f d †  } t ˆ ƒ | ƒ S(   s  
    Turns any callable into a lazy evaluated callable. You need to give result
    classes or types -- at least one is needed so that the automatic forcing of
    the lazy evaluation code is triggered. Results are not memoized; the
    function is evaluated on every access.
    t	   __proxy__c              s   e  Z d  Z d
 Z ‡ f d †  Z ‡  f d †  Z ‡  f d †  Z e e ƒ Z d „  Z	 e e	 ƒ Z	 d „  Z
 d „  Z d „  Z d „  Z d	 „  Z RS(   sÜ   
        Encapsulate a function call and act as a proxy for methods that are
        called on the result of that function. The function is not evaluated
        until one of the methods on the result is called.
        c            s=   ˆ  |  _  | |  _ | |  _ |  i d  j o |  i ƒ  n d  S(   N(   t   _proxy____funct   _proxy____argst   _proxy____kwt   _proxy____dispatcht   Nonet   __prepare_class__(   t   selfR   t   kw(   R   (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __init__™   s
    			c            s    t  |  i |  i |  i f ˆ  f S(   N(   t   _lazy_proxy_unpickleR   R   R    (   R$   (   t   resultclasses(    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt
   __reduce__    s    c            sø   h  |  _  xw ˆ  D]o } h  |  i  | <xY | i i ƒ  D]H \ } } |  i | | | ƒ } t |  | ƒ o q3 n t |  | | ƒ q3 Wq Wt ˆ  j |  _ t ˆ  j |  _	 |  i o |  i	 p
 t
 d ‚ |  i	 o |  i |  _ n |  i o |  i |  _ n d  S(   Ns:   Cannot call lazy() with both str and unicode return types.(   R!   R   t   itemst   __promise__t   hasattrR   t   strt   _delegate_strt   unicodet   _delegate_unicodet   AssertionErrort   _proxy____unicode_castt   __unicode__t   _proxy____str_castt   __str__(   t   clst   resultclasst   kt   vt   meth(   R(   (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR#   ¦   s"    	  

c            sE   ‡  f d †  } | |  i  j o h  |  i  | <n | |  i  | ˆ  <| S(   Nc            sq   |  i  |  i |  i Ž  } xF t | ƒ i ƒ  D]2 } | |  i j o |  i | ˆ  | | | Ž Sq+ Wt d ƒ ‚ d  S(   Ns%   Lazy object returned unexpected type.(   R   R   R    t   typet   mroR!   t	   TypeError(   R$   R   R%   t   rest   t(   t   funcname(    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __wrapper__¾   s      (   R!   (   R6   t   klassR@   R   RA   (    (   R@   sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR+   »   s
    	c         S   s   |  i  |  i |  i Ž  S(   N(   R   R   R    (   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __unicode_castÍ   s    c         S   s   t  |  i |  i |  i Ž  ƒ S(   N(   R-   R   R   R    (   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt
   __str_castÐ   s    c         S   s    |  i  o" t |  i |  i |  i Ž  ƒ } nE |  i o" t |  i |  i |  i Ž  ƒ } n |  i |  i |  i Ž  } t | t ƒ o t	 | | ƒ St	 | | ƒ Sd  S(   N(
   R.   R-   R   R   R    R0   R/   t
   isinstanceR   t   cmp(   R$   t   rhst   s(    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __cmp__Ó   s    
"
"c         S   sB   |  i  o t |  ƒ | S|  i o t |  ƒ | St d ƒ ‚ d  S(   Ns*   __mod__ not supported for non-string types(   R.   R-   R0   R/   R1   (   R$   RG   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __mod__ß   s
    

c         S   s   |  | t  |  ƒ <|  S(   N(   t   id(   R$   t   memo(    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __deepcopy__ç   s    N(   R	   R   R
   R"   R!   R&   R)   R#   t   classmethodR+   R2   R4   RI   RJ   RM   (    (   R(   R   (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR   ‘   s   					c             s   ˆ  |  | ƒ S(   N(    (   R   R%   (   R   (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyRA   î   s    (   R   R   (   R   R(   RA   (    (   R   R(   R   sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   lazy‰   s    ]c         G   s   t  |  | Œ | | Ž  S(   N(   RO   (   R   R   R   R(   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR'   ô   s    c            s"   ‡  ‡ f d †  } t  ˆ ƒ | ƒ S(   sú   
    A decorator that allows a function to be called with one or more lazy
    arguments. If none of the args are lazy, the function is evaluated
    immediately, otherwise a __proxy__ is returned that will evaluate the
    function when needed.
    c             sY   x@ t  |  ƒ | i ƒ  D] } t | t ƒ o Pq q Wˆ |  | Ž  St ˆ ˆ  Œ |  | Ž  S(   N(   t   listt   valuesRE   R   RO   (   R   R   t   arg(   R(   R   (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR   þ   s     	(   R   (   R   R(   R   (    (   R(   R   sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt
   allow_lazy÷   s    t
   LazyObjectc           B   sS   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z	 d „  Z
 RS(   s÷   
    A wrapper for another class that can be used to delay instantiation of the
    wrapped class.

    By subclassing, you have the opportunity to intercept and alter the
    instantiation. If you don't need to do that, use SimpleLazyObject.
    c         C   s   d  |  _ d  S(   N(   R"   t   _wrapped(   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR&     s    c         C   s.   |  i  d  j o |  i ƒ  n t |  i  | ƒ S(   N(   RU   R"   t   _setupR   (   R$   t   name(    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __getattr__  s    c         C   sS   | d j o | |  i  d <n2 |  i d  j o |  i ƒ  n t |  i | | ƒ d  S(   NRU   (   R   RU   R"   RV   R   (   R$   RW   t   value(    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __setattr__  s
    c         C   sO   | d j o t  d ƒ ‚ n |  i d  j o |  i ƒ  n t |  i | ƒ d  S(   NRU   s   can't delete _wrapped.(   R=   RU   R"   RV   t   delattr(   R$   RW   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __delattr__   s
    c         C   s
   t  ‚ d S(   sU   
        Must be implemented by subclasses to initialise the wrapped object.
        N(   t   NotImplementedError(   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyRV   '  s    c         C   s
   |  i  ƒ  S(    (   t   __dir__(   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   <lambda>.  s    c         C   s+   |  i  d  j o |  i ƒ  n t |  i  ƒ S(   N(   RU   R"   RV   t   dir(   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR^   0  s    (   R	   R   R
   R&   RX   RZ   R\   RV   t   propertyt   __members__R^   (    (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyRT     s   						t   SimpleLazyObjectc           B   sb   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z e e ƒ Z	 d „  Z
 d „  Z d „  Z RS(	   s·   
    A lazy object initialised from any function.

    Designed for compound objects of unknown type. For builtins or objects of
    known type, use django.utils.functional.lazy.
    c         C   s   | |  i  d <d |  _ d S(   sC  
        Pass in a callable that returns the object to be wrapped.

        If copies are made of the resulting SimpleLazyObject, which can happen
        in various circumstances within Django, then you must ensure that the
        callable can be safely run more than once and will return the same
        value.
        t
   _setupfuncN(   R   R"   RU   (   R$   R   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR&   <  s    	c         C   s+   |  i  d  j o |  i ƒ  n t |  i  ƒ S(   N(   RU   R"   RV   R-   (   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR5   J  s     c         C   s+   |  i  d  j o |  i ƒ  n t |  i  ƒ S(   N(   RU   R"   RV   R/   (   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyR3   N  s     c         C   sX   |  i  d  j o$ t |  i ƒ } | | t |  ƒ <| Sd d k l } | |  i  | ƒ Sd  S(   Niÿÿÿÿ(   t   deepcopy(   RU   R"   Rc   Rd   RK   t   django.utils.copycompatRe   (   R$   RL   R   Re   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyRM   R  s    c         C   s(   |  i  d  j o |  i ƒ  n |  i  i S(   N(   RU   R"   RV   t	   __class__(   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __get_classa  s     c         C   s+   |  i  d  j o |  i ƒ  n |  i  | j S(   N(   RU   R"   RV   (   R$   t   other(    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __eq__f  s     c         C   s+   |  i  d  j o |  i ƒ  n t |  i  ƒ S(   N(   RU   R"   RV   t   hash(   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   __hash__j  s     c         C   s   |  i  ƒ  |  _ d  S(   N(   Rd   RU   (   R$   (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyRV   n  s    (   R	   R   R
   R&   R5   R3   RM   t   _SimpleLazyObject__get_classRa   Rg   Rj   Rl   RV   (    (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyRc   5  s   							N(   s
   __module__s   __name__s   __doc__(   s   __dict__(   R   t   WRAPPER_ASSIGNMENTSt   WRAPPER_UPDATESR   R   R   t   objectR   RO   R'   RS   RT   Rc   (    (    (    sA   /usr/local/lib/python2.6/dist-packages/django/utils/functional.pyt   <module>5   s   			k		.