a ì)g1ã@sPddlmZmZmZeZdZdZdZddl m Z ddl m Z Gdd„de ƒZ d S) é)Úabsolute_importÚdivisionÚprint_functionaÿ 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@seZdZddd„Zdd„ZdS)Ú LookupModuleNcKs ||_dS)N)Úbasedir)ÚselfrÚkwargs©r úH/usr/lib/python3.9/site-packages/ansible/plugins/lookup/indexed_items.pyÚ__init__+szLookupModule.__init__cKs2t|tƒstdƒ‚| |¡}tttt|ƒƒ|ƒƒS)Nz!with_indexed_items expects a list)Ú isinstanceÚlistrZ_flattenÚzipÚrangeÚlen)r ZtermsZ variablesr Úitemsr r r Úrun.s  zLookupModule.run)N)Ú__name__Ú __module__Ú __qualname__r rr r r r r)s rN)Z __future__rrrÚtypeZ __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNZansible.errorsrZansible.plugins.lookuprrr r r r Ús