o
    Df                     @   sX   d Z ddlmZmZ ddlmZ edZedZdZG dd de	Z
d	d
 Zdd ZdS )zTask Annotations.

Annotations is a nice term for monkey-patching task classes
in the configuration.

This prepares and performs the annotations in the
:setting:`task_annotations` setting.
    )firstmethodmlazy)instantiateannotateannotate_any)MapAnnotationprepareresolve_allc                   @   s    e Zd ZdZdd Zdd ZdS )r   z(Annotation map: task_name => attributes.c                 C   s$   zt | d W S  ty   Y d S w )N*)dictKeyError)self r   O/home/ubuntu/webapp/venv/lib/python3.10/site-packages/celery/app/annotations.pyr      s
   zMapAnnotation.annotate_anyc                 C   s&   zt | |j W S  ty   Y d S w N)r   namer   )r   taskr   r   r   r      s
   zMapAnnotation.annotateN)__name__
__module____qualname____doc__r   r   r   r   r   r   r      s    r   c                    s:   dd  | du r
dS t | ttfs| f}  fdd| D S )z/Expand the :setting:`task_annotations` setting.c                 S   s*   t | tr	t| S t | trtt| S | S r   )
isinstancer   r   strr   r   )
annotationr   r   r   expand_annotation$   s
   


z"prepare.<locals>.expand_annotationNr   c                    s   g | ]} |qS r   r   ).0annor   r   r   
<listcomp>/   s    zprepare.<locals>.<listcomp>)r   listtuple)annotationsr   r   r   r   "   s   r   c                 C   s   dd t | |t| fD S )z Resolve all pending annotations.c                 s   s    | ]}|r|V  qd S r   r   )r   xr   r   r   	<genexpr>4   s    zresolve_all.<locals>.<genexpr>)_first_match_first_match_any)r   r   r   r   r   r	   2   s   r	   N)r   celery.utils.functionalr   r   celery.utils.importsr   r$   r%   __all__r   r   r   r	   r   r   r   r   <module>   s    