a )gs@sdddlmZmZmZeZdZdZdZddl Z ddl m Z ddl m Z ddlmZGd d d e ZdS) )absolute_importdivisionprint_functionaT name: together author: Bradley Young (!UNKNOWN) version_added: '1.3' short_description: merges lists into synchronized list description: - Creates a list with the iterated elements of the supplied lists - "To clarify with an example, [ 'a', 'b' ] and [ 1, 2 ] turn into [ ('a',1), ('b', 2) ]" - This is basically the same as the 'zip_longest' filter and Python function - Any 'unbalanced' elements will be substituted with 'None' options: _terms: description: list of lists to merge required: True z - name: item.0 returns from the 'a' list, item.1 returns from the '1' list ansible.builtin.debug: msg: "{{ item.0 }} and {{ item.1 }}" with_together: - ['a', 'b', 'c', 'd'] - [1, 2, 3, 4] zO _list: description: synchronized list type: list elements: list N) AnsibleError) LookupBase)listify_lookup_plugin_termsc@s"eZdZdZddZdddZdS) LookupModulez Transpose a list of arrays: [1, 2, 3], [4, 5, 6] -> [1, 4], [2, 5], [3, 6] Replace any empty spots in 2nd array with None: [1, 2], [3] -> [1, 3], [2, None] cCs*g}|D]}t||jd}||q|S)N)Ztemplar)rZ_templarappend)selftermsresultsxZ intermediaterC/usr/lib/python3.9/site-packages/ansible/plugins/lookup/together.py_lookup_variables5s  zLookupModule._lookup_variablesNc sH|}|dd}t|dkr*tdfddtj|ddiDS)Nrz8with_together requires at least one element in each listcsg|]}|qSr)Z_flatten).0r r rr Dz$LookupModule.run.. fillvalue)rlenr itertools zip_longest)r r Z variableskwargsZmy_listrrrrun<s    zLookupModule.run)N)__name__ __module__ __qualname____doc__rrrrrrr-sr)Z __future__rrrtypeZ __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNrZansible.errorsrZansible.plugins.lookuprZansible.utils.listifyrrrrrrs