AlkantarClanX12

Your IP : 18.225.92.191


Current Path : /proc/self/root/opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python33/lib64/python3.3/__pycache__/csv.cpython-33.pyc

�
��f9?c@s�dZddlZddlmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZddlmZdddd	d
ddd
ddddddddddddgZGdd�d�ZGdd
�d
e�Zed
e�Gdd�de�Zede�Gdd�de�Zed e�Gd!d�d�ZGd"d�d�ZyeWnek
r�eZYnXGd#d�d�ZdS($u+
csv.py - read/write/investigate CSV files
iN(uErroru__version__uwriterureaderuregister_dialectuunregister_dialectuget_dialectu
list_dialectsufield_size_limitu
QUOTE_MINIMALu	QUOTE_ALLuQUOTE_NONNUMERICu
QUOTE_NONEu__doc__(uDialect(uStringIOu
QUOTE_MINIMALu	QUOTE_ALLuQUOTE_NONNUMERICu
QUOTE_NONEuErroruDialectu__doc__uexcelu	excel_tabufield_size_limitureaderuwriteruregister_dialectuget_dialectu
list_dialectsuSnifferuunregister_dialectu__version__u
DictReaderu
DictWritercBsh|EeZdZdZdZdZdZdZ	dZ
dZdZdZ
dZdd�Zdd�ZdS(	uDialectu�Describe a CSV dialect.

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

    ucCs)|jtkrd|_n|j�dS(NT(u	__class__uDialectuTrueu_validu	_validate(uself((u(/opt/alt/python33/lib64/python3.3/csv.pyu__init__)suDialect.__init__cCsLyt|�Wn7tk
rG}ztt|���WYdd}~XnXdS(N(u_Dialectu	TypeErroruErrorustr(uselfue((u(/opt/alt/python33/lib64/python3.3/csv.pyu	_validate.suDialect._validateNF(u__name__u
__module__u__qualname__u__doc__u_nameuFalseu_validuNoneu	delimiteru	quotecharu
escapecharudoublequoteuskipinitialspaceulineterminatoruquotingu__init__u	_validate(u
__locals__((u(/opt/alt/python33/lib64/python3.3/csv.pyuDialectscBs>|EeZdZdZdZdZdZdZ	dZ
eZdS(uexcelu;Describe the usual properties of Excel-generated CSV files.u,u"u
NTF(
u__name__u
__module__u__qualname__u__doc__u	delimiteru	quotecharuTrueudoublequoteuFalseuskipinitialspaceulineterminatoru
QUOTE_MINIMALuquoting(u
__locals__((u(/opt/alt/python33/lib64/python3.3/csv.pyuexcel5scBs |EeZdZdZdZdS(u	excel_tabuEDescribe the usual properties of Excel-generated TAB-delimited files.u	N(u__name__u
__module__u__qualname__u__doc__u	delimiter(u
__locals__((u(/opt/alt/python33/lib64/python3.3/csv.pyu	excel_tab?su	excel-tabcBs>|EeZdZdZdZdZdZdZ	dZ
eZdS(uunix_dialectu:Describe the usual properties of Unix-generated CSV files.u,u"u
NTF(
u__name__u
__module__u__qualname__u__doc__u	delimiteru	quotecharuTrueudoublequoteuFalseuskipinitialspaceulineterminatoru	QUOTE_ALLuquoting(u
__locals__((u(/opt/alt/python33/lib64/python3.3/csv.pyuunix_dialectDsuunix_dialectuunixcBsk|EeZdZdddddd�Zdd�Zedd��Zejdd��Zd	d
�Z	dS(u
DictReaderuexcelcOsI||_||_||_t||||�|_||_d|_dS(Ni(u_fieldnamesurestkeyurestvalureaderudialectuline_num(uselfufu
fieldnamesurestkeyurestvaludialectuargsukwds((u(/opt/alt/python33/lib64/python3.3/csv.pyu__init__Ps				uDictReader.__init__cCs|S(N((uself((u(/opt/alt/python33/lib64/python3.3/csv.pyu__iter__YsuDictReader.__iter__cCsS|jdkr=yt|j�|_Wq=tk
r9Yq=Xn|jj|_|jS(N(u_fieldnamesuNoneunextureaderu
StopIterationuline_num(uself((u(/opt/alt/python33/lib64/python3.3/csv.pyu
fieldnames\s
uDictReader.fieldnamescCs
||_dS(N(u_fieldnames(uselfuvalue((u(/opt/alt/python33/lib64/python3.3/csv.pyu
fieldnamesfscCs�|jdkr|jnt|j�}|jj|_x|gkrXt|j�}q:Wtt|j|��}t|j�}t|�}||kr�||d�||j<n:||kr�x+|j|d�D]}|j||<q�Wn|S(Ni(	uline_numu
fieldnamesunextureaderudictuzipulenurestkeyurestval(uselfurowudulfulrukey((u(/opt/alt/python33/lib64/python3.3/csv.pyu__next__js
uDictReader.__next__N(
u__name__u
__module__u__qualname__uNoneu__init__u__iter__upropertyu
fieldnamesusetteru__next__(u
__locals__((u(/opt/alt/python33/lib64/python3.3/csv.pyu
DictReaderOs	
cBsY|EeZdZddddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS(u
DictWriteruuraiseuexcelcOs\||_||_|j�dkr7td|��n||_t||||�|_dS(Nuraiseuignoreu-extrasaction (%s) must be 'raise' or 'ignore'(uraiseuignore(u
fieldnamesurestvaluloweru
ValueErroruextrasactionuwriter(uselfufu
fieldnamesurestvaluextrasactionudialectuargsukwds((u(/opt/alt/python33/lib64/python3.3/csv.pyu__init__�s		
	uDictWriter.__init__cCs,tt|j|j��}|j|�dS(N(udictuzipu
fieldnamesuwriterow(uselfuheader((u(/opt/alt/python33/lib64/python3.3/csv.pyuwriteheader�suDictWriter.writeheadercsw�jdkrZ�fdd��D�}|rZtddjdd�|D����qZn��fdd��jD�S(Nuraisecs%g|]}|�jkr|�qS((u
fieldnames(u.0uk(uself(u(/opt/alt/python33/lib64/python3.3/csv.pyu
<listcomp>�s	u,DictWriter._dict_to_list.<locals>.<listcomp>u(dict contains fields not in fieldnames: u, cSsg|]}t|��qS((urepr(u.0ux((u(/opt/alt/python33/lib64/python3.3/csv.pyu
<listcomp>�s	cs%g|]}�j|�j��qS((ugeturestval(u.0ukey(urowdictuself(u(/opt/alt/python33/lib64/python3.3/csv.pyu
<listcomp>�s	(uextrasactionu
ValueErrorujoinu
fieldnames(uselfurowdictuwrong_fields((urowdictuselfu(/opt/alt/python33/lib64/python3.3/csv.pyu
_dict_to_list�s&uDictWriter._dict_to_listcCs|jj|j|��S(N(uwriteruwriterowu
_dict_to_list(uselfurowdict((u(/opt/alt/python33/lib64/python3.3/csv.pyuwriterow�suDictWriter.writerowcCs=g}x$|D]}|j|j|��q
W|jj|�S(N(uappendu
_dict_to_listuwriteru	writerows(uselfurowdictsurowsurowdict((u(/opt/alt/python33/lib64/python3.3/csv.pyu	writerows�s
uDictWriter.writerowsN(u__name__u
__module__u__qualname__u__init__uwriteheaderu
_dict_to_listuwriterowu	writerows(u
__locals__((u(/opt/alt/python33/lib64/python3.3/csv.pyu
DictWriter�s	cBsY|EeZdZdZdd�Zddd�Zdd�Zdd	�Zd
d�Z	dS(
uSnifferue
    "Sniffs" the format of a CSV file (i.e. delimiter, quotechar)
    Returns a Dialect object.
    cCsdddddg|_dS(Nu,u	u;u u:(u	preferred(uself((u(/opt/alt/python33/lib64/python3.3/csv.pyu__init__�suSniffer.__init__cCs�|j||�\}}}}|s?|j||�\}}n|sTtd��nGdd�dt�}||_||_|p�d|_||_|S(uI
        Returns a dialect (or None) corresponding to the sample
        uCould not determine delimitercBs&|EeZdZdZdZeZdS(uSniffer.sniff.<locals>.dialectusniffedu
N(u__name__u
__module__u__qualname__u_nameulineterminatoru
QUOTE_MINIMALuquoting(u
__locals__((u(/opt/alt/python33/lib64/python3.3/csv.pyudialect�sudialectu"(u_guess_quote_and_delimiteru_guess_delimiteruErroruDialectudoublequoteu	delimiteru	quotecharuskipinitialspace(uselfusampleu
delimitersu	quotecharudoublequoteu	delimiteruskipinitialspaceudialect((u(/opt/alt/python33/lib64/python3.3/csv.pyusniff�s				u
Sniffer.sniffcCs/g}xCdD];}tj|tjtjB�}|j|�}|r
Pq
q
W|sVdSi}i}d}x|D]�}	|jdd}
|	|
}|r�|j|d�d||<ny|jd	d}
|	|
}Wnt	k
r�woYnX|r%|dks||kr%|j|d�d||<ny|jd
d}
Wnt	k
rQwoYnX|	|
ro|d7}qoqoWt
|d|j�}|r�t
|d|j�}
||
|k}|
dkr�d}
q�nd}
d}tjd
itj|
�d	6|d6tj�}|j|�rd}nd}|||
|fS(u�
        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.
        uF(?P<delim>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?P=delim)uC(?:^|
)(?P<quote>["']).*?(?P=quote)(?P<delim>[^\w
"'])(?P<space> ?)uD(?P<delim>>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?:$|
)u*(?:^|
)(?P<quote>["']).*?(?P=quote)(?:$|
)uiuquoteiudelimuspaceukeyu
u]((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)(uF(?P<delim>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?P=delim)uC(?:^|
)(?P<quote>["']).*?(?P=quote)(?P<delim>[^\w
"'])(?P<space> ?)uD(?P<delim>>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?:$|
)u*(?:^|
)(?P<quote>["']).*?(?P=quote)(?:$|
)FN(uFNiT(ureucompileuDOTALLu	MULTILINEufindalluFalseuNoneu
groupindexugetuKeyErrorumaxuescapeusearchuTrue(uselfudatau
delimitersumatchesurestruregexpuquotesudelimsuspacesumunukeyu	quotecharudelimuskipinitialspaceu	dq_regexpudoublequote((u(/opt/alt/python33/lib64/python3.3/csv.pyu_guess_quote_and_delimiter�s^





'	u"Sniffer._guess_quote_and_delimitercCsttd|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|�dkre|dddkreqnt|�dkr�t|dd	d
��||<|j||�||d||dt
dd�|D��f||<q|d||<qW|j
�}t||�}d
}d}x�t|�dkr�||kr�xp|D]h\}}|ddkr@|ddkr@|d||kr�|dks�||kr�|||<q�q@q@W|d8}qWt|�dkrt|j	��d}|dj|�|djd|�k}||fS|
}	|
|7}
q�W|s4dSt|�dkr�xZ|jD]L}||j	�krP|dj|�|djd|�k}||fSqPWndd�|j
�D�}|j�|dd}|dj|�|djd|�k}||fS(u�
        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.
        u
cSsg|]}t|��qS((uchr(u.0uc((u(/opt/alt/python33/lib64/python3.3/csv.pyu
<listcomp>.s	u,Sniffer._guess_delimiter.<locals>.<listcomp>ii
iiukeycSs|dS(Ni((ux((u(/opt/alt/python33/lib64/python3.3/csv.pyu<lambda>Hsu*Sniffer._guess_delimiter.<locals>.<lambda>css|]}|dVqdS(iN((u.0uitem((u(/opt/alt/python33/lib64/python3.3/csv.pyu	<genexpr>Msu+Sniffer._guess_delimiter.<locals>.<genexpr>g�?g�������?g{�G�z�?u%c ucSs"g|]\}}||f�qS(((u.0ukuv((u(/opt/alt/python33/lib64/python3.3/csv.pyu
<listcomp>ws	N(uii����(ulistufilteruNoneuspliturangeuminulenugetucountukeysuitemsumaxuremoveusumufloatu	preferredusort(uselfudatau
delimitersuasciiuchunkLengthu	iterationu
charFrequencyumodesudelimsustartuendulineucharu
metaFrequencyufrequitemsumodeListutotaluconsistencyu	thresholdukuvudelimuskipinitialspaceud((u(/opt/alt/python33/lib64/python3.3/csv.pyu_guess_delimiterst

&$! 

uSniffer._guess_delimiterc
Cstt|�|j|��}t|�}t|�}i}xt|�D]}d||<qIWd}x�|D]�}|dkr�Pn|d7}t|�|kr�qjnx�t|j��D]�}	xUt	t
tgD]4}
y|
||	�PWq�tt
fk
r�Yq�Xq�Wt||	�}
|
||	kr�||	dkr@|
||	<qJ||	=q�q�WqjWd}x�|j�D]�\}	}t|�td�kr�t||	�|kr�|d7}q�|d8}qey|||	�Wn"ttfk
r�|d7}YqeX|d8}qeW|dkS(Niii(ureaderuStringIOusniffunextulenurangeuNoneulistukeysuintufloatucomplexu
ValueErroru
OverflowErroruitemsutypeu	TypeError(
uselfusampleurdruheaderucolumnsucolumnTypesuiucheckedurowucoluthisTypeu	hasHeaderucolType((u(/opt/alt/python33/lib64/python3.3/csv.pyu
has_header�sJ


	


uSniffer.has_headerN(
u__name__u
__module__u__qualname__u__doc__u__init__uNoneusniffu_guess_quote_and_delimiteru_guess_delimiteru
has_header(u
__locals__((u(/opt/alt/python33/lib64/python3.3/csv.pyuSniffer�sKg(u__doc__ureu_csvuErroru__version__uwriterureaderuregister_dialectuunregister_dialectuget_dialectu
list_dialectsufield_size_limitu
QUOTE_MINIMALu	QUOTE_ALLuQUOTE_NONNUMERICu
QUOTE_NONEuDialectu_DialectuiouStringIOu__all__uexcelu	excel_tabuunix_dialectu
DictReaderu
DictWriterucomplexu	NameErrorufloatuSniffer(((u(/opt/alt/python33/lib64/python3.3/csv.pyu<module>s.^	


2!