
    `?i\0                         d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm	Z	 d dl
Z
e j                  d        Z G d de      Z G d de      ZeZeZ G d	 d
      Z G d de      Zd Z G d d      Zy)    N)Counter)iscoroutinefunctionmarkcoroutinefunctionsync_to_asyncc                      	 t         j                  } t        j                  j                  |       fS # t        $ r Y yw xY w)N )django__file__AttributeErrorospathdirname)files    j/home/cursorai/projects/django-cronjob-utils/venv/lib/python3.12/site-packages/django/utils/deprecation.pydjango_file_prefixesr      s<     GGOOD!##  s   2 	>>c                       e Zd Zy)RemovedInDjango61WarningN__name__
__module____qualname__r       r   r   r          r   r   c                       e Zd Zy)RemovedInDjango70WarningNr   r   r   r   r   r      r   r   r   c                       e Zd Zd Zd Zy)warn_about_renamed_methodc                 <    || _         || _        || _        || _        y N)
class_nameold_method_namenew_method_namedeprecation_warning)selfr    r!   r"   r#   s        r   __init__z"warn_about_renamed_method.__init__"   s#     %..#6 r   c                       fd}|S )Nc            	          t        j                  dj                  dj                  dj                  dj
                  d        | i |S )N`.z` is deprecated, use `z
` instead.   )warningswarnr    r!   r"   r#   )argskwargsfr$   s     r   wrapperz3warn_about_renamed_method.__call__.<locals>.wrapper+   sJ    MM??D$8$8$:N:NP((	 d%f%%r   r   )r$   r/   r0   s   `` r   __call__z"warn_about_renamed_method.__call__*   s    	& r   N)r   r   r   r%   r1   r   r   r   r   r   !   s    7
r   r   c                   &     e Zd ZdZdZ fdZ xZS )RenameMethodsBasea#  
    Handles the deprecation paths when renaming a method.

    It does the following:
        1) Define the new method if missing and complain about it.
        2) Define the old method if missing.
        3) Complain whenever an old method is called.

    See #15363 for more details.
    r   c                    t         |   | |||      }t        j                  |      D ]  }|j                  }| j
                  D ]  }|d   }|j                  j                  |      }	|d   }
|j                  j                  |
      }|d   }t        |g| }|sC|	rAt        j                  d|d|d|
d|d       t        ||
|	       t        || ||	             |	r|st        || ||               |S )Nr      r*   r(   r)   z` method should be renamed `z`.)super__new__inspectgetmror   renamed_methods__dict__getr   r+   r,   setattr)clsnamebasesattrs	new_classbaser    renamed_methodr!   
old_methodr"   
new_methodr#   r0   	__class__s                 r   r7   zRenameMethodsBase.__new__E   s    GOCue<	NN9-DJ"%"5"5"0"3!]]..?
"0"3!]]..?
&4Q&7#3JPP "jMM%I+	 D/:>D/7:3FG "jD/7:3FG+ #6 .2 r   )r   r   r   __doc__r:   r7   __classcell__rG   s   @r   r3   r3   7   s    	 O r   r3   c                      fd}|S )a  
    Function/method decorator to deprecate some or all positional arguments.

    The decorated function will map any positional arguments after the ``*`` to
    the corresponding keyword arguments and issue a deprecation warning.

    The decorator takes two arguments: a RemovedInDjangoXXWarning warning
    category and a list of parameter names that have been changed from
    positional-or-keyword to keyword-only, in their original positional order.

    Works on both functions and methods. To apply to a class constructor,
    decorate its __init__() method. To apply to a staticmethod or classmethod,
    use @deprecate_posargs after @staticmethod or @classmethod.

    Example: to deprecate passing option1 or option2 as posargs, change::

        def some_func(request, option1, option2=True):
            ...

    to::

        @deprecate_posargs(RemovedInDjangoXXWarning, ["option1", "option2"])
        def some_func(request, *, option1, option2=True):
            ...

    After the deprecation period, remove the decorator (but keep the ``*``)::

        def some_func(request, *, option1, option2=True):
            ...

    Caution: during the deprecation period, do not add any new *positional*
    parameters or change the remaining ones. For example, this attempt to add a
    new param would break code using the deprecated posargs::

        @deprecate_posargs(RemovedInDjangoXXWarning, ["option1", "option2"])
        def some_func(request, wrong_new_param=None, *, option1, option2=True):
            # Broken: existing code may pass a value intended as option1 in the
            # wrong_new_param position.
            ...

    However, it's acceptable to add new *keyword-only* parameters and to
    re-order the existing ones, so long as the list passed to
    @deprecate_posargs is kept in the original posargs order. This change will
    work without breaking existing code::

        @deprecate_posargs(RemovedInDjangoXXWarning, ["option1", "option2"])
        def some_func(request, *, new_param=None, option2=True, option1):
            ...

    The @deprecate_posargs decorator adds a small amount of overhead. In most
    cases it won't be significant, but use with care in performance-critical
    code paths.
    c                    	
 t         t              rt        d      t         t              rt        d      t         t              rt        d      t        j                         j                  
t        d 
j                         D              }|t
        j                  j                     dkD  rt        d      |t
        j                  j                     |t
        j                  j                     z   |t
        j                  j                     }|dk  rt        d      t        
fd	D              rt        d
      t!              		z    j"                  dk(  r3 j$                  j'                  dd      d   }|j)                  dd      }|	fdt+               r!t-        j.                          fd       }|S t-        j.                          fd       }|S )NzS@deprecate_posargs cannot be applied to a class. (Apply it to the __init__ method.)z-Apply @classmethod before @deprecate_posargs.z.Apply @staticmethod before @deprecate_posargs.c              3   4   K   | ]  }|j                     y wr   )kind).0params     r   	<genexpr>z7deprecate_posargs.<locals>.decorator.<locals>.<genexpr>   s     FoUejjos   r   zE@deprecate_posargs() cannot be used with variable positional `*args`.r5   zm@deprecate_posargs() requires at least one keyword-only parameter (after a `*` entry in the parameters list).c              3   ~   K   | ]4  }|vxs* |   j                   t        j                  j                  k7   6 y wr   )rN   r8   	ParameterKEYWORD_ONLY)rO   r?   paramss     r   rQ   z7deprecate_posargs.<locals>.decorator.<locals>.<genexpr>   sA      
( U&,"3"3w7H7H7U7U"UU(s   :=zQ@deprecate_posargs() requires all remappable_names to be keyword-only parameters.r%   z	<locals>.z	.__init__ c           
        	 t        |       x}kD  rt         d d d| d      d|z
   }t        |      t        |      z  		r+dj                  	fd|D              }t         d| d	      t	        t        || d d
            }| d }||z  }dj                  d |D              }t        j                  d| d d
t                      ||fS )z
            Move deprecated positional args to kwargs and issue a warning.
            Return updated (args, kwargs).
            z() takes at most z# positional argument(s) (including z deprecated) but z were given.Nz, c              3   4   K   | ]  }|v sd | d   yw'Nr   )rO   r?   	conflictss     r   rQ   zVdeprecate_posargs.<locals>.decorator.<locals>.remap_deprecated_args.<locals>.<genexpr>   s$      *,:Ddi>OavQKNs   	zB() got both deprecated positional and keyword argument values for r)   T)strictc              3   (   K   | ]
  }d | d   ywrZ   r   )rO   r?   s     r   rQ   zVdeprecate_posargs.<locals>.decorator.<locals>.remap_deprecated_args.<locals>.<genexpr>   s     *R>4QtfA;>s   zPassing positional argument(s) z to z0() is deprecated. Use keyword arguments instead.)skip_file_prefixes)	len	TypeErrorsetjoindictzipr+   r,   r   )r-   r.   num_positional_argsremapped_namesconflicts_strremapped_kwargsremaining_argsupdated_kwargsremapped_names_strr\   r#   	func_namemax_positional_argsnum_positional_paramsnum_remappable_argsremappable_namess            @r   remap_deprecated_argszCdeprecate_posargs.<locals>.decorator.<locals>.remap_deprecated_args   sO   
 (+4y0#4GG k!23F2G H..A-BBS*+<9  .=%(==N N+c&k9I $		 *,:* !   k "++8/<  #ND)>)?$@NO ""8#89N#o5N "&*R>*R!RMM12D1ET) U@ @##7#9	 ">11r   c                  d   K   t        |       kD  r | |      \  } } | i | d {   S 7 wr   r`   r-   r.   funcro   rr   s     r   r0   z5deprecate_posargs.<locals>.decorator.<locals>.wrapper   s:     t944#8v#FLD&!4262222s   &0.0c                  H    t        |       kD  r | |      \  } } | i |S r   rt   ru   s     r   r0   z5deprecate_posargs.<locals>.decorator.<locals>.wrapper  s0    t944#8v#FLD&T,V,,r   )
isinstancetypera   classmethodstaticmethodr8   	signature
parametersr   valuesrS   VAR_POSITIONALPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORDrT   anyr`   r   r   rsplitreplacer   	functoolswraps)rv   num_by_kindnum_keyword_only_params
local_namer    r0   rm   rn   ro   rp   rU   rr   r#   rq   s   `     @@@@@@r   	decoratorz$deprecate_posargs.<locals>.decorator   s   dD!+  dK(KLLdL)LMM""4(33FfmmoFFw((7781<W 
 ))99:'++AABC 	 #.g.?.?.L.L"M"Q&>   
(
 
 + 
 ""2336IIMM	
" **11+qA"EJ#++K<J"I,	2 ,	2\ t$__T"3 #3  __T"- #-
 r   r   )r#   rq   r   s   `` r   deprecate_posargsr   d   s    nsj r   c                   8     e Zd ZdZdZ fdZd Zd Zd Z xZ	S )MiddlewareMixinTc                     |t        d      || _        t        | j                        | _        | j                  rt	        |        t
        |           y )Nzget_response must be provided.)
ValueErrorget_responser   
async_moder   r6   r%   )r$   r   rG   s     r   r%   zMiddlewareMixin.__init__  sM    =>>( .d.?.?@?? "$'r   c                     d| j                   j                  dt        | j                  d| j                  j                   j                        dS )N<z get_response=r   >)rG   r   getattrr   r   )r$   s    r   __repr__zMiddlewareMixin.__repr__$  sB    NN''!!!!++44
 	
r   c                     | j                   r| j                  |      S d }t        | d      r| j                  |      }|xs | j	                  |      }t        | d      r| j                  ||      }|S )Nprocess_requestprocess_response)r   	__acall__hasattrr   r   r   r$   requestresponses      r   r1   zMiddlewareMixin.__call__.  so    ??>>'**4*+++G4H9t0094+,,,Wh?Hr   c                   K   d}t        | d      r% t        | j                  d      |       d{   }|xs | j                  |       d{   }t        | d      r& t        | j                  d      ||       d{   }|S 7 U7 :7 
w)zh
        Async version of __call__ that is swapped in when an async request
        is running.
        Nr   T)thread_sensitiver   )r   r   r   r   r   r   s      r   r   zMiddlewareMixin.__acall__:  s     
 4*+]$$!%  H ?T%6%6w%??4+,]%%!% x! !H   @!s3   /BBBB	1B BB	BB)
r   r   r   sync_capableasync_capabler%   r   r1   r   rI   rJ   s   @r   r   r     s!    LM

r   r   )r   r8   r   r+   collectionsr   asgiref.syncr   r   r   r	   cacher   DeprecationWarningr   PendingDeprecationWarningr   RemovedInNextVersionWarningRemovedAfterNextVersionWarningr   ry   r3   r   r   r   r   r   <module>r      s      	   R R  $ $	1 		8 	 7 !9  ,* *Zl^8 8r   