
    Vh>                    ^    d dl mZ dZdZdZd dlZd dlmZ d dlm	Z	 d dl
mZ  G d	 d
e	      Zy)    )annotationsaT  
    name: together
    author:  Bradley Young (!UNKNOWN) <young.bradley@gmail.com>
    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                      e Zd ZdZd ZddZy)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]
    c                h    g }|D ]*  }t        || j                        }|j                  |       , |S )N)templar)r   _templarappend)selftermsresultsxintermediates        O/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/lookup/together.py_lookup_variableszLookupModule._lookup_variables4   s9     	)A6q$--PLNN<(	)     Nc                    | j                  |      }|d d  }t        |      dk(  rt        d      t        j                  |dd iD cg c]  }| j                  |       c}S c c}w )Nr   z8with_together requires at least one element in each list	fillvalue)r   lenr   	itertoolszip_longest_flatten)r   r   	variableskwargsmy_listr   s         r   runzLookupModule.run;   sa    &&u-(w<1YZZ*3*?*?*YTX*YZQa ZZZs   A")N)__name__
__module____qualname____doc__r   r    r   r   r   r   ,   s    [r   r   )
__future__r   DOCUMENTATIONEXAMPLESRETURNr   ansible.errorsr   ansible.plugins.lookupr   ansible.utils.listifyr   r   r#   r   r   <module>r+      s;    # 
  ' - =[: [r   