
    Vh|                        d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ dgZ e       Z G d	 de
      Zy)
    )annotationsN)AnsibleParserError)Block)Task)Display)SentinelTaskIncludec                       e Zd ZdZ ed      Z ed      Zej                  e      Z ed      Z	d fd	Z
edd       Zd Z fdZd fd		Zd
 Z xZS )r	   z
    A task include is derived from a regular task to handle the special
    circumstances related to the `- include_*: ...` task.
    )file_raw_params)apply)actionargscollectionsdebuggerignore_errorslooploop_control	loop_withnameno_logregisterrun_oncetagstimeoutvarswhenc                @    t         t        |   |||       d| _        y )Nblockroletask_includeF)superr	   __init__statically_loaded)selfr    r!   r"   	__class__s       M/home/dcms/DCMS/lib/python3.12/site-packages/ansible/playbook/task_include.pyr$   zTaskInclude.__init__.   s!    k4)D|)\!&    c                j    t        |||      }|j                  |j                  | ||      |       }|S )Nr   )variable_managerloader)r	   check_options	load_data)datar    r!   r"   r+   r,   titasks           r(   loadzTaskInclude.load2   s=    u4lKLL0@LP

 r)   c           
        t        |j                  j                               }|j                  | j                        }|rQ|j
                  t        j                  v r5t        d|j
                  ddj                  t        |            |      |j                  j                  d      sR|j                  j                  dd      |j                  d<   |j                  d   st        d|j
                  z  |      |j                  j                  d	i       }|r6|j
                  t        j                  vrt        d
|j
                  z  |      t        |t              st        dt!        |      z  |      |S )aV  
        Method for options validation to use in 'load_data' for TaskInclude and HandlerTaskInclude
        since they share the same validations. It is not named 'validate_options' on purpose
        to prevent confusion with '_validate_*" methods. Note that the task passed might be changed
        as a side-effect of this method.
        zInvalid options for z: ,objr   r   NzNo file specified for %sr   zInvalid options for %s: applyz,Expected a dict for apply but got %s instead)	frozensetr   keys
difference
VALID_ARGSr   C'_ACTION_ALL_PROPER_INCLUDE_IMPORT_TASKSr   joinlistgetpop_ACTION_INCLUDE_TASKS
isinstancedicttype)r&   r1   r/   my_arg_namesbad_optsapply_attrss         r(   r-   zTaskInclude.check_options<   s(    !!12  **4??;q'P'PP$T[[RURZRZ[_`h[iRj%kquvvyy}}]+'+yy}}VT'BDIIm$99]+()Cdkk)QW[\\iimmGR04;;a.E.EE$%Dt{{%RX\]]K.$%SVZ[fVg%gmqrrr)   c                   t         t        |   |      }t        |j	                               j                  | j                        }|D ]s  }||   t        us|d   t        j                  v s%t        j                  r't        d|d| j                  j                  |      t        j                  d|z         u |S )Nr   'z!' is not a valid attribute for a r5   zIgnoring invalid attribute: %s)r#   r	   preprocess_datasetr8   r9   VALID_INCLUDE_KEYWORDSr   r;   _ACTION_ALL_INCLUDE_ROLE_TASKSINVALID_TASK_ATTRIBUTE_FAILEDr   r'   __name__displaywarning)r&   dsdiffkr'   s       r(   rJ   zTaskInclude.preprocess_dataW   s    ;5b92779~(()D)DE 	JA!uH$H9Y9Y)Y22,YZ\`\j\j\s\s-tz|}}OO$Dq$HI	J 	r)   c                T    t         t        |   ||      }| j                  |_        |S )N)exclude_parentexclude_tasks)r#   r	   copyr%   )r&   rV   rW   new_mer'   s       r(   rX   zTaskInclude.copye   s-    {D.n\i.j#'#9#9 r)   c                    | j                   j                  di       }|rTg |d<   t        j                  || j                  j
                  | | j                  | j                  | j                        }|S | }|S )z{
        This method is used to create the parent block for the included tasks
        when ``apply`` is specified
        r   r    )playr"   r!   r+   r,   )	r   r@   r   r2   _parent_play_role_variable_manager_loader)r&   rG   p_blocks      r(   build_parent_blockzTaskInclude.build_parent_blockj   sp    
 iimmGR0#%K jj\\''!ZZ!%!7!7||G  Gr)   )NNN)NNNNN)FF)rO   
__module____qualname____doc__r7   BASE
OTHER_ARGSunionr:   rL   r$   staticmethodr2   r-   rJ   rX   rb   __classcell__)r'   s   @r(   r	   r	       sj    
 ,-D:&JJ'J& (0 1'  6
r)   )
__future__r   ansible.constants	constantsr;   ansible.errorsr   ansible.playbook.blockr   ansible.playbook.taskr   ansible.utils.displayr   ansible.utils.sentinelr   __all__rP   r	    r)   r(   <module>ru      s8   $ #  - ( & ) +/
)]$ ]r)   