
    	h#                       d Z ddlmZ ddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZ ddlZddlmZ ddlmZmZmZmZ d-d
Z e            Zd.dZd/dZ ede          Zd0dZej        d1d            Z G d d          Z ej                    Zd2dZd3dZ d4d$Z!e!Z"d.d%Z#d5d'Z$d6d)Z%ej        d7d+            Z&d2d,Z'dS )8z
**Deprecated** primitives to keep context global but thread (and greenlet)
local.

See `thread-local`, but please use :doc:`contextvars` instead.

.. deprecated:: 22.1.0
    )annotationsN)Any	GeneratorIteratorTypeVar   )BoundLoggerLazyProxy)BindableLoggerContext	EventDictWrappedLoggerreturn	type[Any]c                 F    	 ddl m}  n# t          $ r ddlm} |cY S w xY w| S )zg
    Return a dict-like threadlocal storage depending on whether we run with
    greenlets or not.
    r   )GreenThreadLocalr   )local)
_greenletsr   ImportError	threadingr   )r   r   s     b/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/structlog/threadlocal.py_determine_threadlocalr      sZ    
0000000   ######
 s   	 Nonec                 "   d} t          j        t                    5  t          j                    }|j        j        j        d         } ddd           n# 1 swxY w Y   | dk    rdS d}| dk    r|dz  }t          j        dt          |	           dS )
zA
    Raise a warning with best-effort stacklevel adjustment.
     __name__Nzstructlog.threadlocal   
contextlib   zR`structlog.threadlocal` is deprecated, please use `structlog.contextvars` instead.)
stacklevel)
r   suppress	Exceptionsys	_getframef_back	f_globalswarningswarnDeprecationWarning)callsitefr   s      r   _deprecatedr+   1   s     H		Y	'	' 
 
MOO8?,

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ***J <a
M	+	     s   +AAA
dict_classtype[Context]c                    t                       t          dt          t          j                              z   t
          fi           }t                      |_        | |_        |S )z
    Wrap a dict-like class and return the resulting class.

    The wrapped class and used to keep global in the current thread.

    Arguments:

        dict_class: Class used for keeping context.

    .. deprecated:: 22.1.0
    zWrappedDict-)	r+   typestruuiduuid4_ThreadLocalDictWrapperThreadLocal_tl_dict_class)r,   Wrappeds     r   	wrap_dictr8   P   sT     MMMTZ\\***-D,F G --GK$GN    TLLogger)boundloggerc                H   t                       t          | t                    r|                                 } 	 | j        j        j                            | j        j                  }|                     | j	        | j
        i           }||_        |S # t          $ r | cY S w xY w)a<  
    Extract the context from a thread local logger into an immutable logger.

    Arguments:

        logger (structlog.typing.BindableLogger):
            A logger with *possibly* thread local state.

    Returns:

        :class:`~structlog.BoundLogger` with an immutable context.

    .. deprecated:: 22.1.0
    )
processorscontext)r+   
isinstancer	   bind_contextr5   dict_	__class___dict_logger_processorsAttributeError)r<   ctxbls      r   as_immutablerK   i   s     MMM&.// o!'11O!
 
 N)  
 

 	   s   AB B! B!
tmp_valuesr   Generator[TLLogger, None, None]c              +  D  K   t                       t          |           j        }	  | j        di |V  | j                                         | j                            |           dS # | j                                         | j                            |           w xY w)z
    Bind *tmp_values* to *logger* & memorize current state. Rewind afterwards.

    Only works with `structlog.threadlocal.wrap_dict`-based contexts.
    Use :func:`~structlog.threadlocal.bound_threadlocal` for new code.

    .. deprecated:: 22.1.0
    N )r+   rK   rB   rA   clearupdate)r<   rL   saveds      r   tmp_bindrS      s       MMM  )E&fk''J'''''u%%%%% 	u%%%%s   A* *5Bc                      e Zd ZU dZded<   ded<   dd
Zed d            Zd!dZd"dZ	d"dZ
d#dZd$dZd%dZd&dZd'dZdS )(r3   aI  
    Wrap a dict-like class and keep the state *global* but *thread-local*.

    Attempts to re-initialize only updates the wrapped dictionary.

    Useful for short-lived threaded applications like requests in web app.

    Use :func:`wrap` to instantiate and use
    :func:`structlog.BoundLogger.new` to clear the context.
    r   r5   ztype[dict[str, Any]]r6   argskwr   r   c                    |r/t          |d         | j                  r | j        j        di | dS  | j        j        |i | dS )zA
        We cheat.  A context dict gets never recreated.
        r   NrO   )r@   rD   rE   rQ   )selfrU   rV   s      r   __init__z _ThreadLocalDictWrapper.__init__   sf      	+JtAw77 	+ DJ#######DJt*r*****r9   r   c                    	 | j         j        j        S # t          $ r< | j                                         | j         j        _        | j         j        j        cY S w xY w)zB
        Return or create and return the current context.
        )rD   r5   rC   rH   r6   rX   s    r   rE   z_ThreadLocalDictWrapper._dict   s_    
	,>%++ 	, 	, 	,'+~'A'A'C'CDN$>%++++	,s    AAAr0   c                2    d| j         j         d| j        dS )N<(z)>)rD   r   rE   r[   s    r   __repr__z _ThreadLocalDictWrapper.__repr__   s"    =4>*==TZ====r9   otherobjectboolc                "    | j         |j         k    S N)rD   rX   r`   s     r   __eq__z_ThreadLocalDictWrapper.__eq__   s    ~00r9   c                .    |                      |           S rd   )rf   re   s     r   __ne__z_ThreadLocalDictWrapper.__ne__   s    ;;u%%%%r9   Iterator[str]c                4    | j                                         S rd   )rE   __iter__r[   s    r   rk   z _ThreadLocalDictWrapper.__iter__   s    z""$$$r9   keyvaluec                    || j         |<   d S rd   )rE   )rX   rl   rm   s      r   __setitem__z#_ThreadLocalDictWrapper.__setitem__   s    
3r9   c                :    | j                             |           d S rd   )rE   __delitem__)rX   rl   s     r   rq   z#_ThreadLocalDictWrapper.__delitem__   s    
s#####r9   intc                4    | j                                         S rd   )rE   __len__r[   s    r   rt   z_ThreadLocalDictWrapper.__len__   s    z!!###r9   namec                ,    t          | j        |          S rd   )getattrrE   )rX   ru   s     r   __getattr__z#_ThreadLocalDictWrapper.__getattr__   s    tz4(((r9   N)rU   r   rV   r   r   r   r   r   )r   r0   )r`   ra   r   rb   )r   ri   )rl   r0   rm   r   r   r   )rl   r0   r   r   )r   rr   )ru   r0   r   r   )r   
__module____qualname____doc____annotations__rY   propertyrE   r_   rf   rh   rk   ro   rq   rt   rx   rO   r9   r   r3   r3      s        	 	 HHH%%%%	+ 	+ 	+ 	+ 	, 	, 	, X	,> > > >1 1 1 1& & & &
% % % %       $ $ $ $$ $ $ $) ) ) ) ) )r9   r3   r   c                 ^    t                       t                                                      S )zu
    Return a copy of the current thread-local context.

    .. versionadded:: 21.2.0
    .. deprecated:: 22.1.0
    )r+   _get_contextcopyrO   r9   r   get_threadlocalr      s#     MMM>>   r9   bound_loggerr
   c                    t                       t                                                      }|                    t	          j        |                      |S )z
    Return a copy of the current thread-local context merged with the context
    from *bound_logger*.

    .. versionadded:: 21.2.0
    .. deprecated:: 22.1.0
    )r+   r   r   rQ   	structlogget_context)r   rI   s     r   get_merged_threadlocalr      sD     MMM
..



CJJy$\22333Jr9   r   method_namer0   
event_dictr   c                    t                       t                                                      }|                    |           |S )a  
    A processor that merges in a global (thread-local) context.

    Use this as your first processor in :func:`structlog.configure` to ensure
    thread-local context is included in all log calls.

    .. versionadded:: 19.2.0

    .. versionchanged:: 20.1.0
       This function used to be called ``merge_threadlocal_context`` and that
       name is still kept around for backward compatibility.

    .. deprecated:: 22.1.0
    )r+   r   r   rQ   )r<   r   r   r?   s       r   merge_threadlocalr      s9    " MMMnn!!##GNN:Nr9   c                 :    t                       i t          _        dS )z
    Clear the thread-local context.

    The typical use-case for this function is to invoke it early in
    request-handling code.

    .. versionadded:: 19.2.0
    .. deprecated:: 22.1.0
    N)r+   _CONTEXTr?   rO   r9   r   clear_threadlocalr     s     MMMHr9   rV   c                 d    t                       t                                          |            dS )z
    Put keys and values into the thread-local context.

    Use this instead of :func:`~structlog.BoundLogger.bind` when you want some
    context to be global (thread-local).

    .. versionadded:: 19.2.0
    .. deprecated:: 22.1.0
    N)r+   r   rQ   )rV   s    r   bind_threadlocalr   *  s+     MMMNN"r9   keysc                 t    t                       t                      }| D ]}|                    |d           dS )z
    Tries to remove bound *keys* from threadlocal logging context if present.

    .. versionadded:: 20.1.0
    .. deprecated:: 22.1.0
    N)r+   r   pop)r   r?   rl   s      r   unbind_threadlocalr   8  sF     MMMnnG  C r9   Generator[None, None, None]c               +  v  K   t                       t                      fd                                |                                 z  D             }t          di |  	 dV  t	          |                                   t          di | dS # t	          |                                   t          di | w xY w)z
    Bind *kw* to the current thread-local context. Unbind or restore *kw*
    afterwards. Do **not** affect other keys.

    Can be used as a context manager or decorator.

    .. versionadded:: 21.4.0
    .. deprecated:: 22.1.0
    c                "    i | ]}||         S rO   rO   ).0kr?   s     r   
<dictcomp>z%bound_threadlocal.<locals>.<dictcomp>R  s    ???qQ
???r9   NrO   )r+   r   r   r   r   )rV   rR   r?   s     @r   bound_threadlocalr   E  s       MMMG????GLLNNRWWYY$>???Er"BGGII&&!!5!!!!! 	BGGII&&!!5!!!!s   "B )B8c                 l    	 t           j        S # t          $ r i t           _        t           j        cY S w xY wrd   )r   r?   rH   rO   r9   r   r   r   \  sB            s    "33)r   r   )r   r   )r,   r-   r   r-   )r<   r:   r   r:   )r<   r:   rL   r   r   rM   ry   )r   r
   r   r   )r<   r   r   r0   r   r   r   r   )rV   r   r   r   )r   r0   r   r   )rV   r   r   r   )(r|   
__future__r   r   r"   r   r1   r&   typingr   r   r   r   r   _configr	   r
   r   r   r   r   r4   r+   r8   r:   rK   contextmanagerrS   r3   r   r   r   r   r   merge_threadlocal_contextr   r   r   r   r   rO   r9   r   <module>r      sS    # " " " " "     



       4 4 4 4 4 4 4 4 4 4 4 4     ) ) ) ) ) ) E E E E E E E E E E E E    %$&&   >   , 7:^444       F & & & &(?) ?) ?) ?) ?) ?) ?) ?)D 9?! ! ! !      2 .       
 
 
 
 " " " ",           r9   