HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible/plugins/lookup/__pycache__/ini.cpython-39.pyc
a

�)gc�@s�ddlmZmZmZeZdZdZdZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZdd	lmZmZdd
lmZmZddlmZdd
�ZGdd�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)�
LookupBasecs�|��}tdd���g}d}t|���D]b\}}d|vrR|D]}d||vr<|}q<|dksb�|sv|�|<|�|�q(�|d|7<q(�fdd	�|D�S)
z.Safely split parameter term to preserve spacescSsdS)N��rrr�>/usr/lib/python3.9/site-packages/ansible/plugins/lookup/ini.py�<lambda>a�z_parse_params.<locals>.<lambda>�key�=z%s=r� csg|]}�|�qSrr)�.0�x��paramsrr�
<listcomp>wrz!_parse_params.<locals>.<listcomp>)�keysr�	enumerate�split�append)�term�	paramvalsZ
valid_keysrZthiskeyZidp�phrase�krrr�
_parse_params\sr"c@seZdZdd�Zddd�ZdS)�LookupModulecsR|r�fdd�|j�|�D�Sd}z|j�|��}WntjyL|YS0|S)Ncs g|]\}}t��|�r|�qSr)�re�match)rr!�v�rrrrrz*LookupModule.get_value.<locals>.<listcomp>)�cp�items�get�configparserZ
NoOptionError)�selfr�sectionZdfltZ	is_regexp�valuerr'r�	get_value|s
zLookupModule.get_valueNcKsz|j||d�|��}tj|�d|�d��d�|_|drBt|j_g}|D�](}|}d|vsjd|��v�r&|�	�t
||�}zVd}	|D]H}
d|
vr�|
�d�\}}||vr�td	|��|||<q�||kr�|
}d
}	q�Wn@t
�y}
z&td|
|t|
�f|
d��WYd}
~
n
d}
~
00|	�s&td
|��|�|d|d�}t�}|ddk�r^|�d�d|d<|j�|�\}}t|d|dd�}|�|�|�dtj�z|j�|�WnBtj�y�}z&tdj|dt|�d���WYd}~n
d}~00z |�||d|d|d�}Wn0tj�y<tdj|d|dd���Yn0|durJt|t��rj|D]}|�|��qVqJ|�|�qJ|S)N)Zvar_optionsZdirect�allow_no_valueZ
allow_none)r0Zcase_sensitiverrFz%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)�errorsr4rz%Duplicate option in '{file}': {error})r2�error�defaultr$z No section '{section}' in {file})r-r2) Zset_optionsZget_optionsr+ZConfigParserr*r(rZoptionxform�stripZ_deprecate_inline_kvr"rr�
ValueErrorr	Zfind_file_in_search_pathr�writeZ_loaderZ_get_file_contentsr
�seek�os�SEEK_SETZreadfpZDuplicateOptionError�formatr/ZNoSectionError�
isinstancerr)r,ZtermsZ	variables�kwargsr�retrrrZupdated_keyZparam�namer.�e�pathZconfig�contentsZ	show_dataZdoe�varr&rrr�run�sb



0

0  zLookupModule.run)N)�__name__�
__module__�__qualname__r/rGrrrrr#zsr#)Z
__future__rrrr3Z
__metaclass__Z
DOCUMENTATIONZEXAMPLESZRETURNr+r<r$�ior�collectionsr�collections.abcrZansible.errorsrr	Zansible.module_utils._textr
rZansible.plugins.lookuprr"r#rrrr�<module>s0