From 02dac91a6e2fad05b3e4802ab6f075afa6c84429 2013-10-04 22:56:33 From: jakobgager Date: 2013-10-04 22:56:33 Subject: [PATCH] Adress comments * move file extension addition outside of function * move log statement before function call * change default to False * add postprocessor to nbconvertapp --- diff --git a/IPython/nbconvert/nbconvertapp.py b/IPython/nbconvert/nbconvertapp.py index 8b09002..85ab4a4 100755 --- a/IPython/nbconvert/nbconvertapp.py +++ b/IPython/nbconvert/nbconvertapp.py @@ -88,7 +88,7 @@ class NbConvertApp(BaseIPythonApplication): def _classes_default(self): classes = [NbConvertBase, ProfileDir] - for pkg in (exporters, preprocessors, writers): + for pkg in (exporters, preprocessors, writers, postprocessors): for name in dir(pkg): cls = getattr(pkg, name) if isinstance(cls, type) and issubclass(cls, Configurable): diff --git a/IPython/nbconvert/postprocessors/pdf.py b/IPython/nbconvert/postprocessors/pdf.py index 9c1b098..db00144 100644 --- a/IPython/nbconvert/postprocessors/pdf.py +++ b/IPython/nbconvert/postprocessors/pdf.py @@ -45,7 +45,7 @@ class PDFPostProcessor(PostProcessorBase): config=True, help=""" Filename extensions of temp files to remove after running. """) - pdf_open = Bool(True, config=True, help=""" + pdf_open = Bool(False, config=True, help=""" Whether or not to open the pdf after the compile call. """) @@ -117,14 +117,14 @@ class PDFPostProcessor(PostProcessorBase): except OSError: pass - def open_pdf(self,filename): - filepath = filename+'.pdf' + def open_pdf(self, filename): + """Open the pdf in the default viewer.""" if sys.platform.startswith('darwin'): - subprocess.call(('open', filepath)) + subprocess.call(('open', filename)) elif os.name == 'nt': - os.startfile(filepath) + os.startfile(filename) elif os.name == 'posix': - subprocess.call(('xdg-open', filepath)) + subprocess.call(('xdg-open', filename)) return def postprocess(self, filename): @@ -143,7 +143,7 @@ class PDFPostProcessor(PostProcessorBase): if os.path.isfile(filename+'.pdf'): self.log.info('PDF successfully created') if self.pdf_open: - self.open_pdf(filename) self.log.info('Viewer called') + self.open_pdf(filename+'.pdf') return