
    9iG0                     ^   S r SSKJr  SSKJr  SSKJrJrJrJr  SSK	J
r
  SSKJr  \S   r\ " S	 S
5      5       r\ " S S\5      5       r " S S\5      r\ " S S5      5       r\ " S S\5      5       r\ " S S\5      5       r\ " S S\5      5       r\ " S S\5      5       rS\S\4S jrg)a  
Data structures to interact with Discussions and Pull Requests on the Hub.

See [the Discussions and Pull Requests guide](https://huggingface.co/docs/hub/repositories-pull-requests-discussions)
for more information on Pull Requests, Discussions, and the community tab.
    )	dataclass)datetime)LiteralOptional	TypedDictUnion   )	constants)parse_datetime)openclosedmergeddraftc                       \ rS rSr% Sr\\S'   \\S'   \\S'   \\S'   \\S'   \\S'   \	\S	'   \
\S
'   \\S'   \S\\   4S j5       r\S\4S j5       rSrg)
Discussion   a  
A Discussion or Pull Request on the Hub.

This dataclass is not intended to be instantiated directly.

Attributes:
    title (`str`):
        The title of the Discussion / Pull Request
    status (`str`):
        The status of the Discussion / Pull Request.
        It must be one of:
            * `"open"`
            * `"closed"`
            * `"merged"` (only for Pull Requests )
            * `"draft"` (only for Pull Requests )
    num (`int`):
        The number of the Discussion / Pull Request.
    repo_id (`str`):
        The id (`"{namespace}/{repo_name}"`) of the repo on which
        the Discussion / Pull Request was open.
    repo_type (`str`):
        The type of the repo on which the Discussion / Pull Request was open.
        Possible values are: `"model"`, `"dataset"`, `"space"`.
    author (`str`):
        The username of the Discussion / Pull Request author.
        Can be `"deleted"` if the user has been deleted since.
    is_pull_request (`bool`):
        Whether or not this is a Pull Request.
    created_at (`datetime`):
        The `datetime` of creation of the Discussion / Pull Request.
    endpoint (`str`):
        Endpoint of the Hub. Default is https://huggingface.co.
    git_reference (`str`, *optional*):
        (property) Git reference to which changes can be pushed if this is a Pull Request, `None` otherwise.
    url (`str`):
        (property) URL of the discussion on the Hub.
titlestatusnumrepo_id	repo_typeauthoris_pull_request
created_atendpointreturnc                 D    U R                   (       a  SU R                   3$ g)zq
If this is a Pull Request , returns the git reference to which changes can be pushed.
Returns `None` otherwise.
zrefs/pr/N)r   r   selfs    Y/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/huggingface_hub/community.pygit_referenceDiscussion.git_referenceE   s!     dhhZ((    c                    U R                   b  U R                   [        R                  :X  a(  U R                   SU R                   SU R
                   3$ U R                   SU R                    SU R                   SU R
                   3$ )z-Returns the URL of the discussion on the Hub./z/discussions/zs/)r   r
   REPO_TYPE_MODELr   r   r   r   s    r    urlDiscussion.urlO   sp     >>!T^^y7P7P%Pmm_Adll^=
KK--$..!1DLL>txxjYYr#    N)__name__
__module____qualname____firstlineno____doc__str__annotations__DiscussionStatusintboolr   propertyr   r!   r'   __static_attributes__r)   r#   r    r   r      su    $L J	HLNKMx}   ZS Z Zr#   r   c                   v    \ rS rSr% Sr\S   \S'   \\\   \	S4   \S'   \
\   \S'   \
\   \S'   \
\   \S	'   S
rg)DiscussionWithDetailsW   a{  
Subclass of [`Discussion`].

Attributes:
    title (`str`):
        The title of the Discussion / Pull Request
    status (`str`):
        The status of the Discussion / Pull Request.
        It can be one of:
            * `"open"`
            * `"closed"`
            * `"merged"` (only for Pull Requests )
            * `"draft"` (only for Pull Requests )
    num (`int`):
        The number of the Discussion / Pull Request.
    repo_id (`str`):
        The id (`"{namespace}/{repo_name}"`) of the repo on which
        the Discussion / Pull Request was open.
    repo_type (`str`):
        The type of the repo on which the Discussion / Pull Request was open.
        Possible values are: `"model"`, `"dataset"`, `"space"`.
    author (`str`):
        The username of the Discussion / Pull Request author.
        Can be `"deleted"` if the user has been deleted since.
    is_pull_request (`bool`):
        Whether or not this is a Pull Request.
    created_at (`datetime`):
        The `datetime` of creation of the Discussion / Pull Request.
    events (`list` of [`DiscussionEvent`])
        The list of [`DiscussionEvents`] in this Discussion or Pull Request.
    conflicting_files (`Union[list[str], bool, None]`, *optional*):
        A list of conflicting files if this is a Pull Request.
        `None` if `self.is_pull_request` is `False`.
        `True` if there are conflicting files but the list can't be retrieved.
    target_branch (`str`, *optional*):
        The branch into which changes are to be merged if this is a
        Pull Request . `None`  if `self.is_pull_request` is `False`.
    merge_commit_oid (`str`, *optional*):
        If this is a merged Pull Request , this is set to the OID / SHA of
        the merge commit, `None` otherwise.
    diff (`str`, *optional*):
        The git diff if this is a Pull Request , `None` otherwise.
    endpoint (`str`):
        Endpoint of the Hub. Default is https://huggingface.co.
    git_reference (`str`, *optional*):
        (property) Git reference to which changes can be pushed if this is a Pull Request, `None` otherwise.
    url (`str`):
        (property) URL of the discussion on the Hub.
DiscussionEventeventsNconflicting_filestarget_branchmerge_commit_oiddiffr)   )r*   r+   r,   r-   r.   listr0   r   r/   r3   r   r5   r)   r#   r    r7   r7   W   sJ    0d "##T#Yd233C= sm#
3-r#   r7   c                   H    \ rS rSr% \\S'   \\S'   \\S'   \\S'   \\S'   Srg)	DiscussionEventArgs   idtyper   r   _eventr)   N)	r*   r+   r,   r-   r/   r0   r   dictr5   r)   r#   r    rA   rA      s    G
IKLr#   rA   c                   L    \ rS rSr% Sr\\S'   \\S'   \\S'   \\S'   \\S'   Sr	g	)
r9      a  
An event in a Discussion or Pull Request.

Use concrete classes:
    * [`DiscussionComment`]
    * [`DiscussionStatusChange`]
    * [`DiscussionCommit`]
    * [`DiscussionTitleChange`]

Attributes:
    id (`str`):
        The ID of the event. An hexadecimal string.
    type (`str`):
        The type of the event.
    created_at (`datetime`):
        A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)
        object holding the creation timestamp for the event.
    author (`str`):
        The username of the Discussion / Pull Request author.
        Can be `"deleted"` if the user has been deleted since.
rC   rD   r   r   rE   r)   N)
r*   r+   r,   r-   r.   r/   r0   r   rF   r5   r)   r#   r    r9   r9      s&    , 	G
IKLMr#   r9   c                       \ rS rSr% Sr\\S'   \\S'   \\S'   \S\4S j5       r	\S\
4S j5       r\S\4S	 j5       r\S\\   4S
 j5       r\S\4S j5       rSrg)DiscussionComment   a.  A comment in a Discussion / Pull Request.

Subclass of [`DiscussionEvent`].


Attributes:
    id (`str`):
        The ID of the event. An hexadecimal string.
    type (`str`):
        The type of the event.
    created_at (`datetime`):
        A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)
        object holding the creation timestamp for the event.
    author (`str`):
        The username of the Discussion / Pull Request author.
        Can be `"deleted"` if the user has been deleted since.
    content (`str`):
        The raw markdown content of the comment. Mentions, links and images are not rendered.
    edited (`bool`):
        Whether or not this comment has been edited.
    hidden (`bool`):
        Whether or not this comment has been hidden.
contenteditedhiddenr   c                 ,    U R                   S   S   S   $ )z&The rendered comment, as a HTML stringdatalatesthtmlrE   r   s    r    renderedDiscussionComment.rendered   s     {{6"8,V44r#   c                 >    [        U R                  S   S   S   5      $ )+The last edit time, as a `datetime` object.rP   rQ   	updatedAt)r   rE   r   s    r    last_edited_at DiscussionComment.last_edited_at   s"     dkk&1(;KHIIr#   c                 f    U R                   S   S   R                  S0 5      R                  SS5      $ )rW   rP   rQ   r   namedeleted)rE   getr   s    r    last_edited_by DiscussionComment.last_edited_by   s2     {{6"8,002>BB69UUr#   c                 &    U R                   S   S   $ )zThe edit history of the commentrP   historyrS   r   s    r    edit_historyDiscussionComment.edit_history   s     {{6"9--r#   c                 ,    [        U R                  5      $ )N)lenrc   r   s    r    number_of_edits!DiscussionComment.number_of_edits   s    4$$%%r#   r)   N)r*   r+   r,   r-   r.   r/   r0   r3   r4   rT   r   rY   r_   r?   rF   rc   r2   rg   r5   r)   r#   r    rJ   rJ      s    0 LLL5# 5 5 J J J V V V .d4j . . & & &r#   rJ   c                   $    \ rS rSr% Sr\\S'   Srg)DiscussionStatusChange   a
  A change of status in a Discussion / Pull Request.

Subclass of [`DiscussionEvent`].

Attributes:
    id (`str`):
        The ID of the event. An hexadecimal string.
    type (`str`):
        The type of the event.
    created_at (`datetime`):
        A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)
        object holding the creation timestamp for the event.
    author (`str`):
        The username of the Discussion / Pull Request author.
        Can be `"deleted"` if the user has been deleted since.
    new_status (`str`):
        The status of the Discussion / Pull Request after the change.
        It can be one of:
            * `"open"`
            * `"closed"`
            * `"merged"` (only for Pull Requests )

new_statusr)   Nr*   r+   r,   r-   r.   r/   r0   r5   r)   r#   r    rj   rj      s    . Or#   rj   c                   .    \ rS rSr% Sr\\S'   \\S'   Srg)DiscussionCommiti  a  A commit in a Pull Request.

Subclass of [`DiscussionEvent`].

Attributes:
    id (`str`):
        The ID of the event. An hexadecimal string.
    type (`str`):
        The type of the event.
    created_at (`datetime`):
        A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)
        object holding the creation timestamp for the event.
    author (`str`):
        The username of the Discussion / Pull Request author.
        Can be `"deleted"` if the user has been deleted since.
    summary (`str`):
        The summary of the commit.
    oid (`str`):
        The OID / SHA of the commit, as a hexadecimal string.
summaryoidr)   Nrm   r)   r#   r    ro   ro     s    * L	Hr#   ro   c                   .    \ rS rSr% Sr\\S'   \\S'   Srg)DiscussionTitleChangei)  a  A rename event in a Discussion / Pull Request.

Subclass of [`DiscussionEvent`].

Attributes:
    id (`str`):
        The ID of the event. An hexadecimal string.
    type (`str`):
        The type of the event.
    created_at (`datetime`):
        A [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime)
        object holding the creation timestamp for the event.
    author (`str`):
        The username of the Discussion / Pull Request author.
        Can be `"deleted"` if the user has been deleted since.
    old_title (`str`):
        The previous title for the Discussion / Pull Request.
    new_title (`str`):
        The new title.
	old_title	new_titler)   Nrm   r)   r#   r    rs   rs   )  s    * NNr#   rs   eventr   c                    U S   nU S   n[        U S   5      nUUUU R                  S0 5      R                  SS5      U S.nUS:X  a&  [        S0 UDU S	   S
   U S	   S   U S	   S   S   S.D6$ US:X  a  [        S0 UDSU S	   S   0D6$ US:X  a  [	        S0 UDU S	   S   U S	   S   S.D6$ US:X  a  [        S0 UDU S	   S   U S	   S   S.D6$ [        S0 UD6$ )z.Instantiates a [`DiscussionEvent`] from a dictrC   rD   	createdAtr   r\   r]   )rC   rD   r   r   rE   commentrP   rM   rN   rQ   raw)rM   rN   rL   zstatus-changerl   r   commitsubjectrq   )rp   rq   ztitle-changefromto)rt   ru   r)   )r   r^   rJ   rj   ro   rs   r9   )rv   event_id
event_typer   common_argss        r    deserialize_eventr   D  sX   $KHFmJk 23J  ))Hb)--fi@(K Y  

=*=*&M(+E2	
 	
 _$% 

V}X.
 	
 X 

&M),fe$
 	

 ^#$ 

FmF+FmD)
 	
 )[))r#   N)r.   dataclassesr   r   typingr   r   r   r    r
   utilsr   r1   r   r7   rA   r9   rJ   rj   ro   rs   rF   r   r)   r#   r    <module>r      s   "  6 6  ! >?  @Z @Z @ZF 7J 7 7t)  N N N@ 3& 3& 3&l _  6   4 O  4'*T '*o '*r#   