B
    RV                 @   sp   d dl Z d dl T G dd deZG dd deZG dd deZeZeZG d	d
 d
e jZG dd de jZdS )    N)*c               @   s    e Zd ZdZdd Zdd ZdS )_UnicodeWriteWrapperz6Simple write() wrapper that converts unicode to bytes.c             C   s   || _ || _|| _d S )N)binaryencodingerrors)selfr   r   r    r   -lib/python3.7/site-packages/unicodecsv/py3.py__init__	   s    z_UnicodeWriteWrapper.__init__c             C   s   | j || j| jS )N)r   writeencoder   r   )r   stringr   r   r	   r      s    z_UnicodeWriteWrapper.writeN)__name__
__module____qualname____doc__r
   r   r   r   r   r	   r      s   r   c               @   s:   e Zd ZejddfddZdd Zdd Zed	d
 Z	dS )UnicodeWriterzutf-8strictc             O   s4   |d krt t|||d}tj||f||| _d S )N)r   r   )	TypeErrorr   csvwriter)r   fdialectr   r   argskwdsr   r   r	   r
      s    zUnicodeWriter.__init__c             C   s   | j |S )N)r   writerow)r   rowr   r   r	   r      s    zUnicodeWriter.writerowc             C   s   | j |S )N)r   	writerows)r   Zrowsr   r   r	   r      s    zUnicodeWriter.writerowsc             C   s   | j jS )N)r   r   )r   r   r   r	   r   !   s    zUnicodeWriter.dialectN)
r   r   r   r   excelr
   r   r   propertyr   r   r   r   r	   r      s   r   c               @   s>   e Zd ZdddZdd Zdd	 Zed
d Zedd ZdS )UnicodeReaderNutf-8r   c                sd   dddddddg|d kr:t fdd	| D s:tj} fd
d|D }tj||f|| _d S )NZ	delimiterZdoublequoteZ
escapecharZlineterminatorZ	quotecharZquotingZskipinitialspacec                s   g | ]}| kqS r   r   ).0Zkwd_name)format_paramsr   r	   
<listcomp>/   s   z*UnicodeReader.__init__.<locals>.<listcomp>c             3   s   | ]}|j  d V  qdS ))r   N)decode)r"   Zbs)r   r   r   r	   	<genexpr>3   s    z)UnicodeReader.__init__.<locals>.<genexpr>)anykeysr   r   reader)r   r   r   r   r   r   r   )r   r   r#   r	   r
   '   s    zUnicodeReader.__init__c             C   s
   | j  S )N)r)   __next__)r   r   r   r	   r*   6   s    zUnicodeReader.__next__c             C   s   | S )Nr   )r   r   r   r	   __iter__9   s    zUnicodeReader.__iter__c             C   s   | j jS )N)r)   r   )r   r   r   r	   r   <   s    zUnicodeReader.dialectc             C   s   | j jS )N)r)   line_num)r   r   r   r	   r,   @   s    zUnicodeReader.line_num)Nr!   r   )	r   r   r   r
   r*   r+   r   r   r,   r   r   r   r	   r    &   s
   
r    c                   s&   e Zd Zd
 fdd	Zdd	 Z  ZS )
DictWriter raiser   utf-8r   c       
         sD   t  j|||||f||	 t||f|||d|	| _|| _d S )N)r   r   )superr
   r   r   Zencoding_errors)
r   csvfile
fieldnamesrestvalZextrasactionr   r   r   r   r   )	__class__r   r	   r
   J   s
    zDictWriter.__init__c             C   s    t t| j| j}| | d S )N)dictzipr3   r   )r   headerr   r   r	   writeheaderS   s    zDictWriter.writeheader)r.   r/   r   r0   r   )r   r   r   r
   r9   __classcell__r   r   )r5   r	   r-   I   s     r-   c               @   s   e Zd ZdddZdS )
DictReaderNr   utf-8r   c       
      O   s@   t jj| |||||f||	 t||f|||d|	| _d S )N)r   r   )r   r;   r
   r    r)   )
r   r2   r3   Zrestkeyr4   r   r   r   r   r   r   r   r	   r
   Y   s    zDictReader.__init__)NNNr   r<   r   )r   r   r   r
   r   r   r   r	   r;   X   s    r;   )	r   objectr   r   r    r   r)   r-   r;   r   r   r   r	   <module>   s   