
    Vh                    J    d dl mZ dZdZdZd dlmZ d dlmZ  G d de      Z	y	)
    )annotationsa  
    name: indexed_items
    author: Michael DeHaan
    version_added: "1.3"
    short_description: rewrites lists to return 'indexed items'
    description:
      - use this lookup if you want to loop over an array and also get the numeric index of where you are in the array as you go
      - any list given will be transformed with each resulting element having the it's previous position in item.0 and its value in item.1
    options:
      _terms:
        description: list of items
        required: True
z
- name: indexed loop demo
  ansible.builtin.debug:
    msg: "at array position {{ item.0 }} there is a value {{ item.1 }}"
  with_indexed_items:
    - "{{ some_list }}"
z
  _raw:
    description:
      - list with each item.0 giving you the position and item.1 the value
    type: list
    elements: list
)AnsibleError)
LookupBasec                      e Zd ZddZd Zy)LookupModuleNc                    || _         y N)basedir)selfr
   kwargss      T/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/lookup/indexed_items.py__init__zLookupModule.__init__*   s	        c           	         t        |t              st        d      | j                  |      }t        t	        t        t        |            |            S )Nz!with_indexed_items expects a list)
isinstancelistr   _flattenziprangelen)r   terms	variablesr   itemss        r   runzLookupModule.run-   sA    %&BCCe$Cc%j)5122r   r	   )__name__
__module____qualname__r   r    r   r   r   r   (   s    3r   r   N)

__future__r   DOCUMENTATIONEXAMPLESRETURNansible.errorsr   ansible.plugins.lookupr   r   r   r   r   <module>r%      s3    #
 ( -3: 3r   