o nnhs&@sddlmZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl m Z ddlmZmZddlmZdd lmZmZdd lmZed Zd Zdad eddZdededdZddZ ddZ!d"ddZ"d#ddZ#ddZ$ddZ%dd Z&e&Z'd!e'_(dS)$) annotationsN)MutableMappingMutableSequence)dumps) constants)context) AnsibleErrorAnsibleOptionsError) string_types) to_nativeto_text)parse_kv)TrueFalseNonel%012x z%08xc CsHtd7adtddtddtddtdddtddgS)N-rrrr)cur_idjoinnode_mac random_intrr=/usr/local/lib/python3.10/dist-packages/ansible/utils/vars.py get_unique_id+s    rc Cst|tr t|ts>g}||fD]}z |t|Wqty+|t|Yqwtd|jj |jj |d|ddS)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}rrN) isinstancerappendr Exceptionr rformat __class____name__)abmyvarsxrrr_validate_mutable_mappings7s   r(cCs6|s |durtjdkrt||St||||B}|S)zV Return a copy of dictionaries of variables based on configured hash behavior Nmerge)CDEFAULT_HASH_BEHAVIOUR merge_hashr()r$r%r)resultrrr combine_varsOs   r.Treplacecsh|dvrtdt|||iks||kr|S|ikr|S|}|s0|dkr0|||S|D]}\}||vrA||<q4||}t|tr`ttr`|r[t|||||<n||<q4t|trttr|dkrs||<n9|dkr~|||<n.|dkr|||<n#|dkrfdd|D||<n|d krfd d|D||<q4||<q4|S) 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) )r/keeprprepend append_rp prepend_rpzzmerge_hash: 'list_merge' argument can only be equal to 'replace', 'keep', 'append', 'prepend', 'append_rp' or 'prepend_rp'r/rr1r2cg|]}|vr|qSrr.0zy_valuerr zmerge_hash..r3cr4rrr5r8rrr:r;) rr(copyupdateitemsrrr,r)r'y recursive list_mergekeyx_valuerr8rr,]sF     r,cCsttddsci}tjdtD]L}d}t|dd}|dus |s!q|dr0||dd}n|ddvrrrNrOrTrX)versionrXattrsattraliasoptrrrrhs(    rhcCs8t|tsdS|s dS|sdSt|rdSdS)NFT)rr isascii isidentifierkeyword iskeyword)identrrr_isidentifier_PY3s  rsa.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) * True, False and None are reserved keywords (these are reserved keywords on Python 3 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 http://stackoverflow.com/a/29586366 )N)Tr/)) __future__rrprandomuuidcollections.abcrrjsonransiblerr*ransible.errorsrr ansible.module_utils.sixr +ansible.module_utils.common.text.convertersr r ansible.parsing.splitterr frozensetADDITIONAL_PY2_KEYWORDS_MAXSIZErgetnoderrandintrrr(r.r,rMrhrsro__doc__rrrrs4        Z