HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible/playbook/__pycache__/conditional.cpython-39.pyc
a

�)g�'�@s�ddlmZmZmZeZddlZddlZddlm	Z	ddl
mZddlm
ZddlmZmZmZddlmZddlmZmZdd	lmZdd
lmZe�Ze�d�Ze�d�Ze�d
�Z Gdd�d�Z!dS)�)�absolute_import�division�print_functionN)�generate)�UndefinedError)�	constants)�AnsibleError�AnsibleUndefinedVariable�AnsibleTemplateError)�	text_type)�	to_native�to_text)�FieldAttribute)�DisplayzF(hostvars\[.+\]|[\w_]+)\s+(not\s+is|is|is\s+not)\s+(defined|undefined)zlookup\s*\(z^[_A-Za-z][_a-zA-Z0-9]*$csReZdZdZededdd�Zd�fdd�	Zdd	�Zd
d�Z	dd
�Z
dd�Z�ZS)�Conditionalz�
    This is a mix-in class, to be used with Base to allow the object
    to be run conditionally when a condition is met or skipped.
    �listT)Zisa�default�extendZprependNcs4t|d�s"|durtd��n||_tt|���dS)N�_loaderz<a loader must be specified when using Conditional() directly)�hasattrrr�superr�__init__)�self�loader��	__class__��@/usr/lib/python3.9/site-packages/ansible/playbook/conditional.pyr3s


zConditional.__init__cCst|t�st|||g�dS�N)�
isinstancer�setattr)r�attr�name�valuerrr�_validate_when>s
zConditional._validate_whencCsDg}|}t�|�}|r@|�|���||��d�}t�|�}q|Sr)�
DEFINED_REGEX�search�append�groups�end)r�conditional�resultsZcond�mrrr�extract_defined_undefinedBs
z%Conditional.extract_defined_undefinedc
Cs�d}t|d�rt|d�}d}zf|jD]Z}|dus8|dkr>d}nt|t�rN|}n|�|||�}|rd|}t�d||f�|s$q�q$Wn@ty�}z(t	dt
|�t
|�f|d��WYd}~n
d}~00|S)z}
        Loops through the conditionals set on this object, returning
        False if any of them evaluate as such.
        NZ_dsT�zEvaluated conditional (%s): %sz4The conditional check '%s' failed. The error was: %s)�obj)r�getattr�whenr�bool�_check_conditional�display�debug�	Exceptionrr)r�templar�all_varsZds�resultr*�res�errr�evaluate_conditionalNs&	




2z Conditional.evaluate_conditionalcs*�}|���rt�d��||_�zt�d��|j��d��t�t�rP�dkrV�WSt�d�rhtd��G���fdd�dt	j
��zB|j��dd�}t
||jdd�}t	j|d	d
�}��}|�|�Wn4ty�}ztdt|���WYd}~n
d}~00d�}	|j|	�d���}
|
d
k�r$WdS|
dk�r4WdStd|��Wn�ttf�y$}z�z�t�d��t|����d}|���}|D]`\}
}}|�dd�|
�dd�k�r�d|v|dkk}|�r�WWYd}~dSWWYd}~dS�q��Wn$t�ytd||f��Yn0WYd}~n
d}~00dS)z�
        This method does the low-level evaluation of each conditional
        set on this object, using jinja2 to wrap the conditionals for
        evaluation.
        zjconditional statements should not include jinja2 templating delimiters such as {{ }} or {%% %%}. Found: %sZ
__UNSAFE__)�disable_lookupsr.z9Conditional is marked as unsafe, and cannot be evaluated.cseZdZd���fdd�	ZdS)z<Conditional._check_conditional.<locals>.CleansingNodeVisitorFcs�t|tj�rd}ndt|tj�r$d}nRt|tj�rv�rv|rR|j�d�rRtd���n$|rvtj|jdd�}��}|�	|�t�
|�D]}|j|||d�q�dS)NT�__z-Invalid access found in the conditional: '%s'�exec��mode)�inside_call�inside_yield)r�astZCallZYieldZStr�s�
startswithr�parse�visitZiter_child_nodes�
generic_visit)rZnoderBrC�parsed�cnvZ
child_node��CleansingNodeVisitorr*r=rrrI�s(�
�zJConditional._check_conditional.<locals>.CleansingNodeVisitor.generic_visitN)FF)�__name__�
__module__�__qualname__rIrrLrrrM�srMNr?r@z Invalid conditional detected: %sz3{%% if %s %%} True {%% else %%} False {%% endif %%}�TrueT�FalseFz"unable to evaluate conditional: %sz&'(hostvars\[.+\]|[\w_]+)' is undefinedr�'�"�notZdefinedz+error while evaluating conditional (%s): %s)Zis_templater4ZwarningZavailable_variablesr�templaterrr
rDZNodeVisitorZenvironmentrGrrHr6rr�stripr	r�re�compiler&�strr(r-�replace)rr*r7r8�originalr:rJrKr;Z	presented�valZvar_nameZ	def_undefZdu_varZlogic�stateZshould_existrrLrr3tsT
�

&


zConditional._check_conditional)N)
rNrOrP�__doc__rrr1rr$r-r<r3�
__classcell__rrrrr*s&r)"Z
__future__rrr�typeZ
__metaclass__rDrXZjinja2.compilerrZjinja2.exceptionsrZansibler�CZansible.errorsrr	r
Zansible.module_utils.sixrZansible.module_utils._textrr
Zansible.playbook.attributerZansible.utils.displayrr4rYr%ZLOOKUP_REGEXZVALID_VAR_REGEXrrrrr�<module>s