
    `fw                     p    d Z ddlmZ dZ G d d          ZddZ G d d	          Z G d
 d          ZdS )z7Object related utilities, including introspection, etc.    )reduce)BunchFallbackContextgetitem_property
mro_lookupc                       e Zd ZdZd ZdS )r   z-Object that enables you to modify attributes.c                 :    | j                             |           d S N)__dict__update)selfkwargss     F/var/www/html/env/lib/python3.11/site-packages/celery/utils/objects.py__init__zBunch.__init__
   s    V$$$$$    N)__name__
__module____qualname____doc__r    r   r   r   r      s)        77% % % % %r   r   Nc                     |st                      n|}|sg n|}|                                 D ]K}||v r8	 |j        |         }|j        }||vr|c S n# t          t
          f$ r Y nw xY w dS ||j        v r|c S LdS )a  Return the first node by MRO order that defines an attribute.

    Arguments:
        cls (Any): Child class to traverse.
        attr (str): Name of attribute to find.
        stop (Set[Any]): A set of types that if reached will stop
            the search.
        monkey_patched (Sequence): Use one of the stop classes
            if the attributes module origin isn't in this list.
            Used to detect monkey patched attributes.

    Returns:
        Any: The attribute value, or :const:`None` if not found.
    N)setmror   r   AttributeErrorKeyError)clsattrstopmonkey_patchednodevaluemodule_origins          r   r   r      s     &3555$D-ARR>N		  4<< d+ % 0 !66KKK 7 #H-   
 FF4=  KKK ! s   AA%$A%c                   $    e Zd ZdZd Zd Zd ZdS )r   a  Context workaround.

    The built-in ``@contextmanager`` utility does not work well
    when wrapping other contexts, as the traceback is wrong when
    the wrapped context raises.

    This solves this problem and can be used instead of ``@contextmanager``
    in this example::

        @contextmanager
        def connection_or_default_connection(connection=None):
            if connection:
                # user already has a connection, shouldn't close
                # after use
                yield connection
            else:
                # must've new connection, and also close the connection
                # after the block returns
                with create_new_connection() as connection:
                    yield connection

    This wrapper can be used instead for the above like this::

        def connection_or_default_connection(connection=None):
            return FallbackContext(connection, create_new_connection)
    c                 L    || _         || _        || _        || _        d | _        d S r
   )providedfallbackfb_args	fb_kwargs_context)r   r%   r&   r'   r(   s        r   r   zFallbackContext.__init__J   s)      "r   c                     | j         | j         S  | j        | j        i | j                                        x}| _        |S r
   )r%   r&   r'   r(   	__enter__r)   )r   contexts     r   r+   zFallbackContext.__enter__Q   sM    =$= "/$-\#
!^#
 #

)++	$- r   c                 2    | j          | j         j        | S d S r
   )r)   __exit__)r   exc_infos     r   r.   zFallbackContext.__exit__Y   s$    =$)4=)844 %$r   N)r   r   r   r   r   r+   r.   r   r   r   r   r   .   sK         6    5 5 5 5 5r   r   c                   .    e Zd ZdZddZd ZddZd ZdS )r   a  Attribute -> dict key descriptor.

    The target object must support ``__getitem__``,
    and optionally ``__setitem__``.

    Example:
        >>> from collections import defaultdict

        >>> class Me(dict):
        ...     deep = defaultdict(dict)
        ...
        ...     foo = _getitem_property('foo')
        ...     deep_thing = _getitem_property('deep.thing')


        >>> me = Me()
        >>> me.foo
        None

        >>> me.foo = 10
        >>> me.foo
        10
        >>> me['foo']
        10

        >>> me.deep_thing = 42
        >>> me.deep_thing
        42
        >>> me.deep
        defaultdict(<type 'dict'>, {'thing': 42})
    Nc                     |                     d          \  }}| _        |r|                    d          nd | _        || _        d S )N.)
rpartitionkeysplitpathr   )r   keypathdocr6   _s        r   r   zgetitem_property.__init__   sC    #..s33a'+5DJJsOOO	r   c                 H    | j         rt          d |g| j         z             n|S )Nc                     | |         S r
   r   )dks     r   <lambda>z(getitem_property._path.<locals>.<lambda>   s
    AaD r   )r6   r   )r   objs     r   _pathzgetitem_property._path   s0    @D	 ((3%$)*;<<<	r   c                 d    ||S |                      |                              | j                  S r
   )r@   getr4   )r   r?   types      r   __get__zgetitem_property.__get__   s,    ;Kzz#""48,,,r   c                 @    ||                      |          | j        <   d S r
   )r@   r4   )r   r?   r!   s      r   __set__zgetitem_property.__set__   s    $)

3!!!r   r
   )r   r   r   r   r   r@   rD   rF   r   r   r   r   r   ^   se         @   
  - - - -
* * * * *r   r   )NN)r   	functoolsr   __all__r   r   r   r   r   r   r   <module>rI      s    = =      
H% % % % % % % %   @-5 -5 -5 -5 -5 -5 -5 -5`0* 0* 0* 0* 0* 0* 0* 0* 0* 0*r   