
    hw                     \    d Z ddlmZ dZ G d d      ZddZ G d d	      Z G d
 d      Zy)z7Object related utilities, including introspection, etc.    )reduce)BunchFallbackContextgetitem_property
mro_lookupc                       e Zd ZdZd Zy)r   z-Object that enables you to modify attributes.c                 :    | j                   j                  |       y N)__dict__update)selfkwargss     P/var/www/Befach/backend/env/lib/python3.12/site-packages/celery/utils/objects.py__init__zBunch.__init__
   s    V$    N)__name__
__module____qualname____doc__r    r   r   r   r      s
    7%r   r   Nc                     |s
t               n|}|sg n|}| j                         D ]>  }||v r&	 |j                  |   }|j                  }||vr|c S  y||j                  v s<|c S  y# t        t
        f$ r Y  yw xY w)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     35$D-R>N	4< d+ % 0 0 !6K4== K 
 #H-  s   A''A:9A:c                   "    e Zd ZdZd Zd Zd Zy)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                 J    || _         || _        || _        || _        d | _        y 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                  j	                         x}| _        |S r
   )r%   r&   r'   r(   	__enter__r)   )r   contexts     r   r+   zFallbackContext.__enter__Q   sP    ==$== "/$--\\#
!^^#

)+	$- r   c                 N    | j                    | j                   j                  | S y 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   .   s    65r   r   c                   ,    e Zd ZdZddZd ZddZd Zy)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                 z    |j                  d      \  }}| _        |r|j                  d      nd | _        || _        y )N.)
rpartitionkeysplitpathr   )r   keypathdocr6   _s        r   r   zgetitem_property.__init__   s5    #..s3a'+DJJsO	r   c                 T    | j                   rt        d |g| j                   z         S |S )Nc                     | |   S r
   r   )dks     r   <lambda>z(getitem_property._path.<locals>.<lambda>   s    AaDr   )r6   r   )r   objs     r   _pathzgetitem_property._path   s+    @D		(3%$))*;< 		r   c                 ^    ||S | j                  |      j                  | j                        S r
   )r@   getr4   )r   r?   types      r   __get__zgetitem_property.__get__   s)    ;Kzz#""488,,r   c                 @    || j                  |      | j                  <   y 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   ^   s    @
-
*r   r   )NN)r   	functoolsr   __all__r   r   r   r   r   r   r   <module>rI      s5    = 
H% %@-5 -5`0* 0*r   