diff --git a/IPython/html/nbconvert/handlers.py b/IPython/html/nbconvert/handlers.py index 749cd9d..63ba266 100644 --- a/IPython/html/nbconvert/handlers.py +++ b/IPython/html/nbconvert/handlers.py @@ -43,7 +43,7 @@ def respond_zip(handler, name, output, resources): # Prepare the zip file buffer = io.BytesIO() zipf = zipfile.ZipFile(buffer, mode='w', compression=zipfile.ZIP_DEFLATED) - output_filename = os.path.splitext(name)[0] + '.' + resources['output_extension'] + output_filename = os.path.splitext(name)[0] + resources['output_extension'] zipf.writestr(output_filename, cast_bytes(output, 'utf-8')) for filename, data in output_files.items(): zipf.writestr(os.path.basename(filename), data) @@ -96,7 +96,7 @@ class NbconvertFileHandler(IPythonHandler): # Force download if requested if self.get_argument('download', 'false').lower() == 'true': - filename = os.path.splitext(name)[0] + '.' + resources['output_extension'] + filename = os.path.splitext(name)[0] + resources['output_extension'] self.set_header('Content-Disposition', 'attachment; filename="%s"' % filename) diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js index 8350fc2..9a2814b 100644 --- a/IPython/html/static/notebook/js/menubar.js +++ b/IPython/html/static/notebook/js/menubar.js @@ -359,7 +359,7 @@ define([ // Set menu entry text to e.g. "Python (.py)" var langname = (langinfo.name || 'Script') langname = langname.charAt(0).toUpperCase()+langname.substr(1) // Capitalise - el.find('a').text(langname + ' (.'+(langinfo.file_extension || 'txt')+')'); + el.find('a').text(langname + ' ('+(langinfo.file_extension || 'txt')+')'); // Unregister any previously registered handlers el.off('click'); diff --git a/IPython/kernel/zmq/ipkernel.py b/IPython/kernel/zmq/ipkernel.py index 1ef8975..5cc0a01 100644 --- a/IPython/kernel/zmq/ipkernel.py +++ b/IPython/kernel/zmq/ipkernel.py @@ -76,7 +76,7 @@ class IPythonKernel(KernelBase): 'version': sys.version_info[0]}, 'pygments_lexer': 'ipython%d' % (3 if PY3 else 2), 'nbconvert_exporter': 'python', - 'file_extension': 'py' + 'file_extension': '.py' } @property def banner(self): diff --git a/IPython/nbconvert/exporters/exporter.py b/IPython/nbconvert/exporters/exporter.py index a6c00fd..33991db 100644 --- a/IPython/nbconvert/exporters/exporter.py +++ b/IPython/nbconvert/exporters/exporter.py @@ -32,7 +32,7 @@ class Exporter(LoggingConfigurable): """ file_extension = Unicode( - 'txt', config=True, + '.txt', config=True, help="Extension of the file that should be written to disk" ) diff --git a/IPython/nbconvert/exporters/html.py b/IPython/nbconvert/exporters/html.py index 3df3810..d833691 100644 --- a/IPython/nbconvert/exporters/html.py +++ b/IPython/nbconvert/exporters/html.py @@ -32,7 +32,7 @@ class HTMLExporter(TemplateExporter): """ def _file_extension_default(self): - return 'html' + return '.html' def _default_template_path_default(self): return os.path.join("..", "templates", "html") diff --git a/IPython/nbconvert/exporters/pdf.py b/IPython/nbconvert/exporters/pdf.py index 0ef2b2d..d79610b 100644 --- a/IPython/nbconvert/exporters/pdf.py +++ b/IPython/nbconvert/exporters/pdf.py @@ -135,7 +135,7 @@ class PDFExporter(LatexExporter): # convert output extension to pdf # the writer above required it to be tex - resources['output_extension'] = 'pdf' + resources['output_extension'] = '.pdf' return pdf_data, resources diff --git a/IPython/nbconvert/exporters/python.py b/IPython/nbconvert/exporters/python.py index 5c7dbf4..e1218da 100644 --- a/IPython/nbconvert/exporters/python.py +++ b/IPython/nbconvert/exporters/python.py @@ -23,7 +23,7 @@ class PythonExporter(TemplateExporter): Exports a Python code file. """ def _file_extension_default(self): - return 'py' + return '.py' def _template_file_default(self): return 'python' diff --git a/IPython/nbconvert/exporters/rst.py b/IPython/nbconvert/exporters/rst.py index eaae267..731e978 100644 --- a/IPython/nbconvert/exporters/rst.py +++ b/IPython/nbconvert/exporters/rst.py @@ -26,7 +26,7 @@ class RSTExporter(TemplateExporter): """ def _file_extension_default(self): - return 'rst' + return '.rst' def _template_file_default(self): return 'rst' diff --git a/IPython/nbconvert/exporters/script.py b/IPython/nbconvert/exporters/script.py index d89eb80..2e1148a 100644 --- a/IPython/nbconvert/exporters/script.py +++ b/IPython/nbconvert/exporters/script.py @@ -8,7 +8,7 @@ class ScriptExporter(TemplateExporter): def from_notebook_node(self, nb, resources=None, **kw): langinfo = nb.metadata.get('language_info', {}) - self.file_extension = langinfo.get('file_extension', 'txt') + self.file_extension = langinfo.get('file_extension', '.txt') self.output_mimetype = langinfo.get('mimetype', 'text/plain') return super(ScriptExporter, self).from_notebook_node(nb, resources, **kw) diff --git a/IPython/nbconvert/nbconvertapp.py b/IPython/nbconvert/nbconvertapp.py index 1e252d0..115b645 100755 --- a/IPython/nbconvert/nbconvertapp.py +++ b/IPython/nbconvert/nbconvertapp.py @@ -286,7 +286,7 @@ class NbConvertApp(BaseIPythonApplication): # strip duplicate extension from output_base, to avoid Basname.ext.ext if getattr(exporter, 'file_extension', False): base, ext = os.path.splitext(self.output_base) - if ext == '.' + exporter.file_extension: + if ext == exporter.file_extension: self.output_base = base notebook_name = self.output_base resources = {} diff --git a/IPython/nbconvert/writers/files.py b/IPython/nbconvert/writers/files.py index 01062e2..d124fb9 100644 --- a/IPython/nbconvert/writers/files.py +++ b/IPython/nbconvert/writers/files.py @@ -93,7 +93,7 @@ class FilesWriter(WriterBase): # Determine where to write conversion results. if output_extension is not None: - dest = notebook_name + '.' + output_extension + dest = notebook_name + output_extension else: dest = notebook_name if self.build_directory: diff --git a/IPython/nbconvert/writers/tests/test_files.py b/IPython/nbconvert/writers/tests/test_files.py index a859a85..38793d1 100644 --- a/IPython/nbconvert/writers/tests/test_files.py +++ b/IPython/nbconvert/writers/tests/test_files.py @@ -59,7 +59,7 @@ class Testfiles(TestsBase): with self.create_temp_cwd(): # Create the resoruces dictionary - res = {'output_extension': 'txt'} + res = {'output_extension': '.txt'} # Create files writer, test output writer = FilesWriter()