
    _Og5                         S r SSK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g)z!Release logic for the GitHub API.    N)URITemplate   )models)users)utils)requires_auth)	error_forc                       \ rS rSrSrS rS rSS jrS rSS jr	\
S	 5       r\
      SS
 j5       r\
SS j5       rSrg)Release   a  Representation of a GitHub release.

It holds the information GitHub returns about a release from a
:class:`Repository <github3.repos.repo.Repository>`.

Please see GitHub's `Releases Documentation`_ for more information.

This object has the following attributes:

.. attribute:: original_assets

    A list of :class:`~github3.repos.release.Asset` objects representing
    the assets uploaded for this relesae.

.. attribute:: assets_url

    The URL to retrieve the assets from the API.

.. attribute:: author

    A :class:`~github3.users.ShortUser` representing the creator of this
    release.

.. attribute:: body

    The description of this release as written by the release creator.

.. attribute:: created_at

    A :class:`~datetime.datetime` object representing the date and time
    when this release was created.

.. attribute:: draft

    A boolean attribute describing whether this release is a draft.

.. attribute:: html_url

    The URL to view this release in a browser.

.. attribute:: id

    The unique identifier of this release.

.. attribute:: name

    The name given to this release by the :attr:`author`.

.. attribute:: prerelease

    A boolean attribute indicating whether the release is a pre-release.

.. attribute:: published_at

    A :class:`~datetime.datetime` object representing the date and time
    when this release was publisehd.

.. attribute:: tag_name

    The name of the tag associated with this release.

.. attribute:: tarball_url

    The URL to retrieve a GitHub generated tarball for this release from
    the API.

.. attribute:: target_commitish

    The reference (usually a commit) that is targetted by this release.

.. attribute:: upload_urlt

    A :class:`~uritemplate.URITemplate` object that expands to form the
    URL to upload assets to.

.. attribute:: zipball_url

    The URL to retrieve a GitHub generated zipball for this release from
    the API.

.. _Releases Documentation:
    https://developer.github.com/v3/repos/releases/
c                    US   =U l         U l        US    Vs/ s H  n[        X 5      PM     snU l        US   U l        [
        R                  " US   U 5      U l        US   U l        U R                  US   5      U l
        US   U l        US   U l        US	   U l        US
   U l        US   U l        U R                  US   5      U l        US   U l        US   U l        US   U l        [)        US   5      U l        US   U l        g s  snf )Nurlassets
assets_urlauthorbody
created_atdrafthtml_urlidname
prereleasepublished_attag_nametarball_urltarget_commitish
upload_urlzipball_url)_apir   Assetoriginal_assetsr   r   	ShortUserr   r   	_strptimer   r   r   r   r   r   r   r   r   r   r   upload_urltr   )selfreleaseis      Z/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/github3/repos/release.py_update_attributesRelease._update_attributesb   s   &u~-	DH8?8IJ8I1a8IJ!,/oogh&7>FO	..)>?W%

+$-FO	!,/ NN7>+BC
+"=1 '(: ;&w|'<="=1  Ks   D	c                 "    SU R                    S3$ )Nz
<Release []>r   r%   s    r(   _reprRelease._repru   s    DII;b))    c                 &   SnUS;   aS  U R                   SU R                   R                  S5       nU R                  XR                  US9nU R	                  USSS9nU(       a/  U R                  USS5      (       a  [        R                  " X25        gg	)
a  Get the tarball or zipball archive for this release.

:param str format:
    (required), accepted values: ('tarball', 'zipball')
:param path:
    (optional), path where the file should be saved to, default is the
    filename provided in the headers and will be written in the current
    directory. It can take a file-like object as well
:type path:
    str, file
:returns:
    True if successful, False otherwise
:rtype:
    bool
N)tarballzipballz	/releasesbase_urlT)allow_redirectsstream     F)r   rfind
_build_urlr   _get_booleanr   stream_response_to_file)r%   formatpathresprepo_urlr   s         r(   archiveRelease.archivex   s      ++yy!?499??;#?@H//&--(/KC99S$t9DDDMM$S11))$5r1   c                    Sn[        U5      S:  ac  U R                  R                  S5      nU R                  S[	        U5      U R                  SU S9nU R                  U R                  U5      S5      nU R                  [        U5      $ )zRetrieve the asset from this release with ``asset_id``.

:param int asset_id:
    ID of the Asset to retrieve
:returns:
    the specified asset, if it exists
:rtype:
    :class:`~github3.repos.release.Asset`
Nr   /r   r5   r9   )	intr   r;   r<   str_jsonr=   _instance_or_nullr    )r%   asset_idjsonr'   r   s        r(   assetRelease.asset   s|     x=1		$A//#h-$))BQ- " C ::diinc2D%%eT22r1   Nc                 `    U R                  SU R                  S9nU R                  X[        US9$ )a  Iterate over the assets available for this release.

:param int number:
    (optional), Number of assets to return
:param str etag:
    (optional), last ETag header sent
:returns:
    generator of asset objects
:rtype:
    :class:`~github3.repos.release.Asset`
r   r5   )etag)r<   r   _iterr    )r%   numberrQ   r   s       r(   r   Release.assets   s/     ooho;zz&u4z88r1   c                 ^    U R                   nU R                  U R                  U5      SS5      $ )zDelete this release.

Only users with push access to the repository can delete a release.

:returns:
    True if successful; False if not successful
:rtype:
    bool
   r:   r   r>   _deleter%   r   s     r(   deleteRelease.delete   s)     ii}}T\\#.S99r1   c                     U R                   nUUUUUUS.nU R                  U5        U R                  R                  U[        R
                  " U5      S9n	U R                  U	SS5      n
U
(       a  U R                  U	R	                  5       5        U
$ )a  Edit this release.

Only users with push access to the repository can edit a release.

If the edit is successful, this object will update itself.

:param str tag_name:
    (optional), Name of the tag to use
:param str target_commitish:
    (optional), The "commitish" value that determines where the Git tag
    is created from. Defaults to the repository's default branch.
:param str name:
    (optional), Name of the release
:param str body:
    (optional), Description of the release
:param boolean draft:
    (optional), True => Release is a draft
:param boolean prerelease:
    (optional), True => Release is a prerelease
:returns:
    True if successful; False if not successful
:rtype:
    bool
)r   r   r   r   r   r   datar9   r:   )r   _remove_nonesessionpatchrM   dumpsr>   r)   )r%   r   r   r   r   r   r   r   r^   r
successfuls              r(   editRelease.edit   s    D ii  0$
 	$LLsD)9:]]1c3/
##AFFH-r1   c                     SU0nX$S.nU R                  U5        U R                  R                  U5      nU R                  XsSUS9nUR                  S;   a  [        UR                  5       U 5      $ [        U5      e)a  Upload an asset to this release.

.. note:: All parameters are required.

:param str content_type:
    The content type of the asset. Wikipedia has a list of common media
    types
:param str name:
    The name of the file
:param asset:
    The file or bytes object to upload.
:param label:
    (optional), An alternate short description of the asset.
:returns:
    the created asset
:rtype:
    :class:`~github3.repos.release.Asset`
Content-Typer   labelF)r^   rM   headers)      )r_   r$   expand_poststatus_coder    rM   r	   )	r%   content_typer   rN   rj   rk   paramsr   rc   s	            r(   upload_assetRelease.upload_asset   sw    ( "<0/&!%%f-JJsUGJD==J&4((lr1   )r   r   r   r   r   r   r   r   r   r!   r   r   r   r   r   r$   r   r    )N)NNNNNNN)__name__
__module____qualname____firstlineno____doc__r)   r/   rD   rN   r   r   rZ   re   rs   __static_attributes__ r1   r(   r   r      ss    Rh2&*63&9 : :  3 3j  r1   r   c                   H    \ rS rSrSrS rS rS
S jr\S 5       r	SS jr
S	rg)r    i  a  Representation of an asset in a release.

.. seealso::

    `List Assets`_, :meth:`~github3.repos.release.Release.assets`
        Documentation around listing assets of a release
    `Upload Assets`_, :meth:`~github3.repos.release.Release.upload_asset`
        Documentation around uploading assets to a release
    `Get a Single Asset`_, :meth:`~github3.repos.release.Release.asset`
        Documentation around retrieving an asset
    `Edit an Asset`_, :meth:`~github3.repos.release.Asset.edit`
        Documentation around editing an asset
    `Delete an Asset`_, :meth:`~github3.repos.release.Asset.delete`
        Documentation around deleting an asset

This object has the following attributes:

.. attribute:: browser_download_url

    The user-friendly URL to download this asset via a browser.

.. attribute:: content_type

    The Content-Type provided by the uploader when this asset was created.

.. attribute:: created_at

    A :class:`~datetime.datetime` object representing the date and time
    when this asset was created.

.. attribute:: download_count

    The number of times this asset has been downloaded.

.. attribute:: download_url

    The URL to retrieve this uploaded asset via the API, e.g., tarball,
    zipball, etc.

.. attribute:: id

    The unique identifier of this asset.

.. attribute:: label

    The short description of this asset.

.. attribute:: name

    The name provided to this asset.

.. attribute:: size

    The file size of this asset.

.. attribute:: state

    The state of this asset, e.g., ``'uploaded'``.

.. attribute:: updated_at

    A :class:`~datetime.datetime` object representing the date and time
    when this asset was most recently updated.

.. _List Assets:
    https://developer.github.com/v3/repos/releases/#list-assets-for-a-release
.. _Upload Assets:
    https://developer.github.com/v3/repos/releases/#upload-a-release-asset
.. _Get a Single Asset:
    https://developer.github.com/v3/repos/releases/#get-a-single-release-asset
.. _Edit an Asset:
    https://developer.github.com/v3/repos/releases/#edit-a-release-asset
.. _Delete an Asset:
    https://developer.github.com/v3/repos/releases/#delete-a-release-asset
c                 >   US   U l         US   U l        US   U l        U R                  US   5      U l        US   U l        U R                   U l        US   U l        US   U l        US   U l	        US	   U l
        US
   U l        U R                  US   5      U l        g )Nr   browser_download_urlrq   r   download_countr   rj   r   sizestate
updated_at)r   r   rq   r#   r   r   download_urlr   rj   r   r   r   r   )r%   rN   s     r(   r)   Asset._update_attributesd  s    %L	$)*@$A!!.1..|)<=#$45 II+7^
&M	&M	7^
..|)<=r1   c                 "    SU R                    S3$ )Nz<Asset [r,   r-   r.   s    r(   r/   Asset._reprr  s    $))B''r1   c                    SS0nU R                  U R                  SSUS9nUR                  S:X  aT  UR                  SS05        U R                  R                  5          U R                  UR                  S	   SUS
9nSSS5        U R                  USS5      (       a  [        R                  " X15      $ g! , (       d  f       N== f)a`  Download the data for this asset.

:param path:
    (optional), path where the file should be saved to, default is the
    filename provided in the headers and will be written in the current
    directory. It can take a file-like object as well
:type path:
    str, file
:returns:
    name of the file, if successful otherwise ``None``
:rtype:
    str
Acceptzapplication/octet-streamFT)r7   r8   rk   i.  rh   Nlocation)r8   rk   r9   r:   )
r=   r   rp   updater`   no_authrk   r>   r   r?   )r%   rA   rk   rB   s       r(   downloadAsset.downloadu  s     78yyIIuT7  
 s" NNND12%%'yyLL,T7 !  (
 ==sC((00<< ('s   B44
Cc                 ^    U R                   nU R                  U R                  U5      SS5      $ )z{Delete this asset if the user has push access.

:returns:
    True if successful; False if not successful
:rtype:
    bool
rV   r:   rW   rY   s     r(   rZ   Asset.delete  s)     ii}}T\\#.S99r1   Nc                    U(       d  gXS.nU R                  U5        U R                  U R                  [        R                  " U5      S9nU R                  USS5      nU(       a  U R                  UR                  5       5        U$ )zEdit this asset.

:param str name:
    (required), The file name of the asset
:param str label:
    (optional), An alternate description of the asset
:returns:
    True if successful, False otherwise
:rtype:
    bool
Fri   r]   r9   r:   )r_   _patchr   rM   rb   r>   r)   )r%   r   rj   	edit_datarc   rd   s         r(   re   
Asset.edit  sn     !2	)$KK		

9(=K>]]1c3/
##AFFH-r1   )r   r   rq   r   r   r   r   rj   r   r   r   r   ru   rx   )ry   rz   r{   r|   r}   r)   r/   r   r   rZ   re   r~   r   r1   r(   r    r      s2    JX>(@ 	: 	:r1   r    )r}   rM   uritemplater   rv   r   r   r   
decoratorsr   
exceptionsr	   
GitHubCorer   r    r   r1   r(   <module>r      sF    '  #    & "Gf GT_F _r1   