##// END OF EJS Templates
Merge pull request #3861 from minrk/external-js...
Merge pull request #3861 from minrk/external-js remove old external.js

File last commit:

r11859:08b01057
r11901:0741b515 merge
Show More
pdf.py
52 lines | 1.8 KiB | text/x-python | PythonLexer
Jonathan Frederic
Fixed errors after testing...
r11742 """
Contains writer for writing nbconvert output to PDF.
"""
#-----------------------------------------------------------------------------
#Copyright (c) 2013, the IPython Development Team.
#
#Distributed under the terms of the Modified BSD License.
#
#The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import subprocess
import os
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 from IPython.utils.traitlets import Integer, Unicode, Bool
Jonathan Frederic
Fixed errors after testing...
r11742
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 from .base import PostProcessorBase
Jonathan Frederic
Fixed errors after testing...
r11742
#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 class PDFPostProcessor(PostProcessorBase):
Jonathan Frederic
Fixed errors after testing...
r11742 """Writer designed to write to PDF files"""
iteration_count = Integer(3, config=True, help="""
How many times pdflatex will be called.
""")
Jonathan Frederic
flavor=template
r11745 compiler = Unicode(u'pdflatex {0}', config=True, help="""
Shell command used to compile PDF.""")
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 verbose = Bool(False, config=True, help="""
Whether or not to display the output of the compile call.
""")
def call(self, input):
Jonathan Frederic
Fixed errors after testing...
r11742 """
Consume and write Jinja output a PDF.
See files.py for more...
"""
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 command = self.compiler.format(input)
MinRK
add log statement to PDFPostProcessor
r11859 self.log.info("Building PDF: `%s`", command)
Jonathan Frederic
Fixed errors after testing...
r11742 for index in range(self.iteration_count):
Jonathan Frederic
Moved PDF logic into Post-Processor class
r11747 if self.verbose:
subprocess.Popen(command, shell=True)
else:
with open(os.devnull, 'wb') as null:
subprocess.Popen(command, shell=True, stdout=null)