
    Y jn1                        S r SSKrSSKrSSKJr  SSKJr  SSKrSSKJ	r	  SSK
JrJrJrJrJrJrJrJrJr  SSKJr   " S	 S
\\R.                  5      r " S S\\R.                  5      rSS1r\\\R8                  " SSS94   rS\S-  S\S-  S\S-  4S jr\" SS9r\RA                  S/ SQS9\RB                  \RD                  SS\RF                  S4S\S\\\RH                  " SSSS94   S \\\RH                  " S!S"S#S94   S$\S%\S&\S'\SS4S( jj5       r%\RA                  S)S*S+/S9\RF                  S4S\S,\S&\S'\SS4
S- jj5       r&\RA                  S./ S/QS9SSS0\RF                  S4S\S1\\\RH                  " S2S3S94   S\\S-  \RH                  " S4S5S94   S\\S-  \RH                  " S6S7S94   S8\\'\RH                  " S9S:S;S94   S&\S'\SS4S< jj5       r(\RA                  S=S>S?/S9SS\RF                  S4S\S,\S\\S-  \RH                  " S4S@S94   S\\S-  \RH                  " S6SAS94   S&\S'\SS4SB jj5       r)\RA                  SCSDSE/S9SS0\RF                  S4S\S,\S=\\S-  \RH                  " SFSGS94   SH\\'\RH                  " SISJSKS94   S&\S'\SS4SL jj5       r*\RA                  SMSNSO/S9SS0\RF                  S4S\S,\S=\\S-  \RH                  " SFSPS94   SH\\'\RH                  " SISJSKS94   S&\S'\SS4SQ jj5       r+\RA                  SRSS/S9\RF                  S4S\S,\ST\\\R8                  " SUS94   S&\S'\SS4SV jj5       r,\RA                  SWSXSY/S9SS0\RF                  S4S\S,\S=\\S-  \RH                  " SFSZS94   SH\\'\RH                  " SISJSKS94   S&\S'\SS4S[ jj5       r-\RA                  S\S]/S9\RF                  S4S\S,\S&\S'\SS4
S^ jj5       r.g)_zYContains commands to interact with discussions and pull requests on the Hugging Face Hub.    N)Path)	Annotated)	constants   )		AuthorOptLimitOpt	RepoIdArgRepoTypeRepoTypeOptTokenOptapi_object_to_dict
get_hf_apityper_factory)outc                   (    \ rS rSrSrSrSrSrSrSr	g)	DiscussionStatus'   openclosedmergeddraftall N)
__name__
__module____qualname____firstlineno__r   r   r   r   r   __static_attributes__r       p/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/huggingface_hub/cli/discussions.pyr   r   '   s    DFFE
Cr   r   c                        \ rS rSrSrSrSrSrg)DiscussionKind/   r   
discussionpull_requestr   N)r   r   r   r   r   r$   r%   r   r   r   r    r"   r"   /   s    
CJ!Lr   r"   r   r   z&The discussion or pull request number.)helpminbody	body_filereturnc                     U b  Ub  [         R                  " S5      eUb<  [        U5      S:X  a  [        R                  R                  5       $ UR                  SS9$ U $ )zFResolve body text from --body or --body-file (supports '-' for stdin).z'Cannot use both --body and --body-file.-zutf-8)encoding)typerBadParameterstrsysstdinread	read_text)r(   r)   s     r    
_read_bodyr5   E   s[    I1  !JKKy>S 99>>##""G"44Kr   z0Manage discussions and pull requests on the Hub.)r&   z	list | ls)z%hf discussions list username/my-modelzIhf discussions list username/my-model --kind pull_request --status mergedzFhf discussions list username/my-dataset --type dataset --status closedzBhf discussions list username/my-model --author alice --format json)examples   repo_idstatusz-sz--statusz4Filter by status (open, closed, merged, draft, all).kindz-kz--kindz/Filter by kind (discussion, pull_request, all).authorlimit	repo_typetokenc                 "   [        US9nU[        R                  :X  a  SnOU[        R                  :X  a  SnOSnU[        R
                  :X  a  Sn	OUR                  n	/ n
UR                  U UU	UUR                  S9 HU  nUR                  [        ;   a  UR                  UR                  :w  a  M3  U
R                  U5        [        U
5      U:  d  MU    O   U
 Vs/ s H  n[        U5      PM     nn[        R                  " U/ SQSSS0S	9  gs  snf )
z-List discussions and pull requests on a repo.r>   r   r   N)r8   r;   discussion_typediscussion_statusr=   )numtitleis_pull_requestr9   r;   
created_atrC   right)headersid_key
alignments)r   r   r   r   r"   r   valueget_repo_discussions_CLIENT_SIDE_STATUSESr9   appendlenr   r   table)r8   r9   r:   r;   r<   r=   r>   api
api_statusapi_discussion_typediscussionsditemss                r    discussion_listrW   S   s   B 5
!C !&&&
	#**	*

 ~!!!""jjK%%+$// &  <<00QXX5M1{u$ -88Kq"KE8IIU7#	 9s   Dinfoz'hf discussions info username/my-model 5z5hf discussions info username/my-model 5 --format jsonrC   c                 x    [        US9nUR                  U UUR                  S9n[        R                  " U5        g)z,Get info about a discussion or pull request.r@   r8   discussion_numr=   N)r   get_discussion_detailsrK   r   dictr8   rC   r=   r>   rQ   detailss         r    discussion_infor`      s>     5
!C((// ) G
 HHWr   create)z<hf discussions create username/my-model --title "Bug report"zWhf discussions create username/my-model --title "Feature request" --body "Please add X"zIhf discussions create username/my-model --title "Fix typo" --pull-requestzUhf discussions create username/my-dataset --type dataset --title "Data quality issue"FrD   z--titlez,The title of the discussion or pull request.z--bodyz$The description (supports Markdown).z--body-filez4Read the description from a file. Use '-' for stdin.r%   z--pull-requestz--prz.Create a pull request instead of a discussion.c                 (   [        X#5      n[        US9nUR                  U UUUR                  US9n	U(       a  SOSn
U(       a  SU	R                   3OSn[
        R                  " SU
 SU	R                   S	U  3U	R                  U	R                  US
9  g)z2Create a new discussion or pull request on a repo.r@   )r8   rD   descriptionr=   r%   zpull requestr$   zrefs/pr/NzCreated z #z on )rC   urlref)r5   r   create_discussionrK   rC   r   resultrd   )r8   rD   r(   r)   r%   r=   r>   rc   rQ   r$   r:   re   s               r    discussion_createrh      s    X T-K
5
!C&&//! ' J *>|D)5HZ^^$
%4CJJ$r*..!1gY?Z^^YcYgYgmpqr   commentzIhf discussions comment username/my-model 5 --body "Thanks for reporting!"z9hf discussions comment username/my-model 5 --body "LGTM!"z%The comment text (supports Markdown).z0Read the comment from a file. Use '-' for stdin.c                     [        X#5      nUc  [        R                  " S5      e[        US9nUR	                  U UUUR
                  S9  [        R                  " SU SU  3XS9  g)z(Comment on a discussion or pull request.Nz)Either --body or --body-file is required.r@   r8   r[   ri   r=   zCommented on # in rC   repo)r5   r.   r/   r   comment_discussionrK   r   rg   )r8   rC   r(   r)   r=   r>   ri   rQ   s           r    discussion_commentrp      so    8 )G  !LMM
5
!C//	   JJuD	2Jr   closez(hf discussions close username/my-model 5zIhf discussions close username/my-model 5 --comment "Closing as resolved."z	--commentz)An optional comment to post when closing.yesz--yesz-yzSkip confirmation prompt.c                     [         R                  " SU SU  S3US9  [        US9nUR                  U USUUR                  S9  [         R
                  " SU S	U  3XS
9  g)z#Close a discussion or pull request.zClose # on ''?rr   r@   r   r8   r[   
new_statusri   r=   zClosed #rl   rm   Nr   confirmr   change_discussion_statusrK   rg   r8   rC   ri   rr   r=   r>   rQ   s          r    discussion_closer}     sn    : KK'#eG9B/S9
5
!C  // !  JJ#d7),#Dr   reopenz)hf discussions reopen username/my-model 5zZhf discussions reopen username/my-model 5 --comment "Reopening for further investigation."z+An optional comment to post when reopening.c                     [         R                  " SU SU  S3US9  [        US9nUR                  U USUUR                  S9  [         R
                  " SU S	U  3XS
9  g)z+Reopen a closed discussion or pull request.zReopen #rt   ru   rv   r@   r   rw   z
Reopened #rl   rm   Nry   r|   s          r    discussion_reopenr   >  sn    : KK(3%uWIR0c:
5
!C  // !  JJC5WI.CFr   renamez9hf discussions rename username/my-model 5 "Updated title"	new_titlezThe new title.c                     [        US9nUR                  U UUUR                  S9  [        R                  " SU SU  3XUS9  g)z$Rename a discussion or pull request.r@   )r8   r[   r   r=   z	Renamed #rl   )rC   rn   rD   N)r   rename_discussionrK   r   rg   )r8   rC   r   r=   r>   rQ   s         r    discussion_renamer   g  sP    & 5
!C//	   JJ3%tG9-3IVr   mergez(hf discussions merge username/my-model 5zEhf discussions merge username/my-model 5 --comment "Merging, thanks!"z)An optional comment to post when merging.c                     [         R                  " SU SU  S3US9  [        US9nUR                  U UUUR                  S9  [         R
                  " SU SU  3XS	9  g
)zMerge a pull request.zMerge #rt   ru   rv   r@   rk   zMerged #rl   rm   N)r   rz   r   merge_pull_requestrK   rg   r|   s          r    discussion_merger     sk    : KK'#eG9B/S9
5
!C//	   JJ#d7),#Dr   diffz'hf discussions diff username/my-model 5c                     [        US9nUR                  U UUR                  S9nUR                  (       a!  [        R
                  " UR                  5        g[        R
                  " S5        g)z Show the diff of a pull request.r@   rZ   zNo diff available.N)r   r\   rK   r   r   textr^   s         r    discussion_diffr     sV     5
!C((// ) G
 ||%&r   )/__doc__enumr1   pathlibr   typingr   r.   huggingface_hubr   
_cli_utilsr   r   r	   r
   r   r   r   r   r   _outputr   r0   Enumr   r"   rM   intArgumentDiscussionNumArgr5   discussions_clicommandr   r   modelOptionrW   r`   boolrh   rp   r}   r   r   r   r   r   r   r    <module>r      s   `  
    %
 
 
 sDII "S$)) " "7+  	NN5 S4Z D4K C$J   %WX   $ 	 	%^^+<<G	
	< B	
	<$ %<& '<( )<* +<, 
-<<~ 
1?   &^^		  	
 
    0 	 	 	%^^A.r.r?	
	.r d
7	
	.r  tG	
	!.r. A	
	/.r> ?.r@ A.rB 
C.r.rb SC    	 	%^^%KK	K d
8	
	K tC	
	K" #K$ %K& 
'KKD 2S    	 	%^^'EE	E d
<	
	E 
,	
	
E$ %E& 'E( 
)EED 3d    	 	%^^'GG	G d
>	
	G 
,	
	
G$ %G& 'G( 
)GGD C   &^^WW	W !	
	W W W 
WW. 2O    	 	%^^'EE	E d
<	
	E 
,	
	
E$ %E& 'E( 
)EEB 
1   &^^	''	' ' 	'
 
''r   