
    VhD                        d dl mZ d dlZd dlmZ d dlmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ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mZ d dlm Z  d dl!m"Z"  e"       Z# G d deee      Z$y)    )annotationsN)AnsibleParserErrorAnsibleAssertionError)to_bytes)string_types)
split_args)AnsibleBaseYAMLObjectAnsibleMapping)NonInheritableFieldAttribute)Base)Conditional)Taggable)AnsibleCollectionConfig)_get_collection_name_from_path_get_collection_playbook_path)Templar)Displayc                  j     e Zd Z ed      Z eded      Zed
d       Zd fd	Z	 fdZ
d	 Z xZS )PlaybookIncludestring)isadictvars)r   defaultaliasc                <    t               j                  | |||      S )N)dsbasedirvariable_managerloader)r   	load_data)datar   r   r    s       Q/home/dcms/DCMS/lib/python3.12/site-packages/ansible/playbook/playbook_include.pyloadzPlaybookInclude.load-   s!     **dGVfou*vv    c           
        ddl m} ddlm} t        t
        |   |||      }| j                  j                         }|r||j                         z  }t        ||      }	 ||      }
|	j                  |j                        }t        |      }||d   }|d   }nL|}t        j                  j!                  |      s t        j                  j#                  ||      }t%        |      }|r|t&        _        ndt&        j*                  j-                  t        j                  j/                  t        j                  j1                  t3        |d	
                         |
j5                  ||| j                  j                                |
j6                  D ]c  }|j8                  r t;        ||      r|j8                  dd |_        |j                  |j                  z  }|j?                  dd      }|*|j@                  jC                  |jE                  d             ||_        tG        tI        |j@                        jK                  |j@                              |_         |jL                  $t        j                  j/                  |      |_&        |j8                  s|jN                  |jP                  z   |jR                  z   |jT                  z   D ]&  }|j8                  dd |j8                  dd z   |_+        ( f |
S )z
        Overrides the base load_data(), as we're actually going to return a new
        Playbook() object rather than a PlaybookInclude object
        r   )Playbook)Play)r    	variables)r    N      surrogate_or_strict)errors)	file_namer   r   tags,),ansible.playbookr'   ansible.playbook.playr(   superr   r!   r   copyget_varsr   templateimport_playbookr   ospathisabsjoinr   r   default_collectionplaybook_pathsappenddirnameabspathr   _load_playbook_data_entrieswhen
isinstance_included_conditionalpopr/   extendsplitlistsetunion_included_path	pre_tasksrolestasks
post_tasks_when)selfr   r   r    r   r'   r(   new_objall_varstemplarpbr.   resourceplaybookplaybook_collectionentry	temp_vars
param_tags
task_block	__class__s                      r#   r!   zPlaybookInclude.load_data1   s~    	..
 8=MvV99>>#(1133H8< V$$$W%<%<=	 1;{H"*1+ !H77==*77<<: #A"J9L#6 $2299"''//"''//Zbck  uJ  [K  KL  ;M  N
DT[_[d[d[i[i[kl [[ 	LE ||
5$ 7.5ll1o+

W\\1I"vt4J%

!!*"2"23"78"EJc%**o33GLLABEJ##+')wwx'@$
 ||#(??U[[#@5;;#NQVQaQa#a LJ'.||A9K'KJ$L'	L, 	r%   c                   t        |t              st        d|dt        |            t	               }t        |t
              r|j                  |_        |j                         D ]d  \  }}|t        j                  v r| j                  ||||       -|dk(  r.d|v rt        d|      t        |t              st        d|      |||<   f t        t        | ;  |      S )z
        Reorganizes the data for a PlaybookInclude datastructure to line
        up with what we expect the proper attributes to be
        zds (z) should be a dict but was a r   zTimport_playbook parameters cannot be mixed with 'vars' entries for import statementsobjzEvars for import_playbook statements must be specified as a dictionary)rD   r   r   typer
   r	   ansible_positemsC_ACTION_IMPORT_PLAYBOOK_preprocess_importr   r3   r   preprocess_data)rR   r   new_dskvr^   s        r#   rh   zPlaybookInclude.preprocess_data|   s     "d#'SUW[\^W_(`aa  !b/0!#Fhhj 	FQA---''FAq9 ;'0  2H  NP  Q  Q'4001x  A  B  Bq		 _d;FCCr%   c                    |t        d|      t        |t              st        dt        |      z  |      t	        |      }t        |      dk(  rt        d|      |d   j                         |d<   y)zQ
        Splits the playbook import line up into filename and parameters
        Nz$playbook import parameter is missingr`   zQplaybook import parameter must be a string indicating a file path, got %s insteadr   z?import_playbook statements must specify the file name to importr7   )r   rD   r   rb   r   lenstrip)rR   r   ri   rj   rk   rd   s         r#   rg   z"PlaybookInclude._preprocess_import   s     9$%KQSTTA|,$%x{  AB  |C  &C  IK  L  L 1u:?$%flnoo$)!HNN$4 !r%   )NN)NNN)__name__
__module____qualname__r   r7   r   vars_valstaticmethodr$   r!   rh   rg   __classcell__)r^   s   @r#   r   r   (   sA    2x@O+FSHw wIVD<5r%   r   )%
__future__r   r8   ansible.constants	constantsre   ansible.errorsr   r   +ansible.module_utils.common.text.convertersr   ansible.module_utils.sixr   ansible.parsing.splitterr   ansible.parsing.yaml.objectsr	   r
   ansible.playbook.attributer   ansible.playbook.baser   ansible.playbook.conditionalr   ansible.playbook.taggabler   ansible.utils.collection_loaderr   2ansible.utils.collection_loader._collection_finderr   r   ansible.templater   ansible.utils.displayr   displayr    r%   r#   <module>r      sP   $ # 	  D @ 1 / N C & 4 . C | $ )
)A5dK A5r%   