
    VhH                    j    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	  e	       Z
dgZ G d de      Zy)	    )annotations)abstractmethod)AnsibleFileNotFound)AnsiblePlugin)Display
LookupBasec                  v     e Zd Zd	 fd	Zd Zed        Zed        Zed        Ze	d
d       Z
ddZd Z xZS )r   c                \    t         t        |           || _        || _        t
        | _        y N)superr   __init___loader_templardisplay_display)selfloadertemplarkwargs	__class__s       O/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/lookup/__init__.pyr   zLookupBase.__init__!   s'    j$(*      c                H    d|v r|d   S | j                   j                         S )N	role_path)r   get_basedir)r   	variabless     r   r   zLookupBase.get_basedir+   s(    )#[))<<++--r   c                    g }| D ];  }t        |t        t        f      r|j                  |       +|j	                  |       = |S r   )
isinstancelisttupleextendappend)termsretterms      r   _flattenzLookupBase._flatten1   sC     	!D$u.

4 

4 		!
 
r   c                r    g }| D ]/  }|D ](  }|j                  t        j                  ||g             * 1 |S r   )r"   r   r&   )abresultsxys        r   _combinezLookupBase._combine;   sG     	<A <z22Aq6:;<	< r   c                F    g }| D ]  }|j                  || |   d        |S )N)keyvalue)r"   )r#   r$   r/   s      r   _flatten_hash_to_listz LookupBase._flatten_hash_to_listC   s0     	:CJJsU3Z89	:
r   c                     y)a  
        When the playbook specifies a lookup, this method is run.  The
        arguments to the lookup become the arguments to this method.  One
        additional keyword argument named ``variables`` is added to the method
        call.  It contains the variables available to ansible at the time the
        lookup is templated.  For instance::

            "{{ lookup('url', 'https://toshio.fedorapeople.org/one.txt', validate_certs=True) }}"

        would end up calling the lookup plugin named url's run method like this::
            run(['https://toshio.fedorapeople.org/one.txt'], variables=available_variables, validate_certs=True)

        Lookup plugins can be used within playbooks for looping.  When this
        happens, the first argument is a list containing the terms.  Lookup
        plugins can also be called from within playbooks to return their
        values into a variable or parameter.  If the user passes a string in
        this case, it is converted into a list.

        Errors encountered during execution should be returned by raising
        AnsibleError() with a message describing the error.

        Any strings returned by this method that could ever contain non-ascii
        must be converted into python's unicode type as the strings will be run
        through jinja2 which has this requirement.  You can use::

            from ansible.module_utils.common.text.converters import to_text
            result_string = to_text(result_string)
        N )r   r#   r   r   s       r   runzLookupBase.runJ   s    < 	r   c           	         d|v r|d   }n| j                  |      g}d}	 | j                  j                  |||t        d|v             }|S # t        $ r$ |s| j
                  j                  d|z         Y |S w xY w)zL
        Return a file (needle) in the task's expected search path.
        ansible_search_pathNr   )is_rolez?Unable to find '%s' in expected paths (use -vvvvv to see paths))r   r   path_dwim_relative_stackboolr   r   warning)r   myvarssubdirneedleignore_missingpathsresults          r   find_file_in_search_pathz#LookupBase.find_file_in_search_pathj   s    
 !F*01E%%f-.E	r\\::5&&Z^_jnt_tZu:vF
 	 # 	r!%%&gjp&pq		rs   *A )A98A9c                     y r   r3   )r   s    r   _deprecate_inline_kvzLookupBase._deprecate_inline_kv}   s     	r   )NNr   )F)__name__
__module____qualname__r   r   staticmethodr&   r-   r1   r   r4   rA   rC   __classcell__)r   s   @r   r   r      sg     .        >&r   N)
__future__r   abcr   ansible.errorsr   ansible.pluginsr   ansible.utils.displayr   r   __all__r   r3   r   r   <module>rO      s2   $ #  . ) )
).a ar   