o nnh-@sddlmZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZddlmmmZdd lmZd dddZGdddejZd ddZ ddZ!ddZ"ddZ#GdddeZ$dS)!) annotationsN)Mapping)islicechain) GeneratorType) is_sequence)to_text) string_types)AnsibleVaultEncryptedUnicode)NativeJinjaText)wrap_var)StrictUndefinedTF)truefalsenullc@seZdZddZdS) Json2PythoncCs |jtvr|Stjt|jdS)N)value)id _JSON_MAPastConstant)selfnoderJ/usr/local/lib/python3.10/dist-packages/ansible/template/native_helpers.py visit_Names zJson2Python.visit_NameN)__name__ __module__ __qualname__rrrrrrs rrt.AnyreturnboolcCs|g}t} |s dS|d}t|}||vrq||t|tr%qt|tr9|||| nt |rC||nt |ddrKdSq)z Our helper function, which will also recursively check dict and list entries due to the fact that they may be repr'd and contain a key or value which contains jinja2 syntax and would otherwise lose the AnsibleUnsafe value. Tr __UNSAFE__F) setpopradd isinstanceAnsibleUndefinedrextendkeysvaluesrgetattr)rto_checkseenvalval_idrrr _is_unsafe%s*      r0c Cstt|d}|s dSd}t|dkr'|d}t|tr|St|}t|}n%t|tr1t||}g}|D]}|s?t|r?d}| t|q5d |}| dsU|dvrvzt t tt j|d d }Wn ttttfyuYnw|r|t|}|S) anReturn a string of concatenated compiled nodes. Throw an undefined error if any of the nodes is undefined. If the result of concat appears to be a dictionary, list or bool, try and convert it to such using literal_eval, the same mechanism as used in jinja2_native. Used in Templar.template() when jinja2_native=False and convert_data=True. FrT){[)TrueFalseevalmode)listrlenr&r r0rrrappendjoin startswithr literal_evalfix_missing_locationsrvisitparse TypeError ValueError SyntaxError MemoryErrorr )nodesheadunsafeout out_valuesvrrransible_eval_concatGsB         rNcCsJd}g}|D]}|st|rd}|t|qd|}|r#t|}|S)aReturn a string of concatenated compiled nodes. Throw an undefined error if any of the nodes is undefined. Other than that it is equivalent to Jinja2's default concat function. Used in Templar.template() when jinja2_native=False and convert_data=False. FTr2)r0r=rr>r )rHrJr*rMrKrrransible_concats  rOc Cs$tt|d}|s dSd}t|dkr2|d}t|tr|jSt|tr&|St|ts-|St|}n%t|t rrr@rCrDrErFrGr )rHrIrJrKrLrMevaledquoterrransible_native_concatsH            rSc@s0eZdZdZddZddZddZdd Zd S) r'z} A custom Undefined class, which returns further Undefined objects on access, rather than throwing an exception. cCs|dkrt||S)Nr")AttributeError)rnamerrr __getattr__szAnsibleUndefined.__getattr__cC|SNr)rkeyrrr __getitem__zAnsibleUndefined.__getitem__cCsd|j|j|jS)Nz3AnsibleUndefined(hint={0!r}, obj={1!r}, name={2!r}))format_undefined_hint_undefined_obj_undefined_name)rrrr__repr__s zAnsibleUndefined.__repr__cCrWrXr)ritemrrr __contains__r[zAnsibleUndefined.__contains__N)rrr__doc__rVrZr`rbrrrrr's  r')rrr r!)% __future__rrcollections.abcr itertoolsrrtypesr'ansible.module_utils.common.collectionsr+ansible.module_utils.common.text.convertersransible.module_utils.sixr ansible.parsing.yaml.objectsr ansible.utils.native_jinjar ansible.utils.unsafe_proxyr "ansible.module_utils.compat.typing module_utilscompattypingtjinja2.runtimer rNodeTransformerrr0rNrOrSr'rrrrs.           "9K