
    Vh!                         d dl mZmZmZ eZd dlZd dlZd dlZd dl	m
Z d dlmZ d dlmZmZmZmZ d dlmZmZmZ d dlmZ d dlmZ d d	lmZ d d
lmZ  G d de      Zy)    )absolute_importdivisionprint_functionN)	constants)ensure_type)AnsibleErrorAnsibleFileNotFoundAnsibleActionAnsibleActionFail)to_bytesto_text	to_native)boolean)string_types)
ActionBase)generate_ansible_template_varsc                   $     e Zd ZdZd fd	Z xZS )ActionModuleTc                 8   |
t               }t        t        |   ||      }~dD ]  }|| j                  j
                  v st        | j                  j
                  |   d      }|*t        |t              st        |dt        |      d      || j                  j
                  |<    	 t        | j                  j
                  j                  dd      d	      }t        | j                  j
                  j                  d
d      d	      }| j                  j
                  j                  dd      }	| j                  j
                  j                  dd      }
| j                  j
                  j                  dd      }| j                  j
                  j                  dd      }| j                  j
                  j                  dd      }| j                  j
                  j                  dd      }| j                  j
                  j                  dd      }| j                  j
                  j                  dd      }| j                  j
                  j                  dd      xs d}|r	 ddl}	 |j$                  j&                   g d}g d}||v r||j+                  |         }	 |t        d      |	|
t        d      ||vrt        d      	 | j-                  d|	      }		 | j0                  j3                  |	      }t7        |d!"      }	 t9        |d#      5 }	 t/        |j;                         d!"      }	 ddd       |j                  d%g       }|j?                  | j0                  j@                  tB        jD                  jG                  |	      g       g }|D ]B  }|jI                  tB        jD                  jK                  |d             |jI                  |       D |}|jM                         }|jO                  tQ        |	|
&             | jR                  jU                  |||||||||'	      5  | jR                  jW                  dd(      }ddd       | j0                  j_                  |       | j                  jM                         }d*D ]  }|j
                  ja                  |d         tc        jd                  tf        jh                  +      } 	 tB        jD                  jK                  | tB        jD                  jk                  |	            }!t9        t7        |!d!"      d,      5 }|jm                  t7        |d!-             ddd       |j
                  jO                  t        |!|
.             | jn                  jp                  j                  d/|| jr                  | jt                  | j0                  | jR                  | jn                  0      }"|jO                  |"j                  |1             tw        jx                  t7        | d!"             	 | j}                  | jr                  j~                  j                         |S # t        $ r}t        t        |            d}~ww xY w# t         $ r t#        d      w xY w# t(        $ r t#        d      w xY w# t"        $ r}t        t/        |            d}~ww xY w# t4        $ r}t        d|	d t/        |            d}~ww xY w# t<        $ r t        d$      w xY w# 1 sw Y   xY w# 1 sw Y   xY w# tX        $ r  tZ        $ r1}t        t        |      j\                  d)t/        |            d}~ww xY w# | j0                  j_                  |       w xY w# 1 sw Y   >xY w# tw        jx                  t7        | d!"             w xY w# tX        $ r&}|jO                  |jz                         Y d}~d}~ww xY w# | j}                  | jr                  j~                  j                         w xY w)2z! handler for template operations N)srcdeststatenewline_sequencevariable_start_stringvariable_end_stringblock_start_stringblock_end_stringstringz% is expected to be a string, but got z insteadtrim_blocksTF)strictlstrip_blocksr   r   r   r   
r   r   r   r   output_encodingzutf-8r   zAUnable to import Jinja2 defaults for determining Jinja2 features.zAOption `lstrip_blocks' is only available in Jinja2 versions >=2.7)z\nz\rz\r\n)
r"   z)'state' cannot be specified on a templatezsrc and dest are requiredz/newline_sequence needs to be one of: 
,  or 
	templateszcould not find src=z, surrogate_or_strict)errorsrbz+Template source files must be utf-8 encodedansible_search_path)	dest_path)	
searchpathr   r   r   r   r   r   r!   available_variables)preserve_trailing_newlinesescape_backslashesz: )r   r   r   r   r   r   r!   r#   )dirwb)encodingr(   )r   r   zansible.windows.win_copy)task
connectionplay_contextloadertemplarshared_loader_obj)	task_vars)Adictsuperr   run_taskargsr   
isinstancer   r   typer   get	TypeErrorr   jinja2.defaultsImportErrorr   defaultsLSTRIP_BLOCKSAttributeErrorindex_find_needler   _loaderget_real_filer	   r   openreadUnicodeErrorextend_basedirospathdirnameappendjoincopyupdater   _templarset_temporary_contextdo_templater
   	Exception__name__cleanup_tmp_filepoptempfilemkdtempCDEFAULT_LOCAL_TMPbasenamewrite_shared_loader_objaction_loader_connection_play_contextshutilrmtreeresult_remove_tmp_path_shelltmpdir)$selftmpr9   rk   s_typevaluer   r!   esourcer   r   r   r   r   r   r   r#   jinja2wrong_sequencesallowed_sequences
tmp_sourceb_tmp_sourceftemplate_datar,   newsearchpathp	temp_vars	resultantnew_taskremovelocal_tempdirresult_filecopy_action	__class__s$                                      o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ansible/windows/plugins/action/win_template.pyr<   zActionModule.run   s$    I|T.sI>+ 	0F(#DJJOOF$;XF$Z|-L+cikopukv,wxx*/

'	0	2!$**//"5"5mT"JSXYK#DJJOO$7$7$OX]^M
 $$UD1zz""640

##GT2::??../A6J $

 3 34KT R"jjoo112GN!ZZ__001EtL::??../A4H**//--.?ITW h&h-- 30 .01F1FGW1XY\	B '(STT4<'(CDD!)::'(]^^8!..{FCF
\!\\77?
 $J7LML"<,- __(/AV(W_ ']]+@"E
!!4<<#8#8"''//&:Q"RS !## ,A!((a)EF!((+, +
 &NN,	  !?RV!WX]]88JaqL^  rBOd  {NEP`mMV	 9 X D
 !% 9 9-dh  ~C 9  !DID --l;zz(HN 0!!&$/0 %,,1D1DEMU ggll="'':J:J6:RS(;7LMtT iXYGGHYQfghi $$'! #55CCGGHbMUSWScScUYUgUgOS||PTP]P]Z^ZqZq H s koo	oBCh}=RST
 !!$"2"2"9"9"@"@A  	2#IaL11	2$  h"#fggh
 " h"#fggh* $ 8+GAJ778 ' \'vwWXz(Z[[\ ( _/0]^^__ _,D D !  S'DG4D4Dgaj(QRRS --l;i i$ h}=RST 	$MM!((##	$ !!$"2"2"9"9"@"@AsI  ,A"Y +Y, 0Z '+^6 Z &[ ^6 \ \[,9C9\ 2\\ A<^6 A^ *^B-^ 5 ^6 _( 	Y)Y$$Y),ZZ	Z>%Z99Z>>^6 	[)
[$$[))^6 ,\\\	\ \\ ]!0,]]!!]$ $^^6 ^	^ "^33^6 6	_%?_ _(  _%%_( (1`)NN)r\   
__module____qualname__TRANSFERS_FILESr<   __classcell__)r   s   @r   r   r      s    OV V    r   ) 
__future__r   r   r   r@   __metaclass__rQ   ri   r_   ansibler   ra   ansible.config.managerr   ansible.errorsr   r	   r
   r   ansible.module_utils._textr   r   r   )ansible.module_utils.parsing.convert_boolr   ansible.module_utils.sixr   ansible.plugins.actionr   ansible.templater   r    r   r   <module>r      sH   
 C B 	   " . ^ ^ C C = 1 - ;Z: Zr   