403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/plugins/lookup/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/plugins/lookup/__pycache__/csvfile.cpython-311.opt-1.pyc
�

���c�����ddlmZmZmZeZdZdZdZddl	Z	ddl
Z
ddlmZddl
mZmZddlmZdd	lmZdd
lmZddlmZmZmZGd�d
��ZGd�d��ZGd�de��ZdS)�)�absolute_import�division�print_functiona
    name: csvfile
    author: Jan-Piet Mens (@jpmens) <jpmens(at)gmail.com>
    version_added: "1.5"
    short_description: read data from a TSV or CSV file
    description:
      - The csvfile lookup reads the contents of a file in CSV (comma-separated value) format.
        The lookup looks for the row where the first column matches keyname (which can be multiple words)
        and returns the value in the C(col) column (default 1, which indexed from 0 means the second column in the file).
    options:
      col:
        description:  column to return (0 indexed).
        default: "1"
      default:
        description: what to return if the value is not found in the file.
      delimiter:
        description: field separator in the file, for a tab you can specify C(TAB) or C(\t).
        default: TAB
      file:
        description: name of the CSV/TSV file to open.
        default: ansible.csv
      encoding:
        description: Encoding (character set) of the used CSV file.
        default: utf-8
        version_added: "2.1"
    notes:
      - The default is for TSV files (tab delimited) not CSV (comma delimited) ... yes the name is misleading.
      - As of version 2.11, the search parameter (text that must match the first column of the file) and filename parameter can be multi-word.
      - For historical reasons, in the search keyname, quotes are treated
        literally and cannot be used around the string unless they appear
        (escaped as required) in the first column of the file you are parsing.
a�
- name:  Match 'Li' on the first column, return the second column (0 based index)
  ansible.builtin.debug: msg="The atomic number of Lithium is {{ lookup('ansible.builtin.csvfile', 'Li file=elements.csv delimiter=,') }}"

- name: msg="Match 'Li' on the first column, but return the 3rd column (columns start counting after the match)"
  ansible.builtin.debug: msg="The atomic mass of Lithium is {{ lookup('ansible.builtin.csvfile', 'Li file=elements.csv delimiter=, col=2') }}"

- name: Define Values From CSV File, this reads file in one go, but you could also use col= to read each in it's own lookup.
  ansible.builtin.set_fact:
    loop_ip: "{{ csvline[0] }}"
    int_ip: "{{ csvline[1] }}"
    int_mask: "{{ csvline[2] }}"
    int_name: "{{ csvline[3] }}"
    local_as: "{{ csvline[4] }}"
    neighbor_as: "{{ csvline[5] }}"
    neigh_int_ip: "{{ csvline[6] }}"
  vars:
    csvline = "{{ lookup('ansible.builtin.csvfile', bgp_neighbor_ip, file='bgp_neighbors.csv', delimiter=',') }}"
  delegate_to: localhost
zb
  _raw:
    description:
      - value(s) stored in file column
    type: list
    elements: str
N)�MutableSequence)�AnsibleError�AnsibleAssertionError)�parse_kv)�
LookupBase)�PY2)�to_bytes�	to_native�to_textc�*�eZdZdZdd�Zd�Zd�ZeZdS)�
CSVRecoderzP
    Iterator that reads an encoded stream and reencodes the input to UTF-8
    �utf-8c�J�tj|��|��|_dS�N)�codecs�	getreader�reader)�self�f�encodings   �C/usr/lib/python3.11/site-packages/ansible/plugins/lookup/csvfile.py�__init__zCSVRecoder.__init__Us"��0�f�&�x�0�0��3�3�����c��|Sr��rs r�__iter__zCSVRecoder.__iter__X����rc�P�t|j���d��S)Nr)�nextr�encoders r�__next__zCSVRecoder.__next__[s ���D�K� � �'�'��0�0�0rN)r)�__name__�
__module__�__qualname__�__doc__rr r%r#rrrrrQsQ��������4�4�4�4����1�1�1��D�D�Drrc�8�eZdZdZejdfd�Zd�ZeZd�Z	dS)�	CSVReaderzu
    A CSV reader which will iterate over lines in the CSV file "f",
    which is encoded in the given encoding.
    rc��trt||��}ntj|��|��}t	j|fd|i|��|_dS)N�dialect)rrrr�csvr)rrr-r�kwdss     rrzCSVReader.__init__gsW���	.��1�h�'�'�A�A�*�� ��*�*�1�-�-�A��j��<�<�G�<�t�<�<����rc�B�t|j��}d�|D��S)Nc�,�g|]}t|����Sr)r)�.0�ss  r�
<listcomp>z&CSVReader.__next__.<locals>.<listcomp>qs��(�(�(�q���
�
�(�(�(r)r#r)r�rows  rr%zCSVReader.__next__os%���4�;����(�(�C�(�(�(�(rc��|Srrrs rr zCSVReader.__iter__ur!rN)
r&r'r(r)r.�excelrr%r#r rrrr+r+as`��������
#&�)�g�=�=�=�=�)�)�)��D�����rr+c��eZdZdd�Zdd�ZdS)�LookupModulerN�c�R�	tt|��d��}t|t|��|���}|D]4}	t	|	��r#|	d|kr|	t|��cS�5n1#t$r$}
tdt|
��z���d}
~
wwxYw|S)N�rb)�	delimiterrrzcsvfile: %s)�openrr+r
�len�int�	Exceptionr)r�filename�keyr=r�dflt�colr�creaderr5�es           r�read_csvzLookupModule.read_csv{s���	=��X�h�'�'��.�.�A���Y�y�-A�-A�H�U�U�U�G��
)�
)���s�8�8�)��A��#�
�
��s�3�x�x�=�(�(�(��
)���	=�	=�	=��}�y��|�|�;�<�<�<�����	=�����s�A1A6�4A6�6
B$�B�B$c
��g}|�||���|���}|D�]O}t|��}d|vrtd���|d}	|���D];\}	}
|	dkr�|	|vrtd|	z���|���|
||	<�<n(#ttf$r}t|���d}~wwxYw|ddkrd|d<|�	|d|d	��}|�
|||d|d
|d|d��}
|
�Ft|
t��r|
D]}|�
|�����:|�
|
����Q|S)
N)�var_options�direct�_raw_paramsz(Search key is required but was not foundz%s is not a valid optionr=�TAB�	�files�filer�defaultrE)�set_options�get_optionsr	r�itemsr�_deprecate_inline_kv�
ValueError�AssertionError�find_file_in_search_pathrH�
isinstancer�append)r�terms�	variables�kwargs�ret�	paramvals�term�kvrC�name�valuerG�
lookupfile�var�vs               r�runzLookupModule.run�s��������Y�v��>�>�>��$�$�&�&�	��!	$�!	$�D��$���B��B�&�&�"�#M�N�N�N��]�#�C�
&�#%�8�8�:�:�,�,�K�D�%��}�,�,� ��9�,�,�3�4N�QU�4U�V�V�V��-�-�/�/�/�&+�I�d�O�O�,����/�
&�
&�
&�"�1�o�o�%�����
&������%��.�.�)-�	�+�&��6�6�y�'�9�U[�K\�]�]�J��-�-�
�C��;�1G��S]�I^�`i�js�`t�v�AF�wG�H�H�C����c�?�3�3�$� �&�&���
�
�1�
�
�
�
�&��J�J�s�O�O�O���
s�AB/�/C�C�C)rNr:r)r&r'r(rHrgrrrr9r9ys<����������,�,�,�,�,�,rr9)�
__future__rrr�type�
__metaclass__�
DOCUMENTATION�EXAMPLES�RETURNrr.�collections.abcr�ansible.errorsrr�ansible.parsing.splitterr	�ansible.plugins.lookupr
�ansible.module_utils.sixr�ansible.module_utils._textrr
rrr+r9rrr�<module>rtsW��C�B�B�B�B�B�B�B�B�B��
��
�B��*
���
�
�
�
�
�
�
�+�+�+�+�+�+�>�>�>�>�>�>�>�>�-�-�-�-�-�-�-�-�-�-�-�-�(�(�(�(�(�(�C�C�C�C�C�C�C�C�C�C�
�
�
�
�
�
�
�
� ��������0<�<�<�<�<�:�<�<�<�<�<r

Youez - 2016 - github.com/yon3zu
LinuXploit