ó
P'^c           @@  s^   d  Z  d d l m Z d g Z d e f d     YZ d
 g  d  Z d e f d     YZ d	 S(   sp   
    celery.utils.objects
    ~~~~~~~~~~~~~~~~~~~~

    Object related utilities including introspection, etc.

i    (   t   absolute_importt
   mro_lookupt   Bunchc           B@  s   e  Z d  Z d   Z RS(   s-   Object that enables you to modify attributes.c         K@  s   |  j  j |  d  S(   N(   t   __dict__t   update(   t   selft   kwargs(    (    s6   /tmp/pip-unpacked-wheel-gV1wwp/celery/utils/objects.pyt   __init__   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s6   /tmp/pip-unpacked-wheel-gV1wwp/celery/utils/objects.pyR      s   c         C@  s   x{ |  j    D]m } | | k rg y | j | } | j } Wn t t f k
 rR n X| | k rc | Sd S| | j k r | Sq Wd S(   se  Return the first node by MRO order that defines an attribute.

    :keyword stop: A list of types that if reached will stop the search.
    :keyword monkey_patched: Use one of the stop classes if the attr's
        module origin is not in this list, this to detect monkey patched
        attributes.

    :returns None: if the attribute was not found.

    N(   t   mroR   R	   t   AttributeErrort   KeyError(   t   clst   attrt   stopt   monkey_patchedt   nodet   module_origin(    (    s6   /tmp/pip-unpacked-wheel-gV1wwp/celery/utils/objects.pyR      s    t   FallbackContextc           B@  s)   e  Z d  Z d   Z d   Z d   Z RS(   sĪ  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, should not close
                # after use
                yield connection
            else:
                # must have 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         O@  s1   | |  _  | |  _ | |  _ | |  _ d  |  _ d  S(   N(   t   providedt   fallbackt   fb_argst	   fb_kwargst   Nonet   _context(   R   R   R   R   R   (    (    s6   /tmp/pip-unpacked-wheel-gV1wwp/celery/utils/objects.pyR   J   s
    				c         C@  s?   |  j  d  k	 r |  j  S|  j |  j |  j   j   } |  _ | S(   N(   R   R   R   R   R   t	   __enter__R   (   R   t   context(    (    s6   /tmp/pip-unpacked-wheel-gV1wwp/celery/utils/objects.pyR   Q   s
    c         G@  s#   |  j  d  k	 r |  j  j |   Sd  S(   N(   R   R   t   __exit__(   R   t   exc_info(    (    s6   /tmp/pip-unpacked-wheel-gV1wwp/celery/utils/objects.pyR   Y   s    (   R   R	   R
   R   R   R   (    (    (    s6   /tmp/pip-unpacked-wheel-gV1wwp/celery/utils/objects.pyR   /   s   		N(    (   R
   t
   __future__R    t   __all__t   objectR   R   R   (    (    (    s6   /tmp/pip-unpacked-wheel-gV1wwp/celery/utils/objects.pyt   <module>   s
   	