o nnhH@s\ddlmZddlmZddlmZddlmZddlm Z e Z dgZ GdddeZ dS) ) annotations)abstractmethod)AnsibleFileNotFound) AnsiblePlugin)Display LookupBasecsjeZdZdfdd ZddZeddZedd Zed d Ze dd d Z dddZ ddZ Z S)rNc s$tt|||_||_t|_dSN)superr__init___loader_templardisplay_display)selfloadertemplarkwargs __class__J/usr/local/lib/python3.10/dist-packages/ansible/plugins/lookup/__init__.pyr !s zLookupBase.__init__cCsd|vr|dS|jS)N role_path)r get_basedir)r variablesrrrr+s zLookupBase.get_basedircCs6g}|D]}t|ttfr||q||q|Sr) isinstancelisttupleextendappend)termsrettermrrr_flatten1s   zLookupBase._flattencCs0g}|D]}|D] }|t||gqq|Sr)rrr")abresultsxyrrr_combine;s zLookupBase._combinecCs&g}|D] }||||dq|S)N)keyvalue)r)rr r)rrr_flatten_hash_to_listCsz LookupBase._flatten_hash_to_listcKsdS)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) Nr)rrrrrrrrunJszLookupBase.runFcCstd|vr |d}n||g}d}z|jj|||td|vd}W|Sty9|s6|jd|Y|SY|Sw)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))rr path_dwim_relative_stackboolrrwarning)rmyvarssubdirneedleignore_missingpathsresultrrrfind_file_in_search_pathjs   z#LookupBase.find_file_in_search_pathcCsdSrr)rrrr_deprecate_inline_kv}szLookupBase._deprecate_inline_kv)NNr)F)__name__ __module__ __qualname__r r staticmethodr"r(r+rr,r8r9 __classcell__rrrrrs      N) __future__rabcransible.errorsransible.pluginsransible.utils.displayrr __all__rrrrrs