%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.12/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.12/__pycache__/csv.cpython-312.pyc

�

���f@��H�dZddlZddlZddlmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZddlmZddlmZgd�ZGd�d�ZGd	�d
e�Zed
e�Gd�de�Zed
e�Gd�de�Zede�Gd�d�ZGd�d�ZGd�d�Zy)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�
QUOTE_STRINGS�
QUOTE_NOTNULL�__doc__)�Dialect)�StringIO)rr
rrrrrrr�excel�	excel_tabrrrrr	r
�Snifferrr�
DictReader�
DictWriter�unix_dialectc�@�eZdZdZdZdZdZdZdZdZ	dZ
dZdZd�Z
d�Zy)rz�Describe a CSV dialect.

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

    �FNc�X�|jtk7rd|_|j�y)NT)�	__class__r�_valid�	_validate��selfs �/usr/lib/python3.12/csv.py�__init__zDialect.__init__-s���>�>�W�$��D�K�����c�f�	t|�y#t$r}tt|���d}~wwxYw�N)�_Dialect�	TypeErrorr�str)r"�es  r#r zDialect._validate2s,��	 ��T�N���	 ���A��-���	 �s��	0�+�0)�__name__�
__module__�__qualname__r�_namer�	delimiter�	quotechar�
escapechar�doublequote�skipinitialspace�lineterminator�quotingr$r �r%r#rrsA���
�E�
�F��I��I��J��K����N��G��
 r%rc�(�eZdZdZdZdZdZdZdZe	Z
y)rz;Describe the usual properties of Excel-generated CSV files.�,�"TF�
N)r,r-r.rr0r1r3r4r5rr6r7r%r#rr9s$��E��I��I��K����N��Gr%rc��eZdZdZdZy)rzEDescribe the usual properties of Excel-generated TAB-delimited files.�	N)r,r-r.rr0r7r%r#rrCs
��O��Ir%rz	excel-tabc�(�eZdZdZdZdZdZdZdZe	Z
y)rz:Describe the usual properties of Unix-generated CSV files.r9r:TF�
N)r,r-r.rr0r1r3r4r5r
r6r7r%r#rrHs$��D��I��I��K����N��Gr%r�unixc�|�eZdZ		dd�Zd�Zed��Zejd��Zd�Ze	e
j�Zy)rNc��|�t|�|urt|�}||_||_||_t||g|��i|��|_||_d|_y�Nr)�iter�list�_fieldnames�restkey�restvalr�dialect�line_num)r"�f�
fieldnamesrGrHrI�args�kwdss        r#r$zDictReader.__init__TsZ���!�d�:�&6�*�&D��j�)�J�%����������Q��7�$�7�$�7��������
r%c��|Sr'r7r!s r#�__iter__zDictReader.__iter___s���r%c��|j�	t|j�|_|jj|_|jS#t$rY�2wxYwr')rF�nextr�
StopIterationrJr!s r#rLzDictReader.fieldnamesbsW�����#�
�#'����#4�� ����,�,��
������!�
��
�s�A�	A�Ac��||_yr')rF)r"�values  r#rLzDictReader.fieldnamesls
�� ��r%c���|jdk(r|jt|j�}|jj|_|gk(rt|j�}|gk(r�t	t|j|��}t
|j�}t
|�}||kr||d||j<|S||kDr#|j|dD]}|j||<�|SrC)	rJrLrRr�dict�zip�lenrGrH)r"�row�d�lf�lr�keys      r#�__next__zDictReader.__next__ps����=�=�A���O�O��4�;�;������,�,��
�
�R�i��t�{�{�#�C��R�i���T�_�_�c�*�+��
����
!��
��X��
��7�!�"�#�h�A�d�l�l�O����"�W����r�s�+�
&������#��
&��r%)NNNr)
r,r-r.r$rP�propertyrL�setterr_�classmethod�types�GenericAlias�__class_getitem__r7r%r#rrSsX��AE� �	��� �� ����!��!��,$�E�$6�$6�7�r%rc�T�eZdZ		dd�Zd�Zd�Zd�Zd�Zee	j�Zy)rc���|�t|�|urt|�}||_||_|j	�}|dvrtd|z��||_t||g|��i|��|_y)N)�raise�ignorez-extrasaction (%s) must be 'raise' or 'ignore')rDrErLrH�lower�
ValueError�extrasactionr)r"rKrLrHrlrIrMrNs        r#r$zDictWriter.__init__�s{���!�d�:�&6�*�&D��j�)�J�$������#�)�)�+���2�2��L�+�,�-�
-�(����Q��7�$�7�$�7��r%c�v�tt|j|j��}|j|�Sr')rWrXrL�writerow)r"�headers  r#�writeheaderzDictWriter.writeheader�s*���c�$�/�/�4�?�?�;�<���}�}�V�$�$r%c�����jdk(rS�j��jz
}|r4tddj	|D�cgc]
}t|���c}�z����fd��jD�Scc}w)Nrhz(dict contains fields not in fieldnames: z, c3�V�K�|] }�j|�j����"y�wr')�getrH)�.0r^�rowdictr"s  ��r#�	<genexpr>z+DictWriter._dict_to_list.<locals>.<genexpr>�s �����J�3����C����.�J�s�&))rl�keysrLrk�join�repr)r"ru�wrong_fields�xs``  r#�
_dict_to_listzDictWriter._dict_to_list�sp�������'�"�<�<�>�D�O�O�;�L�� �!K�#'�9�9�|�-L�!�d�1�g�-L�#M�"N�O�O�J�$�/�/�J�J��.Ms�A;c�V�|jj|j|��Sr')rrnr|)r"rus  r#rnzDictWriter.writerow�s"���{�{�#�#�D�$6�$6�w�$?�@�@r%c�`�|jjt|j|��Sr')r�	writerows�mapr|)r"�rowdictss  r#rzDictWriter.writerows�s$���{�{�$�$�S��);�);�X�%F�G�Gr%N)rrhr)r,r-r.r$rpr|rnrrbrcrdrer7r%r#rr�s7��?F� �8�%�K�A�H�$�E�$6�$6�7�r%rc�0�eZdZdZd�Zdd�Zd�Zd�Zd�Zy)	rze
    "Sniffs" the format of a CSV file (i.e. delimiter, quotechar)
    Returns a Dialect object.
    c��gd�|_y)N)r9r=�;� �:)�	preferredr!s r#r$zSniffer.__init__�s	��3��r%Nc���|j||�\}}}}|s|j||�\}}|std��Gd�dt�}||_||_|xsd|_||_|S)zI
        Returns a dialect (or None) corresponding to the sample
        zCould not determine delimiterc��eZdZdZdZeZy)�Sniffer.sniff.<locals>.dialect�sniffedr;N)r,r-r.r/r5rr6r7r%r#rIr��s���E�#�N�#�Gr%rIr:)�_guess_quote_and_delimiter�_guess_delimiterrrr3r0r1r4)r"�sample�
delimitersr1r3r0r4rIs        r#�sniffz
Sniffer.sniff�s����2�2�6�:�F�	<�	�;�	�+;��*.�*?�*?��@J�+L�'�I�'���7�8�8�	$�g�	$�*���%���%�,����#3�� ��r%c�,�g}dD]L}tj|tjtjz�}|j	|�}|s�Ln|syi}i}d}j
}	|D]k}
|	ddz
}|
|}|r|j
|d�dz||<	|	ddz
}|
|}|r|�||vr|j
|d�dz||<	|	ddz
}|
|s�g|dz
}�mt||j��}
|r't||j��}|||k(}|d	k(rd
}nd
}d}tjdtj|�|
d�ztj�}|j|�rd
}nd}|
|||fS#t$rY��wxYw#t$rY��'wxYw)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��delim�space�r^r?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�
groupindexrs�KeyError�max�escape�search)r"�datar��matches�restr�regexp�quotes�delims�spacesr��m�nr^r1r�r4�	dq_regexpr3s                  r#r�z"Sniffer._guess_quote_and_delimiter�s�����H�	�E��Z�Z��r�y�y�2�<�<�'?�@�F��n�n�T�*�G���	��'��������&�&�
��	�A��7�#�a�'�A��A�$�C��$�j�j��a�0�1�4��s��
��w�'�!�+����d���
�*�c�Z�.?�$�j�j��a�0�1�4��s��
��w�'�!�+����t��!���#	�&��F�J�J�/�	����F�J�J�/�E�%�e�}��6����}����E� ���J�J��(*�	�	�%�(8�)�L� M�NP�l�l�\�	����D�!��K��K��;��/?�@�@��I�
��
���
��
�s$�
E6�F�6	F�F�	F�Fc��ttd|jd���}td�D�cgc]
}t	|���}}tdt
|��}d}i}i}i}	d|}}
|
t
|�k�r	|dz
}||
|D]I}|D]B}
|j|
i�}|j|
�}|j|d�dz||<|||
<�D�K|j�D]�}
t||
j��}t
|�dk(r|dddk(r�9t
|�dkDrLt|d���||
<|j||
�||
d||
dtd	�|D��z
f||
<��|d||
<��|j�}tt||zt
|���}d
}d}t
|	�dk(rR||k\rM|D]/\}}|ddkDs�|ddkDs�|d|z|k\s�$|�||vs�+||	|<�1|dz}t
|	�dk(r||k\r�Mt
|	�dk(rLt|	j��d}|dj|�|djd
|z�k(}||fS|}
||z
}|
t
|�kr��	|	syt
|	�dkDrU|jD]F}||	j�vs�|dj|�|djd
|z�k(}||fcS|	j�D��cgc]	\}}||f��}}}|j!�|dd}|dj|�|djd
|z�k(}||fScc}wcc}}w)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?��
rr�c��|dS)Nr�r7)r{s r#�<lambda>z*Sniffer._guess_delimiter.<locals>.<lambda>Ns
��1�Q�4�r%r�c3�&K�|]	}|d���y�w)r�Nr7)rt�items  r#rvz+Sniffer._guess_delimiter.<locals>.<genexpr>Ss����(C�T��a��(C�s�g�?g�������?g{�G�z�?z%c )rr���)rE�filter�split�range�chr�minrYrs�countrw�itemsr��remove�sum�floatr��sort)r"r�r��c�ascii�chunkLength�	iteration�
charFrequency�modesr��start�end�line�char�
metaFrequency�freqr��modeList�total�consistency�	threshold�k�vr�r4r[s                          r#r�zSniffer._guess_delimiters���&�F�4����D�!1�2�3��!&�s��,�A��Q��,��,��"�c�$�i�(���	��
�������s���c�$�i����N�I��U�3��
8��!�8�D�$1�$5�$5�d�B�$?�M��:�:�d�+�D�*7�*;�*;�D�!�*D�q�*H�M�$�'�*7�M�$�'�
8�
8�&�*�*�,�

+���]�4�0�6�6�8�9���u�:��?�u�Q�x��{�a�'7���u�:��>�"%�e��"@�E�$�K��L�L��t��-�#(��;�q�>�5��;�q�>�%(�(C�U�(C�%C�4D�#E�E�$�K�#(��(�E�$�K�

+� �{�{�}�H��#�k�I�5�s�4�y�A�B�E��K��I��f�+��"�{�i�'?�$�*�D�A�q���t�a�x�A�a�D�1�H��q�T�%�Z�K�7�'�/�1�
�?�()�F�1�I�	*�
�t�#��
�f�+��"�{�i�'?��6�{�a���V�[�[�]�+�A�.��$(��G�M�M�%�$8�$(��G�M�M�%�%�-�$@�%A� ��/�0�0��E��;��C�c�c�$�i��f���v�;��?��^�^�
1������
�%�(,�Q��
�
�a�(8�(,�Q��
�
�e�a�i�(@�)A�$��/�0�0�	
1�%+�L�L�N�3�5�A�a�!�A��3��3�
�
�
���b�	�!��� ��G�M�M�%�0� ��G�M�M�%�%�-�8�9���'�(�(��_-��R4s�M�8Mc��tt|�|j|��}t|�}t	|�}i}t|�D]}d||<�	d}|D]d}|dkDrn]|dz
}t	|�|k7r�t
|j��D]+}	t}
	|
||	�|
||	k7s�||	�|
||	<�)||	=�-�fd}|j�D]C\}	}t|t�rt	||	�|k7r|dz
}�-|dz}�3	|||	�|dz}�E|dkDS#ttf$rt	||	�}
Y��wxYw#ttf$r|dz
}Y��wxYw)Nr�r�)rrr�rRrYr�rErw�complexrk�
OverflowErrorr��
isinstance�intr))
r"r��rdrro�columns�columnTypes�i�checkedrZ�col�thisType�	hasHeader�colTypes
             r#�
has_headerzSniffer.has_header�s����X�f�%�t�z�z�&�'9�:���c����f�+�����w��6�A�$��Q��6����	-�C���|���q�L�G��3�x�7�"���K�,�,�.�/�
-��"��-��S��X�&�
�{�3�/�/�"�3�'�/�+3��C�(�(��,�
-�	-�6�	�'�-�-�/�	#�L�C���'�3�'��v�c�{�#�w�.���N�I���N�I�#��F�3�K�(���N�I�	#��1�}���;#�M�2�-�"�3�s�8�}�H�-��0#�I�.�#���N�I�#�s$�D�D=�D:�9D:�=E�Er')	r,r-r.rr$r�r�r�r�r7r%r#rr�s%���4�
�:IA�Xd)�N=r%r)rr�rc�_csvrrrrrrr	r
rrr
rrrrrr(�ior�__all__rrrrrrr7r%r#�<module>r�s����
�������%���� � �>�G����%� ������i�(��7�����&�38�38�l 8� 8�FW�Wr%

Zerion Mini Shell 1.0