
    Vh
                     n    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ d dlmZ d dlmZ  G d	 d
e      Zy)    )absolute_importdivisionprint_functiona  
author: Unknown (!UNKNOWN)
name: cartesian
short_description: returns the cartesian product of lists
description:
  - Takes the input lists and returns a list that represents the product of the input lists.
  - It is clearer with an example, it turns [1, 2, 3], [a, b] into [1, a], [1, b], [2, a], [2, b], [3, a], [3, b].
  - You can see the exact syntax in the examples section.
options:
  _terms:
    description:
      - A set of lists.
    type: list
    elements: list
    required: true
a`  
- name: Example of the change in the description
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.cartesian', [1,2,3], [a, b])}}"

- name: loops over the cartesian product of the supplied lists
  ansible.builtin.debug:
    msg: "{{item}}"
  with_community.general.cartesian:
    - "{{list1}}"
    - "{{list2}}"
    - [1, 2, 3, 4, 5, 6]
zr
_list:
  description:
    - List of lists composed of elements of the input lists.
  type: list
  elements: list
)product)AnsibleError)
LookupBase)listify_lookup_plugin_termsc                       e Zd ZdZd ZddZy)LookupModulez/
    Create the cartesian product of lists
    c                     g }|D ]+  }	 t        || j                        }|j	                  |       - |S # t        $ r% t        || j                  | j                        }Y Bw xY w)z|
        Turn this:
            terms == ["1,2,3", "a,b"]
        into this:
            terms == [[1,2,3], [a, b]]
        )templar)r   loader)r	   _templar	TypeError_loaderappend)selftermsresultsxintermediates        n/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/lookup/cartesian.py_lookup_variableszLookupModule._lookup_variables<   sq      	)Aj:1dmmT
 NN<(	)   j  ;1dmm\`\h\hijs   5+A#"A#Nc                     | j                  ||       | j                  |      }|d d  }t        |      dk(  rt        d      t	        | D cg c]  }| j                  |       c}S c c}w )N)var_optionsdirectr   z9with_cartesian requires at least one element in each list)set_optionsr   lenr   r   _flatten)r   r   	variableskwargsmy_listr   s         r   runzLookupModule.runN   sh    Yv>&&u-(w<1Z[[*17*;<Qa <<<s   A()N)__name__
__module____qualname____doc__r   r#        r   r   r   7   s    $	=r)   r   N)
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURN	itertoolsr   ansible.errorsr   ansible.plugins.lookupr   ansible.utils.listifyr	   r   r(   r)   r   <module>r4      sB    C B"
  ' - = =:  =r)   