o
    ;Di                     @   s   d dl mZmZmZ d dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZmZ d dlZd dlmZmZmZmZmZmZ dd Zd	d
 Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZdS )    )absolute_importprint_functiondivisionN)NamedTemporaryFile)PY2)ieqeq_)MemorySourcePopenSource	ZipSourceStdoutSource
GzipSource	BZ2Sourcec                  C   s   d} t  }t| | d}ts|d}| }t|| tt |}t| | t| | t	| | | }d}tsA|d}t|| d S )Nfoobara1b2)cr   foo,bar
a,1
b,2
c,2
asciiz'foo,bar
a,1
b,2
c,2
a,1
b,2
c,2
)
r	   etltocsvr   encodegetvaluer   fromcsvr   	appendcsv)tbl1ssexpectactualtbl2 r'   R/var/www/Datamplify/venv/lib/python3.10/site-packages/petl/test/io/test_sources.pytest_memorysource   s"   




r)   c                  C   s<   d} t s	| d} tt| }d}t|| t|| d S )Nr   r   r   )r   r   r   r    r	   r   )datar%   r$   r'   r'   r(   test_memorysource_2/   s   

r+   c                  C   s,   d} d}t jtddd|d}t| | d S )N)r    zecho foo barT)shell)	delimiter)r   r    r
   r   )r$   r.   r%   r'   r'   r(   test_popensource=   s   r/   c                  C   sd   g d} t  j}t| | t  j}tj|dd}||d |  tt	|d}t
| | d S )Nr   r   r   w)modezdata.tsv)r   namer   totsvzipfileZipFilewriteclosefromtsvr   r   )tblfn_tsvfn_zipzr%   r'   r'   r(   test_zipsourceG   s   r>   c                  C   >   g d} t j| t dd t j| t dd t | t  d S )Nr   )r      )r      r   encodingr   r   r   tohtmltopickler:   r'   r'   r(   test_stdoutsourceW   s   rI   c                 C   s<   g d}t j|dd |  }|j}|r|dv sJ d S d S )Nr@   r   rC   )zfoo,bar
a,1
b,2
zfoo,bar
a,1
b,2
)r   r   
readouterrout)capfdr:   capturedoutpr'   r'   r(   test_stdoutsource_none_   s   rO   c                  C   r?   )N)r   )u   Արամ ԽաչատրյանrA   )u   Johann StraußrB   zutf-8rC   rE   rH   r'   r'   r(   test_stdoutsource_unicodej   s   rP   c                  C      g d} t  jd }d}tj| t|dd t| }t|| tj| |dd t| }t|| t	t|}t
| | t	|}t
| | d S )Nr0   z.gz   foo,bar
a,1
b,2

lineterminator)r   r3   r   r   r   gzipopenreadr   r    r   r:   fnr$   r%   r&   r'   r'   r(   test_gzipsourcet      



r[   c                  C   rQ   )Nr0   z.bz2rR   rS   rT   )r   r3   r   r   r   bz2BZ2FilerX   r   r    r   rY   r'   r'   r(   test_bzip2source   r\   r_   ) 
__future__r   r   r   rV   r]   r5   tempfiler   petl.compatr   petl.test.helpersr   r   petlr   petl.io.sourcesr	   r
   r   r   r   r   r)   r+   r/   r>   rI   rO   rP   r[   r_   r'   r'   r'   r(   <module>   s$    

