관리-도구
편집 파일: ini.cpython-39.opt-1.pyc
a �����)gc����������������������@���s����d�dl�mZmZmZ�eZdZdZdZd�dl Z d�dl Z d�dlZd�dlm Z �d�dlmZ�d�dlmZ�d�d lmZmZ�d�d lmZmZ�d�dlmZ�dd ��ZG�dd��de�ZdS�)�����)�absolute_import�division�print_functiona��� name: ini author: Yannig Perre (!UNKNOWN) <yannig.perre(at)gmail.com> version_added: "2.0" short_description: read data from an ini file description: - "The ini lookup reads the contents of a file in INI format C(key1=value1). This plugin retrieves the value on the right side after the equal sign C('=') of a given section C([section])." - "You can also read a property file which - in this case - does not contain section." options: _terms: description: The key(s) to look up. required: True type: description: Type of the file. 'properties' refers to the Java properties files. default: 'ini' choices: ['ini', 'properties'] file: description: Name of the file to load. default: 'ansible.ini' section: default: global description: Section where to lookup the key. re: default: False type: boolean description: Flag to indicate if the key supplied is a regexp. encoding: default: utf-8 description: Text encoding to use. default: description: Return value if the key is not in the ini file. default: '' case_sensitive: description: Whether key names read from C(file) should be case sensitive. This prevents duplicate key errors if keys only differ in case. default: False version_added: '2.12' allow_no_value: description: - Read an ini file which contains key without value and without '=' symbol. type: bool default: False aliases: ['allow_none'] version_added: '2.12' a��� - ansible.builtin.debug: msg="User in integration is {{ lookup('ansible.builtin.ini', 'user', section='integration', file='users.ini') }}" - ansible.builtin.debug: msg="User in production is {{ lookup('ansible.builtin.ini', 'user', section='production', file='users.ini') }}" - ansible.builtin.debug: msg="user.name is {{ lookup('ansible.builtin.ini', 'user.name', type='properties', file='user.properties') }}" - ansible.builtin.debug: msg: "{{ item }}" loop: "{{ q('ansible.builtin.ini', '.*', section='section1', file='test.ini', re=True) }}" - name: Read an ini file with allow_no_value ansible.builtin.debug: msg: "{{ lookup('ansible.builtin.ini', 'user', file='mysql.ini', section='mysqld', allow_no_value=True) }}" z` _raw: description: - value(s) of the key(s) in the ini file type: list elements: str N)�StringIO)�defaultdict)�MutableSequence)�AnsibleLookupError�AnsibleOptionsError)�to_text� to_native)� LookupBasec��������������������s����|����}tdd�����g�}d}t|�����D�]b\}}d|v�rR|D�]}d|�|v�r<|}q<|dksb��|�sv|��|<�|�|��q(��|��d|�7��<�q(��fdd �|D��S�) z.Safely split parameter term to preserve spacesc�������������������S���s���dS�)N����r���r���r����>/usr/lib/python3.9/site-packages/ansible/plugins/lookup/ini.py�<lambda>a��������z_parse_params.<locals>.<lambda>�key�=z%s=r���� c��������������������s���g�|�]}��|��qS�r���r���)�.0�x��paramsr���r���� <listcomp>w���r���z!_parse_params.<locals>.<listcomp>)�keysr���� enumerate�split�append)�term� paramvalsZ valid_keysr���ZthiskeyZidp�phrase�kr���r���r���� _parse_params\���s����r"���c�������������������@���s���e�Zd�Zdd��Zddd�ZdS�)�LookupModulec��������������������sR���|r��fdd�|�j��|�D��S�d�}z|�j��|���}W�n�tjyL���|�Y�S�0�|S�)Nc��������������������s ���g�|�]\}}t����|�r|�qS�r���)�re�match)r���r!����v�r���r���r���r������r���z*LookupModule.get_value.<locals>.<listcomp>)�cp�items�get�configparserZ NoOptionError)�selfr����sectionZdfltZ is_regexp�valuer���r'���r���� get_value|���s���� zLookupModule.get_valueNc�����������������K���sz��|�j�||d��|����}tj|�d|�d��d�|�_|d�rBt|�j_g�}|D��](}|}d|v�sjd|���v��r&|�� ���t ||�}zVd} |D�]H} d| v�r�| �d�\}}||vr�td |���|||<�q�||kr�| }d } q�W�n@�t �y�} �z&td| |t| �f�| d��W�Y�d�} ~ n d�} ~ 0�0�| �s&td |���|��|d|d��}t��}|d�dk�r^|�d��d|d<�|�j�|�\}}t|d|d�d�}|�|��|�dtj��z|�j�|��W�nB�tj�y��}�z&tdj|d�t|�d���W�Y�d�}~n d�}~0�0�z |��||d�|d�|d��}W�n0�tj�y<���tdj|d�|d�d���Y�n0�|d�urJt|t��rj|D�]}|�|���qVqJ|�|��qJ|S�)N)Zvar_optionsZdirect�allow_no_valueZ allow_none)r0���Zcase_sensitiver���r���Fz%s is not a valid option.Tz Could not use '%s' from '%s': %s)Zorig_exczMNo key to lookup was provided as first term with in string inline options: %s�files�file�typeZ propertiesz[java_properties] Zjava_propertiesr-���Zsurrogate_or_strict�encoding)�errorsr4���r���z%Duplicate option in '{file}': {error})r2����error�defaultr$���z No section '{section}' in {file})r-���r2���) Zset_optionsZget_optionsr+���ZConfigParserr*���r(���r���Zoptionxform�stripZ_deprecate_inline_kvr"���r���r���� ValueErrorr ���Zfind_file_in_search_pathr����writeZ_loaderZ_get_file_contentsr ����seek�os�SEEK_SETZreadfpZDuplicateOptionError�formatr/���ZNoSectionError� isinstancer���r���)r,���ZtermsZ variables�kwargsr����retr���r���r���Zupdated_keyZparam�namer.����e�pathZconfig�contentsZ show_dataZdoe�varr&���r���r���r����run����sb���� 0 0 zLookupModule.run)N)�__name__� __module__�__qualname__r/���rG���r���r���r���r���r#���z���s���r#���)Z __future__r���r���r���r3���Z __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNr+���r<���r$����ior����collectionsr����collections.abcr���Zansible.errorsr���r ���Zansible.module_utils._textr ���r���Zansible.plugins.lookupr���r"���r#���r���r���r���r����<module>���s���0