8000 Merge pull request #511 from sigmavirus24/pr/486 · pljensen/github3.py@ba79cb8 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba79cb8

Browse files
committed
Merge pull request sigmavirus24#511 from sigmavirus24/pr/486
Add method to retrieve GistFile content
2 parents 3c026c7 + 36c2d23 commit ba79cb8

File tree

5 files changed

+95
-4
lines changed

5 files changed

+95
-4
lines changed

github3/gists/file.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"""
88
from __future__ import unicode_literals
99

10-
from ..models import GitHubObject
10+
from ..models import GitHubCore
1111

1212

13-
class GistFile(GitHubObject):
13+
class GistFile(GitHubCore):
1414

1515
"""This represents the file object returned by interacting with gists.
1616
@@ -31,7 +31,16 @@ def _update_attributes(self, attributes):
3131
#: The size of the file.
3232
self.size = attributes.get('size')
3333
#: The content of the file.
34-
self.content = attributes.get('content')
34+
self.original_content = attributes.get('content')
3535

3636
def _repr(self):
3737
return '<Gist File [{0}]>'.format(self.name)
38+
39+
def content(self):
40+
"""Retrieve contents of file from key 'raw_url' if there is no
41+
'content' key in Gist object.
42+
"""
43+
resp = self._get(self.raw_url)
44+
if self._boolean(resp, 200, 404):
45+
return resp.content
46+
return None

0 commit comments

Comments
 (0)
0