15
15
16
16
17
17
class Gist (GitHubCore ):
18
- """The :class:`Gist <Gist>` object. This object holds all the information
19
- returned by Github about a gist. With it you can comment on or fork the
20
- gist (assuming you are authenticated), edit or delete the gist (assuming
21
- you own it). You can also "star" or "unstar" the gist (again assuming you
22
- have authenticated).
18
+
19
+ """This object holds all the information returned by Github about a gist.
20
+
21
+ With it you can comment on or fork the gist (assuming you are
22
+ authenticated), edit or delete the gist (assuming you own it). You can
23
+ also "star" or "unstar" the gist (again assuming you have authenticated).
23
24
24
25
Two gist instances can be checked like so::
25
26
@@ -32,7 +33,9 @@ class Gist(GitHubCore):
32
33
g1.id != g2.id
33
34
34
35
See also: http://developer.github.com/v3/gists/
36
+
35
37
"""
38
+
36
39
def __init__ (self , data , session = None ):
37
40
super (Gist , self ).__init__ (data , session )
38
41
#: Number of comments on this gist
@@ -102,6 +105,7 @@ def create_comment(self, body):
102
105
103
106
:param str body: (required), body of the comment
104
107
:returns: :class:`GistComment <github3.gists.comment.GistComment>`
108
+
105
109
"""
106
110
json = None
107
111
if body :
@@ -113,7 +117,9 @@ def create_comment(self, body):
113
117
def delete (self ):
114
118
"""Delete this gist.
115
119
116
- :returns: bool -- whether the deletion was successful"""
120
+ :returns: bool -- whether the deletion was successful
121
+
122
+ """
117
123
return self ._boolean (self ._delete (self ._api ), 204 , 404 )
118
124
119
125
@requires_auth
@@ -127,6 +133,7 @@ def edit(self, description='', files={}):
127
133
'filename' where the former is the content of the file and the
128
134
latter is the new name of the file.
129
135
:returns: bool -- whether the edit was successful
136
+
130
137
"""
131
138
data = {}
132
139
json = None
@@ -146,23 +153,26 @@ def fork(self):
146
153
"""Fork this gist.
147
154
148
155
:returns: :class:`Gist <Gist>` if successful, ``None`` otherwise
156
+
149
157
"""
150
158
url = self ._build_url ('forks' , base_url = self ._api )
151
159
json = self ._json (self ._post (url ), 201 )
152
160
return Gist (json , self ) if json else None
153
161
154
162
def is_public (self ):
155
- """Checks to see if this gist is public or not.
163
+ """Check to see if this gist is public or not.
156
164
157
165
:returns: bool -- True if public, False if private
166
+
158
167
"""
159
168
return self .public
160
169
161
170
@requires_auth
162
171
def is_starred (self ):
163
- """Checks to see if this gist is starred by the authenticated user.
172
+ """Check to see if this gist is starred by the authenticated user.
164
173
165
174
:returns: bool -- True if it is starred, False otherwise
175
+
166
176
"""
167
177
url = self ._build_url ('star' , base_url = self ._api )
168
178
return self ._boolean (self ._get (url ), 204 , 404 )
@@ -175,7 +185,8 @@ def iter_comments(self, number=-1, etag=None):
175
185
:param str etag: (optional), ETag from a previous request to the same
176
186
endpoint
177
187
:returns: generator of
178
- :class:`GistComment <github3.gists.comment.GistComment>`\ s
188
+ :class:`GistComment <github3.gists.comment.GistComment>`
189
+
179
190
"""
180
191
url = self ._build_url ('comments' , base_url = self ._api )
181
192
return self ._iter (int (number ), url , GistComment , etag = etag )
@@ -192,25 +203,34 @@ def iter_commits(self, number=-1):
192
203
Default: -1 will iterate over all commits associated with this
193
204
gist.
194
205
:returns: generator of
195
- :class: `GistHistory <github3.gists.history.GistHistory>`\ s
206
+ :class:`GistHistory <github3.gists.history.GistHistory>`
207
+
196
208
"""
197
209
url = self ._build_url ('commits' , base_url = self ._api )
198
210
return self ._iter (int (number ), url , GistHistory )
199
211
200
212
def iter_files (self ):
201
- """List of :class:`GistFile <GistFile>` objects representing the files
202
- stored in this gist."""
213
+ """Iterator over the files stored in this gist.
214
+
215
+ :returns: generator of :class`GistFile <github3.gists.file.GistFile>`
216
+
217
+ """
203
218
return iter (self ._files )
204
219
205
220
def iter_forks (self ):
206
- """List of :class:`Gist <Gist>`\ s representing forks of this gist."""
221
+ """Iterator of forks of this gist.
222
+
223
+ :returns: generator of :class:`Gist <Gist>`
224
+
225
+ """
207
226
return iter (self ._forks ) # (No coverage)
208
227
209
228
@requires_auth
210
229
def star (self ):
211
230
"""Star this gist.
212
231
213
232
:returns: bool -- True if successful, False otherwise
233
+
214
234
"""
215
235
url = self ._build_url ('star' , base_url = self ._api )
216
236
return self ._boolean (self ._put (url ), 204 , 404 )
@@ -220,6 +240,7 @@ def unstar(self):
220
240
"""Un-star this gist.
221
241
222
242
:returns: bool -- True if successful, False otherwise
243
+
223
244
"""
224
245
url = self ._build_url ('star' , base_url = self ._api )
225
246
return self ._boolean (self ._delete (url ), 204 , 404 )
0 commit comments