@@ -46,15 +46,46 @@ def _update_attributes(self, release):
46
46
self .published_at = self ._strptime (release .get ('published_at' ))
47
47
#: Name of the tag
48
48
self .tag_name = release .get ('tag_name' )
49
+ #: URL to download a tarball of the release
50
+ self .tarball_url = release .get ('tarball_url' )
49
51
#: "Commit" that this release targets
50
52
self .target_commitish = release .get ('target_commitish' )
51
53
upload_url = release .get ('upload_url' )
52
54
#: URITemplate to upload an asset with
53
55
self .upload_urlt = URITemplate (upload_url ) if upload_url else None
56
+ #: URL to download a zipball of the release
57
+ self .zipball_url = release .get ('zipball_url' )
54
58
55
59
def _repr (self ):
56
60
return '<Release [{0}]>' .format (self .name )
57
61
62
+ def archive (self , format , path = '' ):
63
+ """Get the tarball or zipball archive for this release.
64
+
65
+ :param str format: (required), accepted values: ('tarball',
66
+ 'zipball')
67
+ :param path: (optional), path where the file should be saved
68
BD7E
td>+ to, default is the filename provided in the headers and will be
69
+ written in the current directory.
70
+ it can take a file-like object as well
71
+ :type path: str, file
72
+ :returns: bool -- True if successful, False otherwise
73
+
74
+ """
75
+ resp = None
76
+ if format == 'tarball' :
77
+ resp = self ._get (self .tarball_url , allow_redirects = True ,
78
+ stream = True )
79
+
80
+ elif format == 'zipball' :
81
+ resp = self ._get (self .zipball_url , allow_redirects = True ,
82
+ stream = True )
83
+
84
+ if resp and self ._boolean (resp , 200 , 404 ):
85
+ utils .stream_response_to_file (resp , path )
86
+ return True
87
+ return False
88
+
58
89
def asset (self , asset_id ):
59
90
"""Retrieve the asset from this release with ``asset_id``.
60
91
0 commit comments