24
24
from .. import _load_handler_from_location
25
25
26
26
class GistClientMixin (GithubClientMixin ):
27
- """
28
- provider_label: str
29
- Text to to apply to the navbar icon linking to the provider
30
- provider_icon: str
31
- CSS classname to apply to the navbar icon linking to the provider
32
- executor_label: str, optional
33
- Text to apply to the navbar icon linking to the execution service
34
- executor_icon: str, optional
35
- CSS classname to apply to the navbar icon linking to the execution service
36
- """
27
+
28
+ # PROVIDER_CTX is a dictionary whose entries are passed as keyword arguments
29
+ # to the render_template method of the GistHandler. The following describe
30
+ # the information contained in each of these keyword arguments:
31
+ # provider_label: str
32
+ # Text to to apply to the navbar icon linking to the provider
33
+ # provider_icon: str
34
+ # CSS classname to apply to the navbar icon linking to the provider
35
+ # executor_label: str, optional
36
+ # Text to apply to the navbar icon linking to the execution service
37
+ # executor_icon: str, optional
38
+ # CSS classname to apply to the navbar icon linking to the execution service
37
39
PROVIDER_CTX = {
38
40
'provider_label' : 'Gist' ,
39
41
'provider_icon' : 'github-square' ,
@@ -63,7 +65,7 @@ def render_usergists_template(self, entries, user, provider_url, prev_url,
63
65
"""
64
66
provider_url: str
65
67
URL to the notebook document upstream at the provider (e.g., GitHub)
66
- executor_url: str, optional
68
+ executor_url: str, optional (kwarg passed into `namespace`)
67
69
URL to execute the notebook document (e.g., Binder)
68
70
"""
69
71
return self .render_template ("usergists.html" , entries = entries , user = user ,
@@ -139,10 +141,7 @@ def parse_gist(self, user, gist_id, filename=''):
139
141
@gen .coroutine
140
142
def tree_get (self , user , gist_id , gist , files ):
141
143
"""
142
- provider_url:
143
- URL to the notebook document upstream at the provider (e.g., GitHub)
144
- executor_url: str, optional
145
- URL to execute the notebook document (e.g., Binder)
144
+ user, gist_id, gist, and files are (most) of the values returned by parse_gist
146
145
"""
147
146
entries = []
148
147
ipynbs = []
@@ -175,6 +174,10 @@ def tree_get(self, user, gist_id, gist, files):
175
174
gist_id = gist_id
176
175
) if self .binder_base_url else None
177
176
177
+ # provider_url:
178
+ # URL to the notebook document upstream at the provider (e.g., GitHub)
179
+ # executor_url: str, optional
180
+ # URL to execute the notebook document (e.g., Binder)
178
181
html = self .render_template (
179
182
'treelist.html' ,
180
183
entries = entries ,
@@ -197,8 +200,12 @@ def file_get(self, user, gist_id, filename, gist, many_files_gist, file):
197
200
198
201
yield self .deliver_notebook (user , gist_id , filename , gist , file , content )
199
202
203
+ # Only called by file_get
200
204
@gen .coroutine
201
205
def get_notebook_data (self , gist_id , filename , many_files_gist , file ):
206
+ """
207
+ gist_id, filename, many_files_gist, file are all passed to file_get
208
+ """
202
209
if (file ['type' ] or '' ).startswith ('image/' ):
203
210
app_log .debug ("Fetching raw image (%s) %s/%s: %s" , file ['type' ], gist_id , filename , file ['raw_url' ])
204
211
response = yield self .fetch (file ['raw_url' ])
@@ -220,11 +227,13 @@ def get_notebook_data(self, gist_id, filename, many_files_gist, file):
220
227
else :
221
228
return content
222
229
230
+ # Only called by file_get
223
231
@gen .coroutine
224
232
def deliver_notebook (self , user , gist_id , filename , gist , file , content ):
225
233
"""
226
- provider_url: str, optional
227
- URL to the notebook document upstream at the provider (e.g., GitHub)
234
+ user, gist_id, filename, gist, file, are the same values as those
235
+ passed into file_get, whereas content is returned from
236
+ get_notebook_data using user, gist_id, filename, gist, and file.
228
237
"""
229
238
# Enable a binder navbar icon if a binder base URL is configured
230
239
executor_url = self .BINDER_PATH_TMPL .format (
@@ -234,6 +243,8 @@ def deliver_notebook(self, user, gist_id, filename, gist, file, content):
234
243
path = quote (filename )
235
244
) if self .binder_base_url else None
236
245
246
+ # provider_url: str, optional
247
+ # URL to the notebook document upstream at the provider (e.g., GitHub)
237
248
yield self .finish_notebook (
238
249
content ,
239
250
file ['raw_url' ],
@@ -246,7 +257,10 @@ def deliver_notebook(self, user, gist_id, filename, gist, file, content):
246
257
@cached
247
258
@gen .coroutine
248
259
def get (self , user , gist_id , filename = '' ):
249
-
260
+ """
261
+ Encompasses both the case of a single file gist, handled by
262
+ `file_get`, as well as a many-file gist, handled by `tree_get`.
263
+ """
250
264
user , gist_id , gist , files , many_files_gist = yield self .parse_gist (user , gist_id , filename )
251
265
252
266
if many_files_gist and not filename :
0 commit comments