File: //usr/lib/python3.9/site-packages/ansible/plugins/action/__pycache__/assemble.cpython-39.pyc
a
�)g� � @ s� d dl mZmZmZ eZd dlZd dlZd dlZd dl Z d dl
Z
d dlmZ
d dlmZmZmZmZ d dlmZmZ d dlmZ d dlmZ d dlmZ G d d
� d
e�ZdS )� )�absolute_import�division�print_functionN)� constants)�AnsibleError�
AnsibleAction�_AnsibleActionDone�AnsibleActionFail)� to_native�to_text)�boolean)�
ActionBase)�
checksum_sc s, e Zd ZdZddd�Zd � fdd� Z� ZS )
�ActionModuleTNFc C s< t jtjd�\}}t�|d�}d} d}
dd� tt�|��D �D ]�}|rR|�|�sRq>d||f }tj �
|�r>|r�tj �|��d�r�q>t
| jj||d�d ��}
|
�� }W d
� n1 s�0 Y |
r�|�d� | �r
|�r
t�|�d }|�|� |d
dk�r
|�d� |�|� d} |�d��r*d}
q>d}
q>|�� |S )z/ assemble a file from a directory of fragments )�dir�wbFc s s | ]}t |d d�V qdS )Zsurrogate_or_strict)�errorsN)r )�.0�p� r �C/usr/lib/python3.9/site-packages/ansible/plugins/action/assemble.py� <genexpr>0 � z8ActionModule._assemble_from_fragments.<locals>.<genexpr>z%s/%s�.)�decrypt�rbN�
r ���T)�tempfileZmkstemp�CZDEFAULT_LOCAL_TMP�os�fdopen�sorted�listdir�search�path�isfile�basename�
startswith�openZ_loaderZ
get_real_file�read�write�codecs�
escape_decode�endswith�close)�selfZsrc_path� delimiterZcompiled_regexp�
ignore_hiddenr ZtmpfdZ temp_path�tmpZ
delimit_meZadd_newline�f�fragmentZfragment_fhZfragment_contentr r r �_assemble_from_fragments( s6 "&
z%ActionModule._assemble_from_fragmentsc
s� d| _ tt| ��||�}~|d u r(t� }| jj�dd �}| jj�dd �}| jj�dd �}| jj�dd�}| jj�dd �}| jj�dd�} | jj�d d�}
| jj�d
d�}�z�z�|d u s�|d u r�t d��t
|dd
�r�|�| jd|d�� t
� �nDz| �d|�}W n2 t�y2 } zt t|���W Y d }~n
d }~0 0 tj�|��sNt d| ��d }
|d u�rft�|�}
| �|||
|
|�}t|�}| �|�}| j||| d�}i }| jj�� }dD ]}||v �r�||= �q�||d<