a ì)gfã@shddlmZmZmZeZddlmZddlm Z ddl m Z ddl m Z e ƒZdgZGdd„de ƒZdS) é)Úabsolute_importÚdivisionÚprint_function)Úabstractmethod)ÚAnsibleFileNotFound)Ú AnsiblePlugin)ÚDisplayÚ LookupBasecsjeZdZd‡fdd„ Zdd„Zedd„ƒZedd „ƒZed d „ƒZe dd d „ƒZ ddd„Z dd„Z ‡Z S)r Nc s$tt|ƒ ¡||_||_t|_dS©N)Úsuperr Ú__init__Ú_loaderZ_templarÚdisplayÚ_display)ÚselfÚloaderZtemplarÚkwargs©Ú __class__©úC/usr/lib/python3.9/site-packages/ansible/plugins/lookup/__init__.pyr #szLookupBase.__init__cCsd|vr|dS|j ¡SdS)NZ role_path)r Ú get_basedir)rÚ variablesrrrr-szLookupBase.get_basedircCs6g}|D](}t|ttfƒr&| |¡q| |¡q|Sr )Ú isinstanceÚlistÚtupleÚextendÚappend)ÚtermsÚretZtermrrrÚ_flatten3s   zLookupBase._flattencCs0g}|D]"}|D]}| t ||g¡¡qq|Sr )rr r )ÚaÚbÚresultsÚxÚyrrrÚ_combine=s zLookupBase._combinecCs&g}|D]}| |||dœ¡q|S)N)ÚkeyÚvalue)r)rrr'rrrÚ_flatten_hash_to_listEsz 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._text import to_text result_string = to_text(result_string) Nr)rrrrrrrÚrunLszLookupBase.runFcCsbd|vr|d}n | |¡g}d}z|j |||¡}Wn&ty\|sX|j d|¡Yn0|S)zL Return a file (needle) in the task's expected search path. Zansible_search_pathNz?Unable to find '%s' in expected paths (use -vvvvv to see paths))rr Zpath_dwim_relative_stackrrZwarning)rZmyvarsZsubdirZneedleZignore_missingÚpathsÚresultrrrÚfind_file_in_search_pathls   z#LookupBase.find_file_in_search_pathcCsdSr r)rrrrÚ_deprecate_inline_kvszLookupBase._deprecate_inline_kv)NN)N)F)Ú__name__Ú __module__Ú __qualname__r rÚ staticmethodr r&r)rr*r-r.Ú __classcell__rrrrr !s      N)Z __future__rrrÚtypeZ __metaclass__ÚabcrZansible.errorsrZansible.pluginsrZansible.utils.displayrrÚ__all__r rrrrÚs