
    _Og?1                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJ	r	  SS
K
Jr   " S S\R                  5      r " S S\R                  5      r " S S\5      r " S S\5      rg)z?This module contains the Gist, ShortGist, and GistFork objects.    )dumps   )comment)file)history   )models)users)requires_authc                       \ rS rSrSrS r\R                  rS r	S r
S r\S 5       r\S 5       r\S0 4S	 j5       r\S
 5       r\S 5       rSS jrSS jrSS jr\S 5       r\S 5       rSrg)_Gist   a  This object holds all the information returned by Github about a gist.

With it you can comment on or fork the gist (assuming you are
authenticated), edit or delete the gist (assuming you own it).  You can
also "star" or "unstar" the gist (again assuming you have authenticated).

Two gist instances can be checked like so::

    g1 == g2
    g1 != g2

And is equivalent to::

    g1.id == g2.id
    g1.id != g2.id

See also: http://developer.github.com/v3/gists/

c           	      @   US   U l         US   U l        U R                  US   5      U l        US   U l        US   R                  5        VVs0 s H  u  p#X R                  X05      _M     snnU l        US   U l        US   U l	        US   U l
        US	   U l        UR                  S
5      U l        U R                  b&  [        R                  " U R                  U 5      U l        US   U l        U R                  US   5      U l        US   =U l        U l        g s  snnf )Ncommentscomments_url
created_atdescriptionfilesgit_pull_urlgit_push_urlhtml_urlidownerpublic
updated_aturl)comments_countr   	_strptimer   r   items_file_classr   r   r   r   r   getr   r
   	ShortUserr   r   r   _api)selfgistfilenamegfiles       W/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/github3/gists/gist.py_update_attributes_Gist._update_attributes$   s   ":. 0..l);<. $(=#6#6#8
#8 &&u33#8

 !0 0Z(t*XXg&
::!T:DJ8n..l);<#E{*49
s   Dc                     U R                   $ )Nr   r$   s    r(   __str___Gist.__str__8   s    ww    c                      SR                  U S9$ )Nz<{s.class_name} [{s.id}]>)s)formatr-   s    r(   _repr_Gist._repr;   s    *11D199r0   c                     SnU(       a<  U R                  SU R                  S9nU R                  U R                  USU0S9S5      nU R	                  [
        R                  U5      $ )zCreate a comment on this gist.

:param str body:
    (required), body of the comment
:returns:
    Created comment or None
:rtype:
    :class:`~github3.gists.comment.GistComment`
Nr   base_urlbodydata   )
_build_urlr#   _json_post_instance_or_nullr   GistComment)r$   r9   jsonr   s       r(   create_comment_Gist.create_comment>   s\     //*tyy/AC::djjFD>jBCHD%%g&9&94@@r0   c                 Z    U R                  U R                  U R                  5      SS5      $ )z]Delete this gist.

:returns:
    Whether the deletion was successful or not
:rtype:
    bool
     )_boolean_deleter#   r-   s    r(   delete_Gist.deleteO   s$     }}T\\$))4c3??r0    c                     0 nSnU(       a  XS'   U(       a  X#S'   U(       a3  U R                  U R                  U R                  [        U5      S9S5      nU(       a  U R	                  U5        gg)a  Edit this gist.

:param str description:
    (optional), description of the gist
:param dict files:
    (optional), files that make up this gist; the key(s) should be the
    file name(s) and the values should be another (optional) dictionary
    with (optional) keys: 'content' and 'filename' where the former is
    the content of the file and the latter is the new name of the file.
:returns:
    Whether the edit was successful or not
:rtype:
    bool
Nr   r   r:      TF)r>   _patchr#   r   r)   )r$   r   r   r;   rB   s        r(   edit
_Gist.editZ   sb      "-!M::dkk$))%+kFLD##D)r0   c                     U R                  SU R                  S9nU R                  U R                  U5      S5      nU R	                  [
        U5      $ )zFork this gist.

:returns:
    New gist if successfully forked, ``None`` otherwise
:rtype:
    :class:`~github3.gists.gist.ShortGist`
forksr7   r<   )r=   r#   r>   r?   r@   	ShortGist)r$   r   rB   s      r(   fork
_Gist.forkw   sE     oog		o:zz$**S/3/%%i66r0   c                 z    U R                  SU R                  S9nU R                  U R                  U5      SS5      $ )zCheck to see if this gist is starred by the authenticated user.

:returns:
    True if it is starred, False otherwise
:rtype:
    bool
starr7   rF   rG   )r=   r#   rH   _getr$   r   s     r(   
is_starred_Gist.is_starred   5     ooftyyo9}}TYYs^S#66r0   Nc                     U R                  SU R                  S9nU R                  [        U5      U[        R
                  US9$ )aV  Iterate over comments on this gist.

:param int number:
    (optional), number of comments to iterate over.
    Default: -1 will iterate over all comments on the gist
:param str etag:
    (optional), ETag from a previous request to the same endpoint
:returns:
    generator of comments
:rtype:
    :class:`~github3.gists.comment.GistComment`
r   r7   etag)r=   r#   _iterintr   rA   r$   numberr`   r   s       r(   r   _Gist.comments   s;     ooj499o=zz#f+sG,?,?dzKKr0   c                     U R                  SU R                  S9nU R                  [        U5      U[        R
                  5      $ )a!  Iterate over the commits on this gist.

These commits will be requested from the API and should be the same as
what is in ``Gist.history``.

.. versionadded:: 0.6

.. versionchanged:: 0.9

    Added param ``etag``.

:param int number:
    (optional), number of commits to iterate over.
    Default: -1 will iterate over all commits associated with this
    gist.
:param str etag:
    (optional), ETag from a previous request to this endpoint.
:returns:
    generator of the gist's history
:rtype:
    :class:`~github3.gists.history.GistHistory`
commitsr7   )r=   r#   ra   rb   r   GistHistoryrc   s       r(   rg   _Gist.commits   s7    . ooi$))o<zz#f+sG,?,?@@r0   c                 t    U R                  SU R                  S9nU R                  [        U5      U[        US9$ )a  Iterator of forks of this gist.

.. versionchanged:: 0.9

    Added params ``number`` and ``etag``.

:param int number:
    (optional), number of forks to iterate over.
    Default: -1 will iterate over all forks of this gist.
:param str etag:
    (optional), ETag from a previous request to this endpoint.
:returns:
    generator of gists
:rtype:
    :class:`~github3.gists.gist.ShortGist`
rS   r7   r_   )r=   r#   ra   rb   rT   rc   s       r(   rS   _Gist.forks   s5    " oog		o:zz#f+sIDzAAr0   c                 z    U R                  SU R                  S9nU R                  U R                  U5      SS5      $ )zTStar this gist.

:returns:
    True if successful, False otherwise
:rtype:
    bool
rX   r7   rF   rG   )r=   r#   rH   _putrZ   s     r(   rX   
_Gist.star   r]   r0   c                 z    U R                  SU R                  S9nU R                  U R                  U5      SS5      $ )zWUn-star this gist.

:returns:
    True if successful, False otherwise
:rtype:
    bool
rX   r7   rF   rG   )r=   r#   rH   rI   rZ   s     r(   unstar_Gist.unstar   s6     ooftyyo9}}T\\#.S99r0   )r#   r   r   r   r   r   r   r   r   r   r   r   r   r   )N)__name__
__module____qualname____firstlineno____doc__
class_namegistfileShortGistFiler    r)   r.   r4   r   rC   rJ   rP   rU   r[   r   rg   rS   rX   rp   __static_attributes__ r0   r(   r   r      s    ( J((K+(: A A  @ @ !  8 
7 
7 	7 	7L A4B( 	7 	7 	: 	:r0   r   c                   .    \ rS rSrSrS rS rS r\rSr	g)GistFork   a  This object represents a forked Gist.

This has a subset of attributes of a
:class:`~github3.gists.gist.ShortGist`:

.. attribute:: created_at

    The date and time when the gist was created.

.. attribute:: id

    The unique identifier of the gist.

.. attribute:: owner

    The user who forked the gist.

.. attribute:: updated_at

    The date and time of the most recent modification of the fork.

.. attribute:: url

    The API URL for the fork.
c                     U R                  US   5      U l        US   U l        [        R                  " US   U 5      U l        U R                  US   5      U l        US   =U l        U l        g )Nr   r   userr   r   )	r   r   r   r
   r"   r   r   r   r#   )r$   rU   s     r(   r)   GistFork._update_attributes  s_    ..l);<t*__T&\48
..l);<#E{*49r0   c                 "    SU R                    S3$ )Nz<GistFork [z]>r,   r-   s    r(   r4   GistFork._repr	  s    TWWIR((r0   c                     U R                  U R                  U R                  5      S5      nU R                  [        U5      $ )zRetrieve the full Gist representation of this fork.

:returns:
    The Gist if retrieving it was successful or ``None``
:rtype:
    :class:`~github3.gists.gist.Gist`
rN   )r>   rY   r   r@   Gist)r$   rB   s     r(   to_gistGistFork.to_gist  s4     zz$))DHH-s3%%dD11r0   )r#   r   r   r   r   r   N)
rs   rt   ru   rv   rw   r)   r4   r   refreshr{   r|   r0   r(   r~   r~      s    4+)	2 Gr0   r~   c                   H   ^  \ rS rSrSrS r\R                  rU 4S jr	Sr
U =r$ )r   i  a  This object constitutes the full representation of a Gist.

GitHub's API returns different amounts of information about gists
based upon how that information is retrieved. This object exists to
represent the full amount of information returned for a specific
gist. For example, you would receive this class when calling
:meth:`~github3.github.GitHub.gist`. To provide a clear distinction
between the types of gists, github3.py uses different classes with
different sets of attributes.

This object has all the same attributes as
:class:`~github3.gists.gist.ShortGist` as well as:

.. attribute:: commits_url

    The URL to retrieve gist commits from the GitHub API.

.. attribute:: original_forks

    A list of :class:`~github3.gists.gist.GistFork` objects representing
    each fork of this gist. To retrieve the most recent list of forks, use
    the :meth:`forks` method.

.. attribute:: forks_url

    The URL to retrieve the current listing of forks of this gist.

.. attribute:: history

    A list of :class:`~github3.gists.history.GistHistory` objects
    representing each change made to this gist.

.. attribute:: truncated

    This is a boolean attribute that indicates whether the content of this
    Gist has been truncated or not.
c                   > [         TU ]  U5        US   U l        US    Vs/ s H  n[        X 5      PM     snU l        US   U l        US    Vs/ s H  n[        R                  " X05      PM     snU l        US   U l        g s  snf s  snf )Ncommits_urlrS   	forks_urlr   	truncated)	superr)   r   r~   original_forksr   r   rh   r   )r$   r%   rU   h	__class__s       r(   r)   Gist._update_attributesD  s    "4(.@DWNx3Nk*>B9oNo++A4oNk* ONs   B B)r   r   r   r   r   )rs   rt   ru   rv   rw   rx   ry   GistFiler    r)   r{   __classcell__)r   s   @r(   r   r     s%    $L J##K+ +r0   r   c                        \ rS rSrSrS r\rSrg)rT   iM  aZ  Short representation of a gist.

GitHub's API returns different amounts of information about gists
based upon how that information is retrieved. This object exists to
represent the full amount of information returned for a specific
gist. For example, you would receive this class when calling
:meth:`~github3.github.GitHub.all_gists`. To provide a clear distinction
between the types of gists, github3.py uses different classes with
different sets of attributes.

This object only has the following attributes:

.. attribute:: url

    The GitHub API URL for this repository, e.g.,
    ``https://api.github.com/gists/6faaaeb956dec3f51a9bd630a3490291``.

.. attribute:: comments_count

    Number of comments on this gist

.. attribute:: description

    Description of the gist as written by the creator

.. attribute:: html_url

    The URL of this gist on GitHub, e.g.,
    ``https://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291``

.. attribute:: id

    The unique identifier for this gist.

.. attribute:: public

    This is a boolean attribute  describing if the gist is public or
    private

.. attribute:: git_pull_url

    The git URL to pull this gist, e.g.,
    ``git://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git``

.. attribute:: git_push_url

    The git URL to push to gist, e.g.,
    ``git@gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git``

.. attribute:: created_at

    This is a datetime object representing when the gist was created.

.. attribute:: updated_at
    This is a datetime object representing the last time this gist was
    most recently updated.

.. attribute:: owner

    This attribute is a :class:`~github3.users.ShortUser` object
    representing the creator of the gist.

.. attribute:: files

    A dictionary mapping the filename to a
    :class:`~github3.gists.gist.GistFile` object.

    .. versionchanged:: 1.0.0

        Previously this was a list but it has been converted to a
        dictionary to preserve the structure of the API.

.. attribute:: comments_url

    The URL to retrieve the list of comments on the Gist via the API.
r|   N)	rs   rt   ru   rv   rw   rx   r   _refresh_tor{   r|   r0   r(   rT   rT   M  s    KZ JKr0   rT   N)rw   rB   r   rL   r   r   ry   r   r	   r
   
decoratorsr   
GitHubCorer   r~   r   rT   r|   r0   r(   <module>r      s`    E       &X:F X:v0v   0f0+5 0+fO Or0   