
    5pj6                     T   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  SSKJrJr  SS	KJrJr   " S
 S\\R4                  5      r " S S\\R4                  5      rSS1r\\\" SSS94   rS\S-  S\S-  S\S-  4S jr \" SS9r!\!RE                  S/ SQS9\RF                  \RH                  SS\RJ                  S4S\S\\\" SSS S94   S!\\\" S"S#S$S94   S%\S&\S'\S(\SS4S) jj5       r&\!RE                  S*S+S,/S9\RJ                  S4S\S-\S'\S(\SS4
S. jj5       r'\!RE                  S// S0QS9SSS1\RJ                  S4S\S2\\\" S3S4S94   S\\S-  \" S5S6S94   S\\S-  \" S7S8S94   S9\\(\" S:S;S<S94   S'\S(\SS4S= jj5       r)\!RE                  S>S?S@/S9SS\RJ                  S4S\S-\S\\S-  \" S5SAS94   S\\S-  \" S7SBS94   S'\S(\SS4SC jj5       r*\!RE                  SDSESF/S9SS\RJ                  S4S\S-\SG\\\" SHS94   S\\S-  \" S5SIS94   S\\S-  \" S7SJS94   S'\S(\SS4SK jj5       r+\!RE                  SLSMSN/S9SS1\RJ                  S4S\S-\S>\\S-  \" SOSPS94   SQ\\(\" SRSSSTS94   S'\S(\SS4SU jj5       r,\!RE                  SVSWSX/S9SS1\RJ                  S4S\S-\S>\\S-  \" SOSYS94   SQ\\(\" SRSSSTS94   S'\S(\SS4SZ jj5       r-\!RE                  S[S\/S9\RJ                  S4S\S-\S]\\\" S^S94   S'\S(\SS4S_ jj5       r.\!RE                  S`SaSb/S9SS1\RJ                  S4S\S-\S>\\S-  \" SOScS94   SQ\\(\" SRSSSTS94   S'\S(\SS4Sd jj5       r/\!RE                  SeSf/S9\RJ                  S4S\S-\S'\S(\SS4
Sg jj5       r0g)hzYContains commands to interact with discussions and pull requests on the Hugging Face Hub.    N)Path)	Annotated)	constants   )	AuthorOptLimitOpt	RepoIdArgRepoTypeRepoTypeOptTokenOpt
get_hf_apityper_factory)ArgumentOption)_dataclass_to_dict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       [/var/www/html/pdf-tiff/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)clickBadParameterstrsysstdinread	read_text)r*   r+   s     r"   
_read_bodyr7   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9  gs  snf )	z-List discussions and pull requests on a repo.r@   r   r   N)r:   r=   discussion_typediscussion_statusr?   )numtitleis_pull_requestr;   r=   
created_atrE   )headersid_key)r   r   r   r   r$   r   valueget_repo_discussions_CLIENT_SIDE_STATUSESr;   appendlenr   r   table)r:   r;   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 9s   D	infoz'hf discussions info username/my-model 5z5hf discussions info username/my-model 5 --format jsonrE   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.rB   r:   discussion_numr?   N)r   get_discussion_detailsrK   r   dictr:   rE   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"FrF   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.rB   )r:   rF   descriptionr?   r'   zpull requestr&   zrefs/pr/NzCreated z #z on )rE   urlref)r7   r   create_discussionrK   rE   r   resultrd   )r:   rF   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.N)Either --body or --body-file is required.rB   r:   r[   ri   r?   zCommented on # in rE   repo)r7   r0   r1   r   comment_discussionrK   r   rg   )r:   rE   r*   r+   r?   r@   ri   rQ   s           r"   discussion_commentrq      so    8 )G  !LMM
5
!C//	   JJuD	2Jr!   editzHhf discussions edit username/my-model 5 abc123 --body "Updated comment."zChf discussions edit username/my-model 5 abc123 --body-file fixed.md
comment_idzLThe ID of the comment to edit (see 'hf discussions info ... --format json').z)The new comment text (supports Markdown).z4Read the new comment from a file. Use '-' for stdin.c                     [        X45      nUc  [        R                  " S5      e[        US9nUR	                  U UUUUR
                  S9  [        R                  " SU SU SU  3XUS9  g)	z9Edit an existing comment on a discussion or pull request.Nrk   rB   )r:   r[   rs   new_contentr?   zEdited comment z on #rm   )rE   ro   rs   )r7   r0   r1   r   edit_discussion_commentrK   r   rg   )	r:   rE   rs   r*   r+   r?   r@   ru   rQ   s	            r"   discussion_editrw     s}    D T-K  !LMM
5
!C//    JJE#d7)D#hrsr!   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 ''?ry   rB   r   r:   r[   
new_statusri   r?   zClosed #rm   rn   Nr   confirmr   change_discussion_statusrK   rg   r:   rE   ri   ry   r?   r@   rQ   s          r"   discussion_closer   D  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 #r{   r|   r}   rB   r   r~   z
Reopened #rm   rn   Nr   r   s          r"   discussion_reopenr   m  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.rB   )r:   r[   r   r?   z	Renamed #rm   )rE   ro   rF   N)r   rename_discussionrK   r   rg   )r:   rE   r   r?   r@   rQ   s         r"   discussion_renamer     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 #r{   r|   r}   rB   rl   zMerged #rm   rn   N)r   r   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.rB   rZ   zNo diff available.N)r   r\   rK   r   r   textr^   s         r"   discussion_diffr     sV     5
!C((// ) G
 ||%&r!   )1__doc__enumr3   pathlibr   typingr   r0   huggingface_hubr   
_cli_utilsr   r   r	   r
   r   r   r   r   
_frameworkr   r   _outputr   r   r2   Enumr   r$   rM   intDiscussionNumArgr7   discussions_clicommandr   r   modelrW   r`   boolrh   rq   rw   r   r   r   r   r   r   r!   r"   <module>r      sF   `  
    %	 	 	 ) ,sDII "S$)) " "7+  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 
RM  , 	 	%^^1&t&t	&t _	
	&t d
<	
	&t  tG	
	!&t. /&t0 1&t2 
3&t&tR 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!   