Hacked By AnonymousFox

Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/csv.cpython-35.opt-2.pyc



���]?�@s�ddlZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZddddd	d
ddd
dddddddddddgZGdd
�d
�ZGdd�de�Zede�Gdd
�d
e�Zede�Gdd�de�Zede�Gd d�d�ZGd!d�d�ZyeWnek
r�eZYnXGd"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)�StringIOrrr
rrrr�excel�	excel_tabr
rrrrr	�Snifferrr�
DictReader�
DictWriterc@s^eZdZdZdZdZdZdZdZdZ	dZ
dZdd�Zdd�Z
dS)r�FNcCs&|jtkrd|_|j�dS)NT)�	__class__r�_valid�	_validate)�self�r�(/opt/alt/python35/lib64/python3.5/csv.py�__init__)s	zDialect.__init__cCsLyt|�Wn7tk
rG}ztt|���WYdd}~XnXdS)N)�_Dialect�	TypeErrorr�str)r�errrr.szDialect._validate)�__name__�
__module__�__qualname__�_namer�	delimiter�	quotecharZ
escapechar�doublequote�skipinitialspace�lineterminator�quotingrrrrrrrsc@s4eZdZdZdZdZdZdZeZ	dS)r�,�"TFz
N)
r#r$r%r'r(r)r*r+rr,rrrrr5sc@seZdZdZdS)r�	N)r#r$r%r'rrrrr?sz	excel-tabc@s4eZdZdZdZdZdZdZeZ	dS)�unix_dialectr-r.TF�
N)
r#r$r%r'r(r)r*r+rr,rrrrr0Dsr0Zunixc@sgeZdZdddddd�Zdd�Zedd��Zejd	d��Zd
d�ZdS)rNrcOsI||_||_||_t||||�|_||_d|_dS)Nr)�_fieldnames�restkey�restvalr�dialect�line_num)r�f�
fieldnamesr3r4r5�args�kwdsrrrrPs				zDictReader.__init__cCs|S)Nr)rrrr�__iter__YszDictReader.__iter__cCsP|jdkr:yt|j�|_Wntk
r9YnX|jj|_|jS)N)r2�nextr�
StopIterationr6)rrrrr8\s
zDictReader.fieldnamescCs
||_dS)N)r2)r�valuerrrr8fscCs�|jdkr|jt|j�}|jj|_x|gkrUt|j�}q7Wtt|j|��}t|j�}t|�}||kr�||d�||j<n7||kr�x(|j|d�D]}|j||<q�W|S)Nr)	r6r8r<r�dict�zip�lenr3r4)r�row�dZlfZlr�keyrrr�__next__jszDictReader.__next__)	r#r$r%rr;�propertyr8�setterrErrrrrOs	
c@sUeZdZddddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rr�raisercOsY||_||_|j�dkr4td|��||_t||||�|_dS)NrH�ignorez-extrasaction (%s) must be 'raise' or 'ignore')rHrI)r8r4�lower�
ValueError�extrasactionr)rr7r8r4rLr5r9r:rrrr�s		
	zDictWriter.__init__cCs,tt|j|j��}|j|�dS)N)r?r@r8�writerow)r�headerrrr�writeheader�szDictWriter.writeheadercsq�jdkrT�fdd��D�}|rTtddjdd�|D������fdd��jD�S)	NrHcs%g|]}|�jkr|�qSr)r8)�.0�k)rrr�
<listcomp>�s	z,DictWriter._dict_to_list.<locals>.<listcomp>z(dict contains fields not in fieldnames: z, cSsg|]}t|��qSr)�repr)rP�xrrrrR�s	c3s$|]}�j|�j�VqdS)N)�getr4)rPrD)�rowdictrrr�	<genexpr>�sz+DictWriter._dict_to_list.<locals>.<genexpr>)rLrK�joinr8)rrVZwrong_fieldsr)rVrr�
_dict_to_list�s zDictWriter._dict_to_listcCs|jj|j|��S)N)rrMrY)rrVrrrrM�szDictWriter.writerowcCs|jjt|j|��S)N)r�	writerows�maprY)rZrowdictsrrrrZ�szDictWriter.writerowsN)r#r$r%rrOrYrMrZrrrrr�s	c@sOeZdZdd�Zddd�Zdd�Zdd	�Zd
d�ZdS)rcCsdddddg|_dS)Nr-r/�;� �:)�	preferred)rrrrr�szSniffer.__init__NcCs�|j||�\}}}}|s<|j||�\}}|sNtd��Gdd�dt�}||_||_|pd|_||_|S)NzCould not determine delimiterc@s"eZdZdZdZeZdS)zSniffer.sniff.<locals>.dialectZsniffedz
N)r#r$r%r&r+rr,rrrrr5�sr5r.)�_guess_quote_and_delimiter�_guess_delimiterrrr)r'r(r*)r�sample�
delimitersr(r)r'r*r5rrr�sniff�s				z
Sniffer.sniffcCsg}x@dD]8}tj|tjtjB�}|j|�}|r
Pq
W|sSdSi}i}d}|j}	x�|D]�}
|	dd	}|
|}|r�|j|d�d	||<y|	d
d	}|
|}Wntk
r�wuYnX|r|dks||kr|j|d�d	||<y|	dd	}Wntk
rHwuYnX|
|ru|d	7}quWt|d|j�}
|r�t|d|j�}|||k}|d
kr�d}nd}d}tjdd
tj	|�d|
itj�}|j
|�rd}nd}|
|||fS)N�F(?P<delim>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?P=delim)�C(?:^|
)(?P<quote>["']).*?(?P=quote)(?P<delim>[^\w
"'])(?P<space> ?)�D(?P<delim>>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?:$|
)�*(?:^|
)(?P<quote>["']).*?(?P=quote)(?:$|
)rFr�quote��delimZspacerDr1z]((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)T)rerfrgrh)rFNr)�re�compile�DOTALL�	MULTILINE�findall�
groupindexrU�KeyError�max�escape�search)r�datarc�matchesZrestrZregexpZquotes�delimsZspacesrq�m�nrDr(rkr*Z	dq_regexpr)rrrr`�s`
	




	%	z"Sniffer._guess_quote_and_delimitercCs�ttd|jd���}dd�td�D�}tdt|��}d}i}i}i}dt|t|��}	}
x�|	t|�kr |d7}xn||	|
�D]\}xS|D]K}|j|i�}
|j|�}|
j|d�d|
|<|
||<q�Wq�Wx�|j�D]�}t||j	��}t|�dkrb|dddkrbqt|�dkr�t
|dd	d
��||<|j||�||d||dtdd�|D��f||<q|d||<qW|j	�}t
||�}d
}d}x�t|�dkr�||kr�xj|D]b\}}|ddkr=|ddkr=|d||kr=|dks�||kr=|||<q=W|d8}qWt|�dkr
t|j��d}|dj|�|djd|�k}||fS|
}	|
|7}
q�W|s+dSt|�dkr�xW|jD]L}||j�krG|dj|�|djd|�k}||fSqGWdd�|j	�D�}|j�|dd}|dj|�|djd|�k}||fS)Nr1cSsg|]}t|��qSr)�chr)rP�crrrrR,s	z,Sniffer._guess_delimiter.<locals>.<listcomp>��
rrjrDcSs|dS)Nrjr)rTrrr�<lambda>Fsz*Sniffer._guess_delimiter.<locals>.<lambda>css|]}|dVqdS)rjNr)rP�itemrrrrWKsz+Sniffer._guess_delimiter.<locals>.<genexpr>g�?g�������?g{�G�z�?z%c rcSs"g|]\}}||f�qSrr)rPrQ�vrrrrRus	)rr���)�list�filter�split�range�minrArU�count�keys�itemsrs�remove�sum�floatr_�sort)rrvrc�asciiZchunkLengthZ	iterationZ
charFrequencyZmodesrx�start�end�line�charZ
metaFrequencyZfreqr�ZmodeList�totalZconsistencyZ	thresholdrQr�rkr*rCrrrrast

&$! 

zSniffer._guess_delimiterc
Cs�tt|�|j|��}t|�}t|�}i}xt|�D]}d||<qIWd}x�|D]�}|dkr}P|d7}t|�|kr�qjx�t|j��D]�}	xUtt	t
gD]4}
y|
||	�PWq�ttfk
r�Yq�Xq�Wt||	�}
|
||	kr�||	dkr:|
||	<q�||	=q�WqjWd}x�|j
�D]�\}	}t|�td�kr�t||	�|kr�|d7}q�|d8}q\y|||	�Wn"ttfk
r�|d7}Yq\X|d8}q\W|dkS)Nr�rj)rrrdr<rAr�r�r��intr��complexrK�
OverflowErrorr��typer )
rrbZrdrrN�columnsZcolumnTypes�iZcheckedrB�colZthisTypeZ	hasHeaderZcolTyperrr�
has_header~sJ


	


zSniffer.has_header)r#r$r%rrdr`rar�rrrrr�s
Lg)rlZ_csvrrrrrrrr	r
rrr
rrrr�ior�__all__rrr0rrr��	NameErrorr�rrrrr�<module>s,^	


2


Hacked By AnonymousFox1.0, Coded By AnonymousFox