o
    QDi                      @  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
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*ej+ej,ej-ej.ej/ej0ej1fd5d3d4Z2dS )6    )annotations)ListN)Console)Table   )to_jsonto_yaml)Resource)system   )commonhelpers)consolelistnamesource	List[str]r   strtypepathschemeformatencoding	innerpathcompressiondialectheader_rowsheader_joincomment_charcomment_rowssheettablekeyskeyedboolbuffer_sizeintsample_size
field_typefield_namesfield_confidencefloatfield_float_numbersfield_missing_valuesbasepathyamljsondebugtrusted	standardsc           +      C  s  t  }|r|t_|r|t_tj| |d} | s'|s'd} tj|| d tjddz@tj	|	|
|||||||d	}!tj
|||||||d}"tt| ||||||||||"d}#|!rY|!|#_|#j|d	}$d
d |$D }%W n ty }& ztj|||&d tjddd}&~&ww |rt|% }'t|' t |rt|% }'t|' t |d tdd}(|(d |(d |(d |$D ]}#|#jrdnd})|#j|#j|#jg}*|(j|*d|)i q||( dS )z
    List a data source.
    )r   z(Providing "source" or "path" is required)note   )code)	
descriptorr   r   r   r    r!   r"   r#   r$   )r&   r(   r)   r*   r+   r-   r.   )r   r   r   r   r   datatyper   r   r   r/   detectorr   c                 S  s   g | ]}|  qS  )to_descriptor).0resourcer;   r;   [/var/www/Datamplify/venv/lib/python3.10/site-packages/frictionless/console/commands/list.py
<listcomp>v   s    z$console_describe.<locals>.<listcomp>)r2   	exceptionNz[bold]Datasetdataset)titler   r   r   	sky_blue1 style)r   r
   r3   r4   r   create_sourceprint_errortyperExitcreate_dialectcreate_detectorr	   r   r   	Exceptionprint_exceptionr   stripprintr   ruler   
add_columntabularr   r   r   add_row)+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   r1   r2   r3   r4   r   r5   dialect_objdetector_objr>   	resourcesdescriptorsrA   r8   viewrF   rowr;   r;   r?   console_describe   s   *




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   r0   r%   r1   r%   r2   r%   r3   r%   r4   r   )3
__future__r   typingr   rI   rich.consoler   
rich.tabler   r   r   r   r>   r	   r
   rE   r   r   commandr   resource_namer   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r&   r(   r)   r*   r+   r-   r.   r/   r0   r1   r2   r3   r4   r[   r;   r;   r;   r?   <module>   sV    
