관리-도구
편집 파일: indexed_items.cpython-39.opt-1.pyc
a �)g1 � @ sP d dl mZmZmZ eZdZdZdZd dl m Z d dlmZ G dd� 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 @ s e Zd Zddd�Zdd� ZdS )�LookupModuleNc K s || _ d S )N)�basedir)�selfr �kwargs� r �H/usr/lib/python3.9/site-packages/ansible/plugins/lookup/indexed_items.py�__init__+ s zLookupModule.__init__c K s2 t |t�std��| �|�}tttt|��|��S )Nz!with_indexed_items expects a list)� isinstance�listr Z_flatten�zip�range�len)r ZtermsZ variablesr �itemsr r r �run. s zLookupModule.run)N)�__name__� __module__�__qualname__r r r r r r r ) s r N)Z __future__r r r �typeZ __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNZansible.errorsr Zansible.plugins.lookupr r r r r r �<module> s