Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47cba93

Browse files
committed
Add Release.assets attribute
The JSON describing a release includes complete information on itsassets. Add Release.assets attribute with a list of Assets. This ischeaper for the application than making a separate request viaRelease.iter_assets().Leave Release.iter_assets() in place, in case someone has a use for it,but mention Release.assets in its documentation.
1 parent480349c commit47cba93

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

‎github3/repos/release.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Release(GitHubCore):
2222
def__init__(self,release,session=None):
2323
super(Release,self).__init__(release,session)
2424
self._api=release.get('url')
25+
#: List of :class:`Asset <Asset>` objects for this release
26+
self.assets= [Asset(i,self)foriinrelease.get('assets', [])]
2527
#: URL for uploaded assets
2628
self.assets_url=release.get('assets_url')
2729
#: Body of the release (the description)
@@ -104,7 +106,9 @@ def edit(self, tag_name=None, target_commitish=None, name=None, body=None,
104106
returnsuccessful
105107

106108
defiter_assets(self,number=-1,etag=None):
107-
"""Iterate over the assets available for this release.
109+
"""Iterate over the assets available for this release. The same
110+
information is available, without an additional network access,
111+
from the :attr:`assets` attribute.
108112
109113
:param int number: (optional), Number of assets to return
110114
:param str etag: (optional), last ETag header sent

‎tests/unit/test_repos_release.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ class TestRelease(UnitHelper):
1515
example_data= {
1616
"url":releases_url("/1"),
1717
"html_url":"https://github.com/octocat/Hello-World/releases/v1.0.0",
18+
"assets": [{
19+
"url":releases_url("/assets/1"),
20+
"id":1,
21+
"name":"example.zip",
22+
"label":"short description",
23+
"state":"uploaded",
24+
"content_type":"application/zip",
25+
"size":1024,
26+
"download_count":42,
27+
"created_at":"2013-02-27T19:35:32Z",
28+
"updated_at":"2013-02-27T19:35:32Z"
29+
}],
1830
"assets_url":releases_url("/1/assets"),
1931
"upload_url":releases_url("/1/assets{?name}"),
2032
"id":1,
@@ -29,6 +41,10 @@ class TestRelease(UnitHelper):
2941
}
3042

3143
# Attribute tests
44+
deftest_assets(self):
45+
assertself.instance.assetsisnotNone
46+
assertisinstance(self.instance.assets[0],Asset)
47+
3248
deftest_has_upload_urlt(self):
3349
assertself.instance.upload_urltisnotNone
3450

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp