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
 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 d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j0ej1ej2ej3ej4ej5ej6ej7ej8f d:d8d9Z9dS );    )annotations)ListN)Console)Table   )Dialect)Package)Resource)TableResource)Schema)system   )commonhelpers)console
   describe)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stats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z1tj	|	|
|||||||d	}"tj
|||||||d}#tjt| |||||||||"||#|d}$W n tyr }% ztj| ||%d	 tjddd
}%~%ww |r|$ }&t|& t |st|$ttfr|$  }&t|& t | d t|$ttfsJ t|$tr|$gn|$j}'tdd}(|(d |(d |(d |r|(d |(d |(d |(d |'D ]B})|)jrdnd}*|)j|)j|)jg}+|r|+t |)j! |+t |)j" |+t |)j#p	d |+t |)j$pd |(j%|+d|*i q| |( | d |'D ]N})t|)t&ryt|)jd}(t'|)j(j)},|,d
t* D ]}-|(|- qFt+|,t*kr[|(d |)j(j,d
t* }+t+|,t*kro|+d |(j%|+  | |( q,d
S )z
    Describe a data source.

    Based on the inferred data source type it will return resource or package descriptor.
    Default output format is YAML with a front matter.
    )r   z(Providing "source" or "path" is required)note   )code)	
descriptorr   r    r!   r"   r#   r$   r%   r&   )r(   r*   r+   r,   r-   r/   r0   )r   r   r   r   r   r   r   r   r   r   r1   detectorr2   )r5   	exceptionNz[bold]Datasetdataset)titler   r   r   hashbytesfieldsrows	sky_blue1 stylez[bold]Tablesz...)-r   r   r6   r7   r   create_sourceprint_errortyperExitcreate_dialectcreate_detectorr	   r   	Exceptionprint_exceptionto_jsonprint
isinstancer   r   to_yamlstripruler   	resourcesr   
add_columntabularr   r   r   appendr   r@   rA   rB   rC   add_rowr
   listschemar,   DEFAULT_MAX_FIELDSlenfield_types).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   r5   r6   r7   r   r8   dialect_objdetector_objmetadatar=   r;   rU   viewresourcerF   rowlabelslabel rg   _/var/www/Datamplify/venv/lib/python3.10/site-packages/frictionless/console/commands/describe.pyconsole_describe   s   .















ri   )@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'   r5   r'   r6   r'   r7   r   ):
__future__r   typingr   rI   rich.consoler   
rich.tabler   r   r   packager   rc   r	   rU   r
   r[   r   r   rE   r   r   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/   r0   r1   r2   r3   r4   r5   r6   r7   ri   rg   rg   rg   rh   <module>   s`    
