@@ -72,23 +72,23 @@ def get(self):
7272 filename , filename_no_ext = get_notebook_filename (nb_path )
7373
7474 # Extract file contents given the path to the notebook
75- notebook_output , python_output = get_notebook_contents (nb_path )
75+ notebook_output , script_output , ext = get_notebook_contents (nb_path )
7676
7777 # Prepare and our github request to create the new gist
78- filename_with_py = filename_no_ext + ".py"
78+ filename_with_ext = filename_no_ext + ext
7979 gist_contents = {
8080 "description" : filename_no_ext ,
8181 "public" : False ,
8282 "files" : {
8383 filename : {"filename" : filename , "content" : notebook_output },
84- filename_with_py : {"filename" : filename_with_py ,
85- "content" : python_output }
84+ filename_with_ext : {"filename" : filename_with_ext ,
85+ "content" : script_output }
8686 }
8787 }
8888
8989 # Get the authenticated user's matching gist (if available)
9090 match_id = find_existing_gist_by_name (filename ,
91- filename_with_py ,
91+ filename_with_ext ,
9292 access_token )
9393
9494 # If no gist with this name exists yet, create a new gist
@@ -257,11 +257,12 @@ def get_notebook_contents(nb_path):
257257 # Extract file contents given the path to the notebook
258258 try :
259259 notebook_output , _ = export_by_name ("notebook" , nb_path )
260- python_output , _ = export_by_name ("python" , nb_path )
260+ script_output , script_resources = export_by_name ("script" , nb_path )
261+
261262 except OSError : # python 2 does not support FileNotFoundError
262263 raise_error ("Couldn't export notebook contents" )
263264
264- return (notebook_output , python_output )
265+ return (notebook_output , script_output , script_resources [ 'output_extension' ] )
265266
266267
267268def find_existing_gist_by_name (nb_filename , py_filename , access_token ):
0 commit comments