
    Evg8                         d dl Z d dlZd dlZd dlmZ  G d d          Z G d d          Z G d d          Zd	 Zd
 Z	d Z
d Zd Z e            Zd Z G d d          Zd Z G d de          Zd ZdS )    N)wrapsc                   @    e Zd ZdZdZed             Zd Zd ZddZ	dS )cached_propertyz
    Decorator that converts a method with a single self argument into a
    property cached on the instance.

    A cached property can be made out of an existing method:
    (e.g. ``url = cached_property(get_absolute_url)``).
    Nc                      t          d          )NzICannot use cached_property instance without calling __set_name__() on it.	TypeError)instances    T/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/utils/functional.pyfunczcached_property.func   s    $
 
 	
    c                 >    || _         t          |d          | _        d S )N__doc__)	real_funcgetattrr   selfr   s     r
   __init__zcached_property.__init__   s    tY//r   c                     | j         || _         | j        | _        d S || j         k    rt          d| j         d|d          d S )Nz?Cannot assign the same cached_property to two different names (z and z).)namer   r   r   )r   ownerr   s      r
   __set_name__zcached_property.__set_name__   s[    9DIDIIITY)"&)))TTT3   r   c                 V    || S |                      |          x}|j        | j        <   |S )z
        Call the function and put the return value in instance.__dict__ so that
        subsequent attribute access on the instance returns the cached value
        instead of calling cached_property.__get__().
        )r   __dict__r   )r   r	   clsress       r
   __get__zcached_property.__get__'   s4     K-1YYx-@-@@h	*
r   N)
__name__
__module____qualname__r   r   staticmethodr   r   r   r    r   r
   r   r      sp          D
 
 \
0 0 0  	 	 	 	 	 	r   r   c                   (    e Zd ZdZddZddZd ZdS )classpropertyz
    Decorator that converts a method with a single cls argument into a property
    that can be accessed directly from the class.
    Nc                     || _         d S r   fgetr   methods     r
   r   zclassproperty.__init__9   s    			r   c                 ,    |                      |          S r   r&   )r   r	   r   s      r
   r   zclassproperty.__get__<   s    yy~~r   c                     || _         | S r   r&   r(   s     r
   getterzclassproperty.getter?   s    	r   r   )r   r   r    r   r   r   r,   r"   r   r
   r$   r$   3   sU         
          r   r$   c                       e Zd ZdZdS )Promisez
    Base class for the proxy class created in the closure of the lazy function.
    It's used to recognize promises in code.
    N)r   r   r    r   r"   r   r
   r.   r.   D   s         
 	Dr   r.   c                      G  fddt                     D ]M}|                                D ]6}|j        D ],}t          |          r|d fd
}t	          ||           -7Nt                     fd            }|S )a  
    Turn any callable into a lazy evaluated callable. result classes or types
    is required -- 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.
    c                       e Zd ZdZd Z fdZd Z fdZd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )lazy.<locals>.__proxy__z
        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                 "    || _         || _        d S r   _args_kw)r   argskws      r
   r   z lazy.<locals>.__proxy__.__init__\   s    DJDHHHr   c                 6    t           | j        | j        fz   fS r   )_lazy_proxy_unpickler4   r5   )r   r   resultclassess    r
   
__reduce__z"lazy.<locals>.__proxy__.__reduce__`   s#    $tz48,}< r   c                 *    | |t          |           <   | S r   )id)r   memos     r
   __deepcopy__z$lazy.<locals>.__proxy__.__deepcopy__f   s     "DDNKr   c                 (     | j         i | j        S r   r3   r   s    r
   __castzlazy.<locals>.__proxy__.__castm   s    40tx000r   c                 D    t          |                                           S r   )repr_proxy____castr   s    r
   __repr__z lazy.<locals>.__proxy__.__repr__s       &&&r   c                 D    t          |                                           S r   )strrD   rE   s    r
   __str__zlazy.<locals>.__proxy__.__str__v   s    t{{}}%%%r   c                     t          |t                    r|                                }|                                 |k    S r   
isinstancer.   rD   r   others     r
   __eq__zlazy.<locals>.__proxy__.__eq__y   4    %)) ';;==E))r   c                     t          |t                    r|                                }|                                 |k    S r   rL   rN   s     r
   __ne__zlazy.<locals>.__proxy__.__ne__~   rQ   r   c                     t          |t                    r|                                }|                                 |k     S r   rL   rN   s     r
   __lt__zlazy.<locals>.__proxy__.__lt__   4    %)) ';;==5((r   c                     t          |t                    r|                                }|                                 |k    S r   rL   rN   s     r
   __le__zlazy.<locals>.__proxy__.__le__   rQ   r   c                     t          |t                    r|                                }|                                 |k    S r   rL   rN   s     r
   __gt__zlazy.<locals>.__proxy__.__gt__   rV   r   c                     t          |t                    r|                                }|                                 |k    S r   rL   rN   s     r
   __ge__zlazy.<locals>.__proxy__.__ge__   rQ   r   c                 D    t          |                                           S r   )hashrD   rE   s    r
   __hash__z lazy.<locals>.__proxy__.__hash__   rG   r   c                 F    t          |                                 |          S r   )formatrD   )r   format_specs     r
   
__format__z"lazy.<locals>.__proxy__.__format__   s    $++--555r   c                 0    |                                  |z   S r   rD   rN   s     r
   __add__zlazy.<locals>.__proxy__.__add__       ;;==5((r   c                 0    ||                                  z   S r   re   rN   s     r
   __radd__z lazy.<locals>.__proxy__.__radd__   s    4;;==((r   c                 0    |                                  |z  S r   re   rN   s     r
   __mod__zlazy.<locals>.__proxy__.__mod__   rg   r   c                 0    |                                  |z  S r   re   rN   s     r
   __mul__zlazy.<locals>.__proxy__.__mul__   rg   r   N)r   r   r    r   r   r;   r?   rD   rF   rJ   rP   rS   rU   rX   rZ   r\   r_   rc   rf   ri   rk   rm   )r   r:   s   r
   	__proxy__r1   U   sF       	 		 	 		 	 	 	 	 		 	 		1 	1 	1 	1 	1	' 	' 	'	& 	& 	&	* 	* 	*
	* 	* 	*
	) 	) 	)
	* 	* 	*
	) 	) 	)
	* 	* 	*
	' 	' 	'	6 	6 	6	) 	) 	)	) 	) 	)	) 	) 	)	) 	) 	) 	) 	)r   rn   )__method_namec                T     | j         i | j        } t          ||          |i |S r   )r4   r5   r   )r   ro   r6   r7   resultr   s        r
   __wrapper__zlazy.<locals>.__wrapper__   s<     "T4::::F976=994F2FFFr   c                       | |          S r   r"   )r6   r7   rn   s     r
   rr   zlazy.<locals>.__wrapper__   s     yr"""r   )r.   mror   hasattrsetattrr   )r   r:   resultclasstype_method_namerr   rn   s   ``    @r
   lazyrz   M   s    U) U) U) U) U) U) U) U)G U) U) U)r % = = __&& 	= 	=E$~ = = 9k22  <G G G G G G G G 	;<<<<=	=" 4[[# # # # [# r   c                 (     t          | g|R  |i |S r   )rz   )r   r6   kwargsr:   s       r
   r9   r9      s'    %4%}%%%t6v666r   c                 H     t          t          t                    |           S )zK
    Shortcut for the common case of a lazy callable that returns str.
    )rz   rI   )texts    r
   lazystrr      s     4S>>$r   c                  4      st          d           fd}|S )z
    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.
    z3You must pass at least one argument to keep_lazy().c                 \     t           gR  t                      fd            }|S )Nc                      t          d t          j        | |                                          D                       r | i |S  | i |S )Nc              3   @   K   | ]}t          |t                    V  d S r   )rM   r.   ).0args     r
   	<genexpr>z@keep_lazy.<locals>.decorator.<locals>.wrapper.<locals>.<genexpr>   s@         3((     r   )any	itertoolschainvalues)r6   r|   r   	lazy_funcs     r
   wrapperz-keep_lazy.<locals>.decorator.<locals>.wrapper   sq      $?4AA     2 !y$1&1114((((r   )rz   r   )r   r   r   r:   s   ` @r
   	decoratorzkeep_lazy.<locals>.decorator   sO    ....		t	) 	) 	) 	) 	) 
	) r   r   )r:   r   s   ` r
   	keep_lazyr      s>      OMNNN     r   c                 <     t          t                    |           S )zO
    A decorator for functions that accept lazy arguments and return text.
    )r   rI   )r   s    r
   keep_lazy_textr      s     9S>>$r   c                        fd}d|_         |S )Nc                 l    | j         x}t          u r|                                  | j         } |g|R  S r   )_wrappedempty_setup)r   r6   r   r   s      r
   innerznew_method_proxy.<locals>.inner   sA    %H%//KKMMM}HtH$t$$$$r   F)_mask_wrapped)r   r   s   ` r
   new_method_proxyr      s+    % % % % %  ELr   c                   D    e Zd ZdZdZd Z fdZ ee          Z	d Z
d Zd Zd Zd	 Zd
 Z ee          Z ee          Z ee          Z ee          Z e e ej        d                              Z eej                  Z eej                  Z eej                   Z! eej"                  Z# ee$          Z% eej&                  Z' eej(                  Z) eej*                  Z+ ee,          Z- ee.          Z/ eej0                  Z1 xZ2S )
LazyObjectz
    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.
    Nc                     t           | _        d S r   )r   r   rE   s    r
   r   zLazyObject.__init__  s     r   c                     |dk    r!t                                          |          S t                                          |          }t          |dd          st          |S )Nr   r   T)super__getattribute__r   AttributeError)r   r   value	__class__s      r
   r   zLazyObject.__getattribute__  s^    :77++D111((.. uot44 	!  r   c                     |dk    r|| j         d<   d S | j        t          u r|                                  t	          | j        ||           d S )Nr   )r   r   r   r   rv   )r   r   r   s      r
   __setattr__zLazyObject.__setattr__!  sS    :(-DM*%%%}%%DM4/////r   c                     |dk    rt          d          | j        t          u r|                                  t	          | j        |           d S )Nr   zcan't delete _wrapped.)r   r   r   r   delattr)r   r   s     r
   __delattr__zLazyObject.__delattr__*  sN    :4555=E!!KKMMMt$$$$$r   c                      t          d          )zU
        Must be implemented by subclasses to initialize the wrapped object.
        z7subclasses of LazyObject must provide a _setup() method)NotImplementedErrorrE   s    r
   r   zLazyObject._setup1  s     "E
 
 	
r   c                 d    | j         t          u r|                                  t          | j         ffS r   )r   r   r   unpickle_lazyobjectrE   s    r
   r;   zLazyObject.__reduce__G  s,    =E!!KKMMM#dm%566r   c                 ~    | j         t          u r t          |                       S t          j        | j                   S r   )r   r   typecopyrE   s    r
   __copy__zLazyObject.__copy__L  s7    =E!! 4::<< 9T]+++r   c                     | j         t          u r+ t          |                       }||t          |           <   |S t	          j        | j         |          S r   )r   r   r   r=   r   deepcopyr   r>   rq   s      r
   r?   zLazyObject.__deepcopy__U  sJ    =E!!  T$ZZ\\F#DDNM}T]D111r   r   )3r   r   r    r   r   r   r   r   r   __getattr__r   r   r   r;   r   r?   bytes	__bytes__rI   rJ   bool__bool__dir__dir__propertyoperator
attrgetterr   eqrP   ltrU   gtrZ   nerS   r^   r_   getitem__getitem__setitem__setitem__delitem__delitem__iter__iter__len__len__contains__contains____classcell__r   s   @r
   r   r     s         H  
	 	 	 	 	 #"7++K0 0 0% % %
 
 
,7 7 7
, , ,2 2 2 ! ''Is##G%%H s##G ))*=(*=k*J*JKKLLIhk**Fhk**Fhk**Fhk**F%%H #"8#344K""8#344K""8#344K%%Hs##G##H$566LLLLLr   r   c                     | S )zh
    Used to unpickle lazy objects. Just return its argument, which will be the
    wrapped object.
    r"   )wrappeds    r
   r   r   w  s	    
 Nr   c                   p     e Zd ZdZ fdZd Zd Zd Zd Z e	e
j                  Ze	d             Z xZS )SimpleLazyObjectz
    A lazy object initialized from any function.

    Designed for compound objects of unknown type. For builtins or objects of
    known type, use django.utils.functional.lazy.
    c                 \    || j         d<   t                                                       dS )aC  
        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.
        
_setupfuncN)r   r   r   )r   r   r   s     r
   r   zSimpleLazyObject.__init__  s-     '+l#r   c                 8    |                                  | _        d S r   )r   r   rE   s    r
   r   zSimpleLazyObject._setup  s    ))r   c                 r    | j         t          u r| j        }n| j         }dt          |           j        d|dS )N<z: >)r   r   r   r   r   )r   	repr_attrs     r
   rF   zSimpleLazyObject.__repr__  s>    =E!!III!$ZZ000)))<<r   c                 x    | j         t          u rt          | j                  S t	          j        | j                   S r   )r   r   r   r   r   rE   s    r
   r   zSimpleLazyObject.__copy__  s5    =E!! $DO444 9T]+++r   c                     | j         t          u r(t          | j                  }||t	          |           <   |S t          j        | j         |          S r   )r   r   r   r   r=   r   r   r   s      r
   r?   zSimpleLazyObject.__deepcopy__  sH    =E!! &do66F#DDNM}T]D111r   c                     || z   S r   r"   rN   s     r
   ri   zSimpleLazyObject.__radd__  s    t|r   )r   r   r    r   r   r   rF   r   r?   r   r   addrf   ri   r   r   s   @r
   r   r     s         
 
 
 
 
* * *
= = =, , ,2 2 2 x|,,G      r   r   c                 `    g g f}|D ]&}| | |                                        |           '|S )z
    Split the values into two sets, based on the return value of the function
    (True/False). e.g.:

        >>> partition(lambda x: x > 3, range(5))
        [0, 1, 2, 3], [4]
    )append)	predicater   resultsitems       r
   	partitionr     sE     2hG . .		$ ''----Nr   )r   r   r   	functoolsr   r   r$   r.   rz   r9   r   r   r   objectr   r   r   r   r   r   r"   r   r
   <module>r      s              ) ) ) ) ) ) ) )X       "	 	 	 	 	 	 	 	x x xv7 7 7       6      	  q7 q7 q7 q7 q7 q7 q7 q7h  6 6 6 6 6z 6 6 6r    r   