Show More
@@ -43,7 +43,7 b' def respond_zip(handler, name, output, resources):' | |||
|
43 | 43 | # Prepare the zip file |
|
44 | 44 | buffer = io.BytesIO() |
|
45 | 45 | zipf = zipfile.ZipFile(buffer, mode='w', compression=zipfile.ZIP_DEFLATED) |
|
46 |
output_filename = os.path.splitext(name)[0] + |
|
|
46 | output_filename = os.path.splitext(name)[0] + resources['output_extension'] | |
|
47 | 47 | zipf.writestr(output_filename, cast_bytes(output, 'utf-8')) |
|
48 | 48 | for filename, data in output_files.items(): |
|
49 | 49 | zipf.writestr(os.path.basename(filename), data) |
@@ -96,7 +96,7 b' class NbconvertFileHandler(IPythonHandler):' | |||
|
96 | 96 | |
|
97 | 97 | # Force download if requested |
|
98 | 98 | if self.get_argument('download', 'false').lower() == 'true': |
|
99 |
filename = os.path.splitext(name)[0] + |
|
|
99 | filename = os.path.splitext(name)[0] + resources['output_extension'] | |
|
100 | 100 | self.set_header('Content-Disposition', |
|
101 | 101 | 'attachment; filename="%s"' % filename) |
|
102 | 102 |
@@ -359,7 +359,7 b' define([' | |||
|
359 | 359 | // Set menu entry text to e.g. "Python (.py)" |
|
360 | 360 | var langname = (langinfo.name || 'Script') |
|
361 | 361 | langname = langname.charAt(0).toUpperCase()+langname.substr(1) // Capitalise |
|
362 |
el.find('a').text(langname + ' ( |
|
|
362 | el.find('a').text(langname + ' ('+(langinfo.file_extension || 'txt')+')'); | |
|
363 | 363 | |
|
364 | 364 | // Unregister any previously registered handlers |
|
365 | 365 | el.off('click'); |
@@ -76,7 +76,7 b' class IPythonKernel(KernelBase):' | |||
|
76 | 76 | 'version': sys.version_info[0]}, |
|
77 | 77 | 'pygments_lexer': 'ipython%d' % (3 if PY3 else 2), |
|
78 | 78 | 'nbconvert_exporter': 'python', |
|
79 | 'file_extension': 'py' | |
|
79 | 'file_extension': '.py' | |
|
80 | 80 | } |
|
81 | 81 | @property |
|
82 | 82 | def banner(self): |
@@ -32,7 +32,7 b' class Exporter(LoggingConfigurable):' | |||
|
32 | 32 | """ |
|
33 | 33 | |
|
34 | 34 | file_extension = Unicode( |
|
35 | 'txt', config=True, | |
|
35 | '.txt', config=True, | |
|
36 | 36 | help="Extension of the file that should be written to disk" |
|
37 | 37 | ) |
|
38 | 38 |
@@ -32,7 +32,7 b' class HTMLExporter(TemplateExporter):' | |||
|
32 | 32 | """ |
|
33 | 33 | |
|
34 | 34 | def _file_extension_default(self): |
|
35 | return 'html' | |
|
35 | return '.html' | |
|
36 | 36 | |
|
37 | 37 | def _default_template_path_default(self): |
|
38 | 38 | return os.path.join("..", "templates", "html") |
@@ -135,7 +135,7 b' class PDFExporter(LatexExporter):' | |||
|
135 | 135 | |
|
136 | 136 | # convert output extension to pdf |
|
137 | 137 | # the writer above required it to be tex |
|
138 | resources['output_extension'] = 'pdf' | |
|
138 | resources['output_extension'] = '.pdf' | |
|
139 | 139 | |
|
140 | 140 | return pdf_data, resources |
|
141 | 141 |
@@ -23,7 +23,7 b' class PythonExporter(TemplateExporter):' | |||
|
23 | 23 | Exports a Python code file. |
|
24 | 24 | """ |
|
25 | 25 | def _file_extension_default(self): |
|
26 | return 'py' | |
|
26 | return '.py' | |
|
27 | 27 | |
|
28 | 28 | def _template_file_default(self): |
|
29 | 29 | return 'python' |
@@ -26,7 +26,7 b' class RSTExporter(TemplateExporter):' | |||
|
26 | 26 | """ |
|
27 | 27 | |
|
28 | 28 | def _file_extension_default(self): |
|
29 | return 'rst' | |
|
29 | return '.rst' | |
|
30 | 30 | |
|
31 | 31 | def _template_file_default(self): |
|
32 | 32 | return 'rst' |
@@ -8,7 +8,7 b' class ScriptExporter(TemplateExporter):' | |||
|
8 | 8 | |
|
9 | 9 | def from_notebook_node(self, nb, resources=None, **kw): |
|
10 | 10 | langinfo = nb.metadata.get('language_info', {}) |
|
11 | self.file_extension = langinfo.get('file_extension', 'txt') | |
|
11 | self.file_extension = langinfo.get('file_extension', '.txt') | |
|
12 | 12 | self.output_mimetype = langinfo.get('mimetype', 'text/plain') |
|
13 | 13 | |
|
14 | 14 | return super(ScriptExporter, self).from_notebook_node(nb, resources, **kw) |
@@ -286,7 +286,7 b' class NbConvertApp(BaseIPythonApplication):' | |||
|
286 | 286 | # strip duplicate extension from output_base, to avoid Basname.ext.ext |
|
287 | 287 | if getattr(exporter, 'file_extension', False): |
|
288 | 288 | base, ext = os.path.splitext(self.output_base) |
|
289 |
if ext == |
|
|
289 | if ext == exporter.file_extension: | |
|
290 | 290 | self.output_base = base |
|
291 | 291 | notebook_name = self.output_base |
|
292 | 292 | resources = {} |
@@ -93,7 +93,7 b' class FilesWriter(WriterBase):' | |||
|
93 | 93 | |
|
94 | 94 | # Determine where to write conversion results. |
|
95 | 95 | if output_extension is not None: |
|
96 |
dest = notebook_name + |
|
|
96 | dest = notebook_name + output_extension | |
|
97 | 97 | else: |
|
98 | 98 | dest = notebook_name |
|
99 | 99 | if self.build_directory: |
General Comments 0
You need to be logged in to leave comments.
Login now