Show More
@@ -138,12 +138,16 b' class NbConvertApp(BaseIPythonApplication):' | |||
|
138 | 138 | """ |
|
139 | 139 | Entrypoint of NbConvert application. |
|
140 | 140 | """ |
|
141 | ||
|
142 | #Call base | |
|
143 | 141 | super(NbConvertApp, self).start() |
|
142 | self.convert_notebooks() | |
|
143 | ||
|
144 | 144 | |
|
145 | def convert_notebooks(self): | |
|
146 | """ | |
|
147 | Convert the notebooks in the self.notebook traitlet | |
|
148 | """ | |
|
145 | 149 | #Export each notebook |
|
146 | #TODO: Empty check | |
|
150 | conversion_success = 0 | |
|
147 | 151 | for notebook_filename in self.notebooks: |
|
148 | 152 | |
|
149 | 153 | #Get a unique key for the notebook and set it in the resources object. |
@@ -165,12 +169,24 b' class NbConvertApp(BaseIPythonApplication):' | |||
|
165 | 169 | "\n\t" + "\n\t".join(get_export_names()), |
|
166 | 170 | file=sys.stderr) |
|
167 | 171 | sys.exit(-1) |
|
168 | except Exception as e: | |
|
169 | print("Error: could no export '%s'" % notebook_filename, file=sys.stderr) | |
|
170 | print(e, file=sys.stderr) | |
|
171 | ||
|
172 | #Write | |
|
173 | self.writer.write(output, resources, notebook_name=notebook_name) | |
|
172 | #except Exception as e: | |
|
173 | #print("Error: could not export '%s'" % notebook_filename, file=sys.stderr) | |
|
174 | #print(e, file=sys.stderr) | |
|
175 | else: | |
|
176 | self.writer.write(output, resources, notebook_name=notebook_name) | |
|
177 | conversion_success += 1 | |
|
178 | ||
|
179 | #If nothing was converted successfully, help the user. | |
|
180 | if conversion_success == 0: | |
|
181 | ||
|
182 | #No notebooks were specified, show help. | |
|
183 | if len(self.notebooks) == 0: | |
|
184 | self.print_help() | |
|
185 | ||
|
186 | #Notebooks were specified, but not converted successfully. Show how | |
|
187 | #to access help. | |
|
188 | else: | |
|
189 | print('For help, use "ipython nbconvert --help"') | |
|
174 | 190 | |
|
175 | 191 | |
|
176 | 192 | #----------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now