ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/csv.cpython-311.pyc

�

�f�>���dZddlZddlmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZddlmZgd�ZGd�d��ZGd	�d
e��Zed
e��Gd�de��Zed
e��Gd�de��Zede��Gd�d��ZGd�d��Z	en
#e$reZYnwxYwGd�d��ZdS)z+
csv.py - read/write/investigate CSV files
�N)�Error�__version__�writer�reader�register_dialect�unregister_dialect�get_dialect�
list_dialects�field_size_limit�
QUOTE_MINIMAL�	QUOTE_ALL�QUOTE_NONNUMERIC�
QUOTE_NONE�__doc__)�Dialect)�StringIO)rr
rrrrr�excel�	excel_tabrrrrr	r
�Snifferrr�
DictReader�
DictWriter�unix_dialectc�B�eZdZdZdZdZdZdZdZdZ	dZ
dZdZd�Z
d�ZdS)rz�Describe a CSV dialect.

    This must be subclassed (see csv.excel).  Valid attributes are:
    delimiter, quotechar, escapechar, doublequote, skipinitialspace,
    lineterminator, quoting.

    �FNc�\�|jtkrd|_|���dS)NT)�	__class__r�_valid�	_validate��selfs �*/opt/alt/python311/lib64/python3.11/csv.py�__init__zDialect.__init__*s,���>�W�$�$��D�K���������c��	t|��dS#t$r!}tt|�����d}~wwxYw�N)�_Dialect�	TypeErrorr�str)r �es  r!rzDialect._validate/sG��	 ��T�N�N�N�N�N���	 �	 �	 ���A���-�-������	 ���s��
>�9�>)�__name__�
__module__�__qualname__r�_namer�	delimiter�	quotechar�
escapechar�doublequote�skipinitialspace�lineterminator�quotingr"r�r#r!rrsl��������
�E�
�F��I��I��J��K����N��G����
 � � � � r#rc�*�eZdZdZdZdZdZdZdZe	Z
dS)rz;Describe the usual properties of Excel-generated CSV files.�,�"TF�
N)r*r+r,rr.r/r1r2r3rr4r5r#r!rr6s3������E�E��I��I��K����N��G�G�Gr#rc��eZdZdZdZdS)rzEDescribe the usual properties of Excel-generated TAB-delimited files.�	N)r*r+r,rr.r5r#r!rr@s������O�O��I�I�Ir#rz	excel-tabc�*�eZdZdZdZdZdZdZdZe	Z
dS)rz:Describe the usual properties of Unix-generated CSV files.r7r8TF�
N)r*r+r,rr.r/r1r2r3r
r4r5r#r!rrEs3������D�D��I��I��K����N��G�G�Gr#r�unixc�\�eZdZ		dd�Zd�Zed���Zejd���Zd�ZdS)	rNrc�x�||_||_||_t||g|�Ri|��|_||_d|_dS�Nr)�_fieldnames�restkey�restvalr�dialect�line_num)r �f�
fieldnamesrCrDrE�args�kwdss        r!r"zDictReader.__init__QsK��%����������Q��7�$�7�7�7�$�7�7��������
�
�
r#c��|Sr%r5rs r!�__iter__zDictReader.__iter__Zs���r#c��|j�+	t|j��|_n#t$rYnwxYw|jj|_|jSr%)rB�nextr�
StopIterationrFrs r!rHzDictReader.fieldnames]sZ����#�
�#'���#4�#4�� � �� �
�
�
���
������,��
���s�#�
0�0c��||_dSr%)rB)r �values  r!rHzDictReader.fieldnamesgs�� ����r#c��|jdkr|jt|j��}|jj|_|gkrt|j��}|gk�t	t|j|����}t
|j��}t
|��}||kr||d�||j<n"||kr|j|d�D]}|j||<�
|SrA)	rFrHrNr�dict�zip�lenrCrD)r �row�d�lf�lr�keys      r!�__next__zDictReader.__next__ks����=�A����O�O��4�;������,��
�
�R�i�i��t�{�#�#�C��R�i�i���T�_�c�*�*�+�+��
���
!�
!��
��X�X��
��7�7�!�"�#�#�h�A�d�l�O�O�
�"�W�W���r�s�s�+�
&�
&�����#����r#)NNNr)	r*r+r,r"rL�propertyrH�setterr[r5r#r!rrPs�������AE� ��������� � ��X� ���!�!���!�����r#rc�2�eZdZ		d
d�Zd�Zd�Zd�Zd�Zd	S)rr�raiserc��||_||_|���dvrtd|z���||_t||g|�Ri|��|_dS)N)r_�ignorez-extrasaction (%s) must be 'raise' or 'ignore')rHrD�lower�
ValueError�extrasactionr)r rGrHrDrdrErIrJs        r!r"zDictWriter.__init__�sr��$�����������':�:�:��L�+�,�-�-�
-�(����Q��7�$�7�7�7�$�7�7����r#c�z�tt|j|j����}|�|��Sr%)rSrTrH�writerow)r �headers  r!�writeheaderzDictWriter.writeheader�s/���c�$�/�4�?�;�;�<�<���}�}�V�$�$�$r#c������jdkrM�����jz
}|r/tdd�d�|D����z�����fd��jD��S)Nr_z(dict contains fields not in fieldnames: z, c�,�g|]}t|����Sr5)�repr)�.0�xs  r!�
<listcomp>z,DictWriter._dict_to_list.<locals>.<listcomp>�s��-L�-L�-L�!�d�1�g�g�-L�-L�-Lr#c3�N�K�|]}��|�j��V�� dSr%)�getrD)rlrZ�rowdictr s  ��r!�	<genexpr>z+DictWriter._dict_to_list.<locals>.<genexpr>�s3�����J�J�3����C���.�.�J�J�J�J�J�Jr#)rd�keysrHrc�join)r rq�wrong_fieldss`` r!�
_dict_to_listzDictWriter._dict_to_list�s��������'�'�"�<�<�>�>�D�O�;�L��
O� �!K�#'�9�9�-L�-L�|�-L�-L�-L�#M�#M�"N�O�O�O�J�J�J�J�J�$�/�J�J�J�Jr#c�\�|j�|�|����Sr%)rrfrv)r rqs  r!rfzDictWriter.writerow�s&���{�#�#�D�$6�$6�w�$?�$?�@�@�@r#c�\�|j�t|j|����Sr%)r�	writerows�maprv)r �rowdictss  r!ryzDictWriter.writerows�s%���{�$�$�S��);�X�%F�%F�G�G�Gr#N)rr_r)r*r+r,r"rhrvrfryr5r#r!rr�su������?F� �8�8�8�8�%�%�%�K�K�K�A�A�A�H�H�H�H�Hr#rc�2�eZdZdZd�Zdd�Zd�Zd�Zd�ZdS)	rze
    "Sniffs" the format of a CSV file (i.e. delimiter, quotechar)
    Returns a Dialect object.
    c��gd�|_dS)N)r7r;�;� �:)�	preferredrs r!r"zSniffer.__init__�s��3�3�3����r#Nc��|�||��\}}}}|s|�||��\}}|std���Gd�dt��}||_||_|pd|_||_|S)zI
        Returns a dialect (or None) corresponding to the sample
        zCould not determine delimiterc��eZdZdZdZeZdS)�Sniffer.sniff.<locals>.dialect�sniffedr9N)r*r+r,r-r3rr4r5r#r!rEr��s�������E�#�N�#�G�G�Gr#rEr8)�_guess_quote_and_delimiter�_guess_delimiterrrr1r.r/r2)r �sample�
delimitersr/r1r.r2rEs        r!�sniffz
Sniffer.sniff�s����2�2�6�:�F�F�	<�	�;�	�+;��	L�*.�*?�*?��@J�+L�+L�'�I�'��	9��7�8�8�8�	$�	$�	$�	$�	$�g�	$�	$�	$�*���%���%�,����#3�� ��r#c�J�g}dD]G}tj|tjtjz��}|�|��}|rn�H|sdSi}i}d}|j}	|D]�}
|	ddz
}|
|}|r|�|d��dz||<	|	ddz
}|
|}n#t$rY�TwxYw|r"|�||vr|�|d��dz||<	|	ddz
}n#t$rY��wxYw|
|r|dz
}��t||j�	��}
|r+t||j�	��}|||k}|d
krd}nd}d}tjdtj	|��|
d
�ztj��}|�
|��rd}nd}|
|||fS)a�
        Looks for text enclosed between two identical quotes
        (the probable quotechar) which are preceded and followed
        by the same character (the probable delimiter).
        For example:
                         ,'some text',
        The quote with the most wins, same with the delimiter.
        If there is no quotechar the delimiter can't be determined
        this way.
        )zI(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?P=delim)zG(?:^|\n)(?P<quote>["\']).*?(?P=quote)(?P<delim>[^\w\n"\'])(?P<space> ?)zG(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?:$|\n)z-(?:^|\n)(?P<quote>["\']).*?(?P=quote)(?:$|\n))rFNrr�quote��delimN�space�rZr=rz]((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$))r�r�TF)�re�compile�DOTALL�	MULTILINE�findall�
groupindexrp�KeyError�max�escape�search)r �datar��matches�restr�regexp�quotes�delims�spacesr��m�nrZr/r�r2�	dq_regexpr1s                  r!r�z"Sniffer._guess_quote_and_delimiter�sQ����H�	�	�E��Z��r�y�2�<�'?�@�@�F��n�n�T�*�*�G��
���
��	(�'�'��������&�
��	�	�A��7�#�a�'�A��A�$�C��
5�$�j�j��a�0�0�1�4��s��
��w�'�!�+����d�����
�
�
���
�����
5�
�*�c�Z�.?�.?�$�j�j��a�0�0�1�4��s��
��w�'�!�+�����
�
�
���
������t�
��!������F�J�/�/�/�	��	!���F�J�/�/�/�E�%�e�}��6����}�}�����E� ���J��(*�	�%�(8�(8�)�L�L� M�NP�l�\�\�	����D�!�!�	 ��K�K��K��;��/?�@�@s$�B(�(
B5�4B5�C)�)
C6�5C6c�.�ttd|�d������}d�td��D��}t	dt|����}d}i}i}i}d|}
}	|	t|��k�r�|dz
}||	|
�D]S}|D]N}|�|i��}
|�|��}|
�|d��dz|
|<|
||<�O�T|���D]�}t||�	����}t|��dkr|dddkr�Ot|��dkrjt|d��	��||<|�||��||d||dtd
�|D����z
f||<��|d||<��|�	��}tt	||zt|������}d}d}t|��dkr^||krX|D]7\}}|ddkr&|ddkr|d|z|kr|�||vr|||<�8|d
z}t|��dkr||k�Xt|��dkrft|�����d}|d�|��|d�d|z��k}||fS|
}	|
|z
}
|	t|��k���|sdSt|��dkra|jD]Y}||���vrA|d�|��|d�d|z��k}||fcS�Zd�|�	��D��}|���|dd}|d�|��|d�d|z��k}||fS)a�
        The delimiter /should/ occur the same number of times on
        each row. However, due to malformed data, it may not. We don't want
        an all or nothing approach, so we allow for small variations in this
        number.
          1) build a table of the frequency of each character on every line.
          2) build a table of frequencies of this frequency (meta-frequency?),
             e.g.  'x occurred 5 times in 10 rows, 6 times in 1000 rows,
             7 times in 2 rows'
          3) use the mode of the meta-frequency to determine the /expected/
             frequency for that character
          4) find out how often the character actually meets that goal
          5) the character that best meets its goal is the delimiter
        For performance reasons, the data is evaluated in chunks, so it can
        try and evaluate the smallest portion of the data possible, evaluating
        additional chunks as necessary.
        Nr=c�,�g|]}t|����Sr5)�chr)rl�cs  r!rnz,Sniffer._guess_delimiter.<locals>.<listcomp>-s��,�,�,�A��Q���,�,�,r#��
rr�c��|dS)Nr�r5)rms r!�<lambda>z*Sniffer._guess_delimiter.<locals>.<lambda>Gs
��1�Q�4�r#r�c3�&K�|]}|dV��
dS)r�Nr5)rl�items  r!rrz+Sniffer._guess_delimiter.<locals>.<genexpr>Ls&����(C�(C�T��a��(C�(C�(C�(C�(C�(Cr#g�?g�������?g{�G�z�?z%c )rrc��g|]	\}}||f��
Sr5r5)rl�k�vs   r!rnz,Sniffer._guess_delimiter.<locals>.<listcomp>vs ��3�3�3�5�A�a�!�A��3�3�3r#���)�list�filter�split�range�minrUrp�countrs�itemsr��remove�sum�floatr��sort)r r�r��ascii�chunkLength�	iteration�
charFrequency�modesr��start�end�line�char�
metaFrequency�freqr��modeList�total�consistency�	thresholdr�r�r�r2rWs                         r!r�zSniffer._guess_delimitersf��&�F�4����D�!1�!1�2�2�3�3��,�,��s���,�,�,���"�c�$�i�i�(�(���	��
�������s���c�$�i�i�����N�I��U�3�Y��
8�
8��!�8�8�D�$1�$5�$5�d�B�$?�$?�M��:�:�d�+�+�D�*7�*;�*;�D�!�*D�*D�q�*H�M�$�'�*7�M�$�'�'�
8�&�*�*�,�,�

+�

+���]�4�0�6�6�8�8�9�9���u�:�:��?�?�u�Q�x��{�a�'7�'7���u�:�:��>�>�"%�e���"@�"@�"@�E�$�K��L�L��t��-�-�-�#(��;�q�>�5��;�q�>�%(�(C�(C�U�(C�(C�(C�%C�%C�4D�#E�E�$�K�K�#(��(�E�$�K�K��{�{�}�}�H��#�k�I�5�s�4�y�y�A�A�B�B�E��K��I��f�+�+��"�"�{�i�'?�'?�$�*�*�D�A�q���t�a�x�x�A�a�D�1�H�H��q�T�%�Z�K�7�7�'�/�1�
�?�?�()�F�1�I���t�#��
�f�+�+��"�"�{�i�'?�'?��6�{�{�a����V�[�[�]�]�+�+�A�.��$(��G�M�M�%�$8�$8�$(��G�M�M�%�%�-�$@�$@�%A� ��/�0�0��E��;��C�c�c�$�i�i���f�	��7��v�;�;��?�?��^�
1�
1������
�
�%�%�(,�Q��
�
�a�(8�(8�(,�Q��
�
�e�a�i�(@�(@�)A�$��/�0�0�0�0�&�4�3�F�L�L�N�N�3�3�3��
�
�
�����b�	�!��� ��G�M�M�%�0�0� ��G�M�M�%�%�-�8�8�9���'�(�(r#c�b�tt|��|�|����}t|��}t	|��}i}t|��D]}d||<�d}|D]�}|dkrn�|dz
}t	|��|kr�#t
|�����D]e}	t}
	|
||	��n,#ttf$rt	||	��}
YnwxYw|
||	kr||	�|
||	<�b||	=�f��d}|���D]}\}	}t|��td��kr%t	||	��|kr|dz
}�D|dz}�J	|||	��|dz}�b#ttf$r|dz
}Y�zwxYw|dkS)Nr�r�)rrr�rNrUr�r�rs�complexrc�
OverflowErrorr��typer')
r r��rdrrg�columns�columnTypes�i�checkedrV�col�thisType�	hasHeader�colTypes
             r!�
has_headerzSniffer.has_headers���X�f�%�%�t�z�z�&�'9�'9�:�:���c�����f�+�+�����w���6�6�A�$��Q������	-�	-�C���|�|����q�L�G��3�x�x�7�"�"���K�,�,�.�.�/�/�
-�
-��"��-��H�S��X�&�&�&�&��"�M�2�-�-�-�"�3�s�8�}�}�H�H�H�-�����{�3�/�/�/�"�3�'�/�+3��C�(�(�(��,��
-�$�	�'�-�-�/�/�	#�	#�L�C���G�}�}��Q���'�'��v�c�{�#�#�w�.�.���N�I�I���N�I�I�#��G�F�3�K�(�(�(���N�I�I��#�I�.�#�#�#���N�I�I�I�#����
�1�}�s$�:C�&C5�4C5�8F�F(�'F(r%)	r*r+r,rr"r�r�r�r�r5r#r!rr�sy��������4�4�4�
����:IA�IA�IA�Xd)�d)�d)�N=�=�=�=�=r#r)rr��_csvrrrrrrr	r
rrr
rrrr&�ior�__all__rrrrrr��	NameErrorr�rr5r#r!�<module>r�s�����
�	�	�	���������������������������������
%�$�$�$�$�$����������� � � � � � � � �>�����G�������%� � � �������������i�(�(�(������7��������&�&�&�/�/�/�/�/�/�/�/�dH�H�H�H�H�H�H�H�<��G�G�������G�G�G�����W�W�W�W�W�W�W�W�W�Ws�-B0�0B:�9B:

Zerion Mini Shell 1.0