AlkantarClanX12

Your IP : 3.21.46.68


Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/csv.cpython-37.opt-2.pyc

B

YI~d4?�@sHddlZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZddlmZdddd	d
ddd
dddddddddddddgZGdd�d�ZGdd
�d
e�Zed
e�Gdd�de�Zede�Gdd�de�Zed e�Gd!d�d�ZGd"d�d�ZyeWnek
�r4eZYnXGd#d�d�ZdS)$�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)�OrderedDict)�StringIOrrr
rrrr�excel�	excel_tabr
rrrrr	�Snifferrr�
DictReader�
DictWriter�unix_dialectc@s@eZdZdZdZdZdZdZdZdZ	dZ
dZdd�Zdd�Z
dS)r�FNcCs|jtkrd|_|��dS)NT)�	__class__r�_valid�	_validate)�self�r�(/opt/alt/python37/lib64/python3.7/csv.py�__init__+s
zDialect.__init__c
Cs@yt|�Wn.tk
r:}ztt|���Wdd}~XYnXdS)N)�_Dialect�	TypeErrorr�str)r�errrr0szDialect._validate)�__name__�
__module__�__qualname__�_namer�	delimiter�	quotecharZ
escapechar�doublequote�skipinitialspace�lineterminator�quotingr rrrrrrsc@s$eZdZdZdZdZdZdZeZ	dS)r�,�"TFz
N)
r%r&r'r)r*r+r,r-rr.rrrrr7sc@seZdZdZdS)r�	N)r%r&r'r)rrrrrAsz	excel-tabc@s$eZdZdZdZdZdZdZeZ	dS)rr/r0TF�
N)
r%r&r'r)r*r+r,r-rr.rrrrrFsZunixc@s@eZdZddd�Zdd�Zedd��Zejd	d��Zd
d�ZdS)
rNrcOs6||_||_||_t||f|�|�|_||_d|_dS)Nr)�_fieldnames�restkey�restvalr�dialect�line_num)r�f�
fieldnamesr4r5r6�args�kwdsrrrr RszDictReader.__init__cCs|S)Nr)rrrr�__iter__[szDictReader.__iter__cCs@|jdkr0yt|j�|_Wntk
r.YnX|jj|_|jS)N)r3�nextr�
StopIterationr7)rrrrr9^s

zDictReader.fieldnamescCs
||_dS)N)r3)r�valuerrrr9hscCs�|jdkr|jt|j�}|jj|_x|gkr:t|j�}q&Wtt|j|��}t|j�}t|�}||krz||d�||j<n*||kr�x |j|d�D]}|j||<q�W|S)Nr)	r7r9r=rr�zip�lenr4r5)r�row�dZlfZlr�keyrrr�__next__ls




zDictReader.__next__)NNNr)	r%r&r'r r<�propertyr9�setterrErrrrrQs

c@s6eZdZddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rr�raisercOsB||_||_|��dkr$td|��||_t||f|�|�|_dS)N)rH�ignorez-extrasaction (%s) must be 'raise' or 'ignore')r9r5�lower�
ValueError�extrasactionr)rr8r9r5rLr6r:r;rrrr �szDictWriter.__init__cCs tt|j|j��}|�|�dS)N)�dictr@r9�writerow)r�headerrrr�writeheader�szDictWriter.writeheadercsN�jdkr8����j}|r8tdd�dd�|D������fdd��jD�S)NrHz(dict contains fields not in fieldnames: z, cSsg|]}t|��qSr)�repr)�.0�xrrr�
<listcomp>�sz,DictWriter._dict_to_list.<locals>.<listcomp>c3s|]}��|�j�VqdS)N)�getr5)rRrD)�rowdictrrr�	<genexpr>�sz+DictWriter._dict_to_list.<locals>.<genexpr>)rL�keysr9rK�join)rrVZwrong_fieldsr)rVrr�
_dict_to_list�s
zDictWriter._dict_to_listcCs|j�|�|��S)N)rrNrZ)rrVrrrrN�szDictWriter.writerowcCs|j�t|j|��S)N)r�	writerows�maprZ)rZrowdictsrrrr[�szDictWriter.writerowsN)rrHr)r%r&r'r rPrZrNr[rrrrr�s
	c@s6eZdZdd�Zddd�Zdd�Zdd	�Zd
d�ZdS)
rcCsdddddg|_dS)Nr/r1�;� �:)�	preferred)rrrrr �szSniffer.__init__NcCsd|�||�\}}}}|s(|�||�\}}|s4td��Gdd�dt�}||_||_|pVd|_||_|S)NzCould not determine delimiterc@seZdZdZdZeZdS)zSniffer.sniff.<locals>.dialectZsniffedz
N)r%r&r'r(r-rr.rrrrr6�sr6r0)�_guess_quote_and_delimiter�_guess_delimiterrrr+r)r*r,)r�sample�
delimitersr*r+r)r,r6rrr�sniff�s

z
Sniffer.sniffc	Cs�g}x0dD](}t�|tjtjB�}|�|�}|r
Pq
W|s>dSi}i}d}|j}	x�|D]�}
|	dd}|
|}|r�|�|d�d||<y|	dd}|
|}Wntk
r�wVYnX|r�|dks�||kr�|�|d�d||<y|	dd}Wntk
�rwVYnX|
|rV|d7}qVWt||jd�}
|�rZt||jd�}|||k}|d	k�rbd
}nd
}d}t�dt�	|�|
d�tj�}|�
|��r�d
}nd}|
|||fS)N)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��delimZspace)rDr2rz]((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$))rhrfTF)�re�compile�DOTALL�	MULTILINE�findall�
groupindexrU�KeyError�max�escape�search)r�datard�matchesZrestrZregexpZquotes�delimsZspacesrn�m�nrDr*rhr,Z	dq_regexpr+rrrra�sZ



z"Sniffer._guess_quote_and_delimitercCsttd|�d���}dd�td�D�}tdt|��}d}i}i}i}d|}	}
�x|	t|�k�rj|d7}xT||	|
�D]D}x>|D]6}|�|i�}
|�|�}|
�|d�d|
|<|
||<q�WqvWx�|��D]�}t||�	��}t|�dkr�|dddkr�q�t|�dk�rZt
|dd	�d
�||<|�||�||d||dtdd�|D��f||<q�|d||<q�W|�	�}t
t||t|���}d
}d}x�t|�dk�r||k�rx\|D]T\}}|ddk�r�|ddk�r�|d||k�r�|dk�s�||k�r�|||<�q�W|d8}�q�Wt|�dk�r\t|���d}|d�|�|d�d|�k}||fS|
}	|
|7}
qRW|�svdSt|�dk�r�xF|jD]<}||��k�r�|d�|�|d�d|�k}||fS�q�Wdd�|�	�D�}|��|dd}|d�|�|d�d|�k}||fS)Nr2cSsg|]}t|��qSr)�chr)rR�crrrrT.sz,Sniffer._guess_delimiter.<locals>.<listcomp>��
rrgcSs|dS)Nrgr)rSrrr�<lambda>H�z*Sniffer._guess_delimiter.<locals>.<lambda>)rDcss|]}|dVqdS)rgNr)rR�itemrrrrWMsz+Sniffer._guess_delimiter.<locals>.<genexpr>g�?g�������?g{�G�z�?z%c )rrcSsg|]\}}||f�qSrr)rR�k�vrrrrTws���)�list�filter�split�range�minrArU�countrX�itemsrp�remove�sum�floatr`�sort)rrsrd�asciiZchunkLengthZ	iterationZ
charFrequencyZmodesru�start�end�line�charZ
metaFrequencyZfreqr�ZmodeListZtotalZconsistencyZ	thresholdrr�rhr,rCrrrrbst


zSniffer._guess_delimiterc
Cs�tt|�|�|��}t|�}t|�}i}xt|�D]}d||<q2Wd}x�|D]�}|dkrZP|d7}t|�|krpqLx�t|���D]x}	xJtt	t
gD]0}
y|
||	�PWq�ttfk
r�Yq�Xq�Wt||	�}
|
||	kr~||	dkr�|
||	<q~||	=q~WqLWd}x�|�
�D]~\}	}t|�td�k�rLt||	�|k�rB|d7}n|d8}n<y|||	�Wn"ttfk
�r~|d7}Yn
X|d8}�qW|dkS)Nr�rg)rrrer=rAr�r�rX�intr��complexrK�
OverflowErrorr��typer")
rrcZrdrrO�columnsZcolumnTypes�i�checkedrB�colZthisTypeZ	hasHeaderZcolTyperrr�
has_header�sJ





zSniffer.has_header)N)r%r&r'r rerarbr�rrrrr�s

Lg) riZ_csvrrrrrrrr	r
rrr
rrrr!�collectionsr�ior�__all__rrrrrr��	NameErrorr�rrrrr�<module>s0@



2