o
    wvXj  ã                   @   st   d Z ddlmZmZ ddlm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 )z½Task 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.
é    )Úabsolute_importÚunicode_literals)Ústring_t)Ú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   úS/var/www/html/myproject/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
   r   r   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>3   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>8   s   € zresolve_all.<locals>.<genexpr>)Ú_first_matchÚ_first_match_any)r   r   r   r   r   r   6   s   r   N)r   Ú
__future__r   r   Úcelery.fiver   Úcelery.utils.functionalr   r   Úcelery.utils.importsr   r&   r'   Ú__all__r   r
   r   r   r   r   r   r   Ú<module>   s   