
    Wi                        d Z ddlZddlZddlmZmZmZ ddlZddlm	Z	m
Z
mZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ  e ee            Z ee      Z  ejB                  de D  ci c]  } | |  c} e"	      Z#eee"    ejH                  d
djK                  e       d ee            f   Z& ed      Z'e'jQ                  dddg      ddddddejR                  ddf	dedededeee#    ejH                  d      f   dede&dededed dfd!       Z*e'jQ                  d"d#d$g      	 	 	 d)d%ee" ejV                  d&      f   d'ede&ded df
d(       Z,yc c} w )*a  Contains commands to interact with spaces on the Hugging Face Hub.

Usage:
    # list spaces on the Hub
    hf spaces ls

    # list spaces with a search query
    hf spaces ls --search "chatbot"

    # get info about a space
    hf spaces info enzostvs/deepsite
    N)	AnnotatedOptionalget_args)CLIErrorRepositoryNotFoundErrorRevisionNotFoundError)ExpandSpaceProperty_TSpaceSort_T   )	AuthorOpt	FilterOpt	FormatOptLimitOptOutputFormatQuietOptRevisionOpt	SearchOptTokenOptapi_object_to_dict
get_hf_apimake_expand_properties_parserprint_list_outputtyper_factorySpaceSortEnum)typezMComma-separated properties to expand. Example: '--expand=likes,tags'. Valid: z, .)helpcallbackz Interact with spaces on the Hub.)r   lszhf spaces ls --limit 10z4hf spaces ls --search "chatbot" --author huggingface)examples
   FsearchauthorfiltersortzSort results.limitexpandformatquiettokenreturnc	                     t        |      }	|r|j                  nd}
|	j                  ||| |
||      D cg c]  }t        |       }}t	        |||       yc c}w )zList spaces on the Hub.r*   N)r$   r#   r"   r%   r&   r'   )r(   r)   )r   valuelist_spacesr   r   )r"   r#   r$   r%   r&   r'   r(   r)   r*   apisort_key
space_inforesultss                f/home/sietch6/trending-topics-pipeline/venv/lib/python3.12/site-packages/huggingface_hub/cli/spaces.py	spaces_lsr5   G   sn    , 5
!C!tzztH //&he\b * 
 	:&G  gfE:s   Ainfoz hf spaces info enzostvs/deepsitez>hf spaces info gradio/theme_builder --expand sdk,runtime,likesspace_idz)The space ID (e.g. `username/repo-name`).revisionc                    t        |      }	 |j                  | ||      }t        t        j                  t        |      d	
             y# t        $ r}t        d|  d      |d}~wt        $ r}t        d| d|  d      |d}~ww xY w)z"Get info about a space on the Hub.r-   )repo_idr8   r'   zSpace 'z' not found.Nz
Revision 'z' not found on 'z'.   )indent)	r   r2   r   r   r   printjsondumpsr   )r7   r8   r'   r*   r0   r6   es          r4   spaces_inforA   h   s     5
!CS~~h&~Q
 
$**'-a
89	 # @
,78a?  SH:-=hZrJKQRRSs#   A 	B	A%%B	1BB	)NNN)-__doc__enumr>   typingr   r   r   typerhuggingface_hub.errorsr   r   r   huggingface_hub.hf_apir	   r
   
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   sorted_EXPAND_PROPERTIES_SORT_OPTIONSEnumstrr   Optionjoin	ExpandOpt
spaces_clicommandtabler5   ArgumentrA   )ss   0r4   <module>rV      s.     0 0  [ [ E   $ H%:;< %		/-+HQAqD+HsS SMELL\]a]f]fgy]z\{{|}./AB	  BC
 !>    	$**;;; ; /*	,	; ; ; ; ; ; 
;;4 
*H   !	:^U^^1\]]^:: : 	:
 
::o ,Is   2
E!
