
    Vh%                    (   d dl mZ d dlZd dlZd dl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mZ d d
lmZ dZd ad ej4                         z  dd Zd ej8                  e      z  dd Zd Zd ZddZ ddZ!d Z"d Z#d Z$y)    )annotationsN)MutableMappingMutableSequence)dumps)	constants)context)AnsibleErrorAnsibleOptionsError)string_types)	to_nativeto_text)parse_kvl        %012x   z%08x   c            	         t         dz  a dj                  t        dd t        dd t        dd t        dd dt         z  d d g      S )N   -r   r   r      r   )cur_idjoinnode_mac
random_int     B/home/dcms/DCMS/lib/python3.12/site-packages/ansible/utils/vars.pyget_unique_idr   )   sT    
aKF88121Q1Q	6	3B  r   c           	     x   t        | t              rt        |t              sqg }| |fD ]  }	 |j                  t        |              t        dj                  | j                  j                  |j                  j                  |d   |d               y# t        $ r |j                  t        |             Y w xY w)z
    Internal convenience function to ensure arguments are MutableMappings

    This checks that all arguments are MutableMappings or raises an error

    :raises AnsibleError: if one of the arguments is not a MutableMapping
    zQfailed to combine variables, expected dicts but got a '{0}' and a '{1}': 
{2}
{3}r   r   N)

isinstancer   appendr   	Exceptionr   r	   format	__class____name__)abmyvarsxs       r   _validate_mutable_mappingsr)   5   s     q.)jN.KQ 	,A,eAh'	,
 pwwKK  !++"6"6q	6!9N 
 	
 /L
  ,il+,s   B#B98B9c                n    |s|t         j                  dk(  rt        | |      S t        | |       | |z  }|S )zV
    Return a copy of dictionaries of variables based on configured hash behavior
    merge)CDEFAULT_HASH_BEHAVIOUR
merge_hashr)   )r%   r&   r+   results       r   combine_varsr0   M   s?    
 !":":g"E!Q q!$UFMr   c                   |dvrt        d      t        | |       | i k(  s| |k(  r|j                         S |i k(  r| S | j                         } |s|dk(  r| j                  |       | S |j	                         D ]  \  }}|| vr|| |<   | |   }t        |t              r*t        |t              r|rt        ||||      | |<   n|| |<   Ot        |t              ryt        |t              ri|dk(  r|| |<   n]|dk(  r	||z   | |<   nO|dk(  r	||z   | |<   nA|dk(  r|D cg c]	  }||vs| c}|z   | |<   n |dk(  r||D cg c]	  }||vs| c}z   | |<   || |<    | S c c}w c c}w )z
    Return a new dictionary result of the merges of y into x,
    so that keys from y take precedence over keys from x.
    (x and y aren't modified)
    )replacekeepr    prepend	append_rp
prepend_rpzzmerge_hash: 'list_merge' argument can only be equal to 'replace', 'keep', 'append', 'prepend', 'append_rp' or 'prepend_rp'r2   r    r4   r5   r6   )	r	   r)   copyupdateitemsr   r   r.   r   )r(   y	recursive
list_mergekeyy_valuex_valuezs           r   r.   r.   [   s    \\  X  Y  	Y q!$
 	Bw!q&vvxBw 	
A
 y0	 	 0W a<AcF C& g~.:g~3V#GWiL# #
 g/Jw4XY& #x' 7*#y( 7*#{* &-A0@!AGK#|+ w#K!!7:JA#KK#  #a0d H B $Ls   	E E8	EEc                   t        t        dd       si }t        j                  j	                  dt                     D ]  }d }t        |d      }||s|j                  d      r| j                  |dd        }n9|d   dv rt        d|z        |d   d	v r| j                  |      }nt        |      }t        |t              rt        ||      }t        d
|z         t        t        d|       t        j                   S )N
extra_varssurrogate_or_strict)errors@r   r   )/.z0Please prepend extra_vars filename '%s' with '@')[{zJInvalid extra vars data supplied. '%s' could not be made into a dictionary)getattrload_extra_varsr   CLIARGSgettupler   
startswithload_from_filer
   loadr   r   r   r0   setattrrB   )loaderrB   extra_vars_optdatas       r   rK   rK      s   ?L$7
%oo11,H 	IND$^<QRN%^((.,,^AB-?@"l2)*\_m*mnn"l2{{>2  /$/)*d;
)*v  zH  +H  I  I+	I. 	z:%%%r   c           	        t        t        dd       sf| d} d| i}dddddd	d
dd}|j                         D ]/  \  }}t        j                  j                  |      }|(||d|z  <   1 t        t        d|       t        j                  S )Noptions_varsUnknownansible_version
check_mode	diff_modeforksinventory_sources	skip_tagslimitrun_tags	verbosity)checkdiffr\   	inventoryr^   subsettagsra   z
ansible_%s)rJ   load_options_varsr9   r   rL   rM   rR   rW   )versionrW   attrsattraliasopts         r   rg   rg      s    $nd;?G)73&$!1)"#)+ !;;= 	9KD%//%%d+C58\E12	9
 	!><@)))r   c                    t        | t              sy| j                         sy| j                         syt	        j
                  |       ryy)a  Determine if string is valid identifier.

    The purpose of this function is to be used to validate any variables created in
    a play to be valid Python identifiers and to not conflict with Python keywords
    to prevent unexpected behavior. Since Python 2 and Python 3 differ in what
    a valid identifier is, this function unifies the validation so playbooks are
    portable between the two. The following changes were made:

        * disallow non-ascii characters (Python 3 allows for them as opposed to Python 2)

    :arg ident: A text string of identifier to check. Note: It is callers
        responsibility to convert ident to text if it is not already.

    Originally posted at https://stackoverflow.com/a/29586366
    FT)r   r   isasciiisidentifierkeyword	iskeyword)idents    r   ro   ro      s@      e\*==?r   )N)Tr2   )%
__future__r   rp   secretsuuidcollections.abcr   r   jsonr   ansibler   r,   r   ansible.errorsr	   r
   ansible.module_utils.sixr   +ansible.module_utils.common.text.convertersr   r   ansible.parsing.splitterr   _MAXSIZEr   getnoder   	randbelowr   r   r)   r0   r.   rK   rg   ro   r   r   r   <module>r      s   $ #    ;  "  < 1 J - 	
ldlln$cr*(w((22BQ7
	
0Wt&@*2r   