mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Add download_url to ContentFile, closes #575
This commit is contained in:
@@ -66,6 +66,14 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
content = self.content
|
||||
return base64.b64decode(content)
|
||||
|
||||
@property
|
||||
def download_url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
self._completeIfNotSet(self._download_url)
|
||||
return self._download_url.value
|
||||
|
||||
@property
|
||||
def encoding(self):
|
||||
"""
|
||||
@@ -160,6 +168,7 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
def _initAttributes(self):
|
||||
self._content = github.GithubObject.NotSet
|
||||
self._encoding = github.GithubObject.NotSet
|
||||
self._download_url = github.GithubObject.NotSet
|
||||
self._git_url = github.GithubObject.NotSet
|
||||
self._html_url = github.GithubObject.NotSet
|
||||
self._license = github.GithubObject.NotSet
|
||||
@@ -173,6 +182,8 @@ class ContentFile(github.GithubObject.CompletableGithubObject):
|
||||
def _useAttributes(self, attributes):
|
||||
if "content" in attributes: # pragma no branch
|
||||
self._content = self._makeStringAttribute(attributes["content"])
|
||||
if "download_url" in attributes: # pragma no branch
|
||||
self._download_url = self._makeStringAttribute(attributes["download_url"])
|
||||
if "encoding" in attributes: # pragma no branch
|
||||
self._encoding = self._makeStringAttribute(attributes["encoding"])
|
||||
if "git_url" in attributes: # pragma no branch
|
||||
|
||||
@@ -49,6 +49,7 @@ class ContentFile(Framework.TestCase):
|
||||
self.assertEqual(len(self.file.content), 10212)
|
||||
self.assertEqual(len(self.file.decoded_content), 7531)
|
||||
self.assertEqual(self.file.sha, "5628799a7d517a4aaa0c1a7004d07569cd154df0")
|
||||
self.assertEqual(self.file.download_url, "https://raw.githubusercontent.com/jacquev6/PyGithub/master/README.md")
|
||||
|
||||
# test __repr__() based on this attributes
|
||||
self.assertEqual(self.file.__repr__(), 'ContentFile(path="ReadMe.md")')
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user