o
    QDiT                     @  s  d dl mZ d dlmZ d dlZd dlmZ d dlmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZmZ ddlmZ ejddejejejejejejejejejejejejej ej!ej"ej#ej$ej%ej&ej'ejejejej(ddej)ej*ej+fd1d/d0Z,dS )2    )annotations)ListN)Console)track   )FrictionlessException)platform)Resource)system   )commonhelpers)consoleconvertname)defaultsource	List[str]r   strtypepathschemeformatcompression	innerpathencodingschemabasepathdialectheader_rowsheader_joincomment_charcomment_rowssheettablekeyskeyedboolto_path	to_format
to_dialectto_csv_delimiterdebugtrusted	standardsc           #      C  sn  t  }|r|t_|r|t_tj| |d} | s'|s'd}tj||d tjddzetj	|||||||||d	}t
t| ||||||||	|
d
}|rL||_tj	||d}|j|d	} | d
 }t|tjjsod|j d}t||d tddgddD ]}!|!dkr|j|||d q|W n ty }" ztj|||"d tjddd}"~"ww |d |d| d dS )z
    Convert data table
    )r   z(Providing "source" or "path" is required)note   )code)	
descriptorr    r!   r"   r#   r$   r%   r&   r'   )
r   r   r   r   datatyper   r   r   r   r   )r3   csv_delimiterr   r   zResource with data type "z" is not convertiblez[bold]ConvertstartendzConverting...)description)r)   r*   r+   )r-   	exceptionNz[bold]Resultz Succesefully converted to [bold]z[/bold])r   r
   r.   r/   r   create_sourceprint_errortyperExitcreate_dialectr	   r   list
isinstancer   frictionless_resourcesConvertibler4   r   ruler   r   	Exceptionprint_exceptionprint)#r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r)   r*   r+   r,   r-   r.   r/   r   r0   dialect_objresourceto_dialect_obj	resourcesstager9    rL   ^/var/www/Datamplify/venv/lib/python3.10/site-packages/frictionless/console/commands/convert.pyconsole_convert   sx   %

rN   )6r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r$   r   r%   r   r&   r   r'   r(   r)   r   r*   r   r+   r   r,   r   r-   r(   r.   r(   r/   r   )-
__future__r   typingr   r<   rich.consoler   rich.progressr   r9   r   r   rH   r	   r
    r   r   r   commandr   resource_namer   r   r   r   r   r   r   r   r   r   r    r!   r"   	skip_rowsr$   r%   r&   r'   Optionr-   r.   r/   rN   rL   rL   rL   rM   <module>   sP    

