%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/ansible/plugins/action/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/ansible/plugins/action/__pycache__/include_vars.cpython-39.opt-1.pyc

a

�)g�,�@s�ddlmZmZmZeZddlmZmZddl	Z	ddl
mZddl
mZddlmZddlmZmZddlmZddlmZGd	d
�d
e�ZdS)�)�absolute_import�division�print_function)�path�walkN)�AnsibleError)�string_types)�	to_native�to_text)�
ActionBase)�combine_varscs�eZdZdZgd�Zgd�ZddgZddgZdd	�Zd
d�Z	d�fd
d�	Z
dd�Zdd�Zdd�Z
dd�Zdd�Zddd�Zdd�Z�ZS)�ActionModuleF)ZyamlZymlZjson)�dir�depth�files_matching�ignore_files�
extensions�ignore_unknown_extensions�file�_raw_params�name�hash_behaviourcCsx|jsd|_|jr(t�d�|j��|_nd|_|js<t�|_t|jt	�rV|j�
�|_nt|jt�rtdd�|j�d�SdS)Nrz{0}Tz{0} must be a list)�failed�message)rr�re�compile�format�matcherr�list�
isinstancer�split�dict��self�r$�G/usr/lib/python3.9/site-packages/ansible/plugins/action/include_vars.py�_set_dir_defaultss
�zActionModule._set_dir_defaultscCs|jj�dd�|_|jj�dd�|_|jj�dd�|_|jj�dd�|_|jsx|jsx|jj�d�|_|jrx|j�d�|_|jj�dd�|_|jj�d	d�|_	|jj�d
d�|_
|jj�dd�|_|jj�d
|j�|_
t|j
t�r�t|j
�|_
t|j
t��std��dS)z@ Set instance variables based on the arguments that were passed rNrrrr�
rrrFrrz7Invalid type for "extensions" option, it must be a list)�_task�args�getr�return_results_as_name�
source_dir�source_file�rstriprrrr�VALID_FILE_EXTENSIONS�valid_extensionsrrrrr"r$r$r%�	_set_args0s"zActionModule._set_argsNc
sZ~|durt�}d|_g|_d}d}|jjD]J}||jvrD|d7}q,||jvrX|d7}q,||jvrdq,td�	t
|����q,|r�|r�td��|��t�}d}|j�r2|�
�|��t�|j�s�d}d�	t
|j��}n\t�|j�s�d}d	�	t
|j��}n:|��D]0\}	}
|�|	|
�\}}}|�r$�q�|�|�q�njz6|�d
|j�|_|�|j�\}}}|�sf|�|�Wn2t�y�}zd}t
|�}WYd}~n
d}~00|j�r�t�}
||
|j<|
}tt|�j|d�}|�r�||d<||d
<nV|jdu�r8|jtjk�r8|jdk}|��D](\}}|� |d�}t!|||d�||<�q|j|d<||d<|j|d<|S)z6 Load yml files recursively from a directory.
        NTr�z){0} is not a valid option in include_varszGYou are mixing file only and dir only arguments, these are incompatibleFz{0} directory does not existz{0} is not a directory�vars)�	task_varsrr�merge)r5Zansible_included_var_filesZ
ansible_factsZ_ansible_no_log)"r!�show_content�included_filesr(r)�VALID_DIR_ARGUMENTS�VALID_FILE_ARGUMENTS�	VALID_ALLrrr	r1r,r&�
_set_root_dirr�exists�isdir�_traverse_dir_depth�_load_files_in_dir�updateZ_find_needler-�_load_filesr+�superr
�runr�CZDEFAULT_HASH_BEHAVIOUR�itemsr*r)r#�tmpr4�dirs�files�arg�resultsr�err_msg�root_dir�	filenamesZupdated_results�eZscope�resultZmerge_hashes�key�value�	old_value��	__class__r$r%rCHsx





�



zActionModule.runcCs�|jjr`|j�d�ddkrBt�|jjj|j�}t�|�r^||_q�t�|jjjd|j�}||_n<t|jj	d�r�d�|jj	j
�d�dd��}t�||j�|_dS)N�/rr3�_data_source���)r(�_roler,r r�join�
_role_pathr<�hasattrZ_dsrV)r#Zpath_to_use�current_dirr$r$r%r;�s�
���zActionModule._set_root_dircCs"|j�dt|j�t|�f�dS)Nz#Issue with walking through "%s": %s)Z_displayZvvvr	�filename)r#�errorr$r$r%�	_log_walk�szActionModule._log_walkccspd}tt|j|jd��}|jdd�d�|D]>\}}}|d7}||jksR|jdkrf|��||fVq,qlq,dS)z� Recursively iterate over a directory and sort the files in
            alphabetical order. Do not iterate pass the set depth.
            The default depth is unlimited.
        r)�onerrorcSs|dS)Nrr$)�xr$r$r%�<lambda>��z2ActionModule._traverse_dir_depth.<locals>.<lambda>)rPr2N)rrr,r_�sortr)r#Z
current_depthZsorted_walkZcurrent_rootr\Z
current_filesr$r$r%r>�sz ActionModule._traverse_dir_depthc	CsT|jD]H}zt�d�|�|�r&WdSWqtyLd�|�}t|��Yq0qdS)z� Return True if a file matches the list of ignore_files.
        Args:
            filename (str): The filename that is being matched against.

        Returns:
            Boolean
        z{0}$TzInvalid regular expression: {0}F)rr�searchr�	Exceptionr)r#r]Z	file_typerKr$r$r%�_ignore_file�s

zActionModule._ignore_filecCs0t�|�}tt|�dko,|ddd�|jv�S)z� Verify if source file has a valid extension
        Args:
            source_file (str): The full path of source file or source file.
        Returns:
            Bool
        r2rWN)r�splitext�bool�lenr0)r#r-Zfile_extr$r$r%�_is_valid_file_ext�s
zActionModule._is_valid_file_extc	Cs�t�}d}d}|r:|�|�s:d}d�t|�d�|j��}nz|j�|�\}}t|dd�}|j	|M_	|jj
|||d�}|s�t�}t|t�s�d}d	�t|��}n|j�
|�|�|�|||fS)
z� Loads a file and converts the output into a valid Python dict.
        Args:
            filename (str): The source file.

        Returns:
            Tuple (bool, str, dict)
        F�Tz({0} does not have a valid extension: {1}z, Zsurrogate_or_strict)�errors)�	file_namer6z'{0} must be stored as a dictionary/hash)r!rkrr	rYr0Z_loaderZ_get_file_contentsr
r6�loadrr7�appendr@)	r#r]�validate_extensionsrJrrKZb_datar6�datar$r$r%rA�s$

zActionModule._load_filesc
Cs�t�}d}d}|D]�}d}|jjrHt�|jjj|�t�|dd�krHd}qt�||�}|jrj|j�|�sjd}|s|s|j	r�t�
|�r�|�|�s�|�|�r�|j
|dd�\}}}	|s�|�|	�qt�
|�r|�|�s|j
|dd�\}}}	|s|�|	�q|||fS)a> Load the found yml files and update/overwrite the dictionary.
        Args:
            root_dir (str): The base directory of the list of files that is being passed.
            var_files: (list): List of files to iterate over and load into a dictionary.

        Returns:
            Tuple (bool, str, dict)
        Frlr3zmain.ymlT)rq)r!r(rXrrYrZrrrerr<rgrkrAr@)
r#rLZ	var_filesrJrrKr]Z	stop_iter�filepathZloaded_datar$r$r%r?�s0	 zActionModule._load_files_in_dir)NN)F)�__name__�
__module__�__qualname__ZTRANSFERS_FILESr/r8r9r:r&r1rCr;r_r>rgrkrAr?�
__classcell__r$r$rSr%r
sR

 r
)Z
__future__rrr�typeZ
__metaclass__�osrrrZansible.constantsZ	constantsrDZansible.errorsrZansible.module_utils.sixrZansible.module_utils._textr	r
Zansible.plugins.actionrZansible.utils.varsrr
r$r$r$r%�<module>s

Zerion Mini Shell 1.0