##// END OF EJS Templates
Allow to build a converter without input file
Matthias BUSSONNIER -
Show More
@@ -29,7 +29,8 b' from types import FunctionType'
29 29 # IPython imports
30 30 from IPython.nbformat import current as nbformat
31 31 from IPython.config.configurable import Configurable, SingletonConfigurable
32 from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, CaselessStrEnum
32 from IPython.utils.traitlets import (List, Unicode, Type, Bool, Dict, CaselessStrEnum,
33 Any)
33 34
34 35 # Our own imports
35 36 from .utils import remove_fake_files_url
@@ -112,15 +113,16 b' class Converter(Configurable):'
112 113 # Instance-level attributes that are set in the constructor for this
113 114 # class.
114 115 #-------------------------------------------------------------------------
115 infile = Unicode()
116 infile = Any()
116 117
117 118 highlight_source = Bool(True,
118 119 config=True,
119 120 help="Enable syntax highlighting for code blocks.")
120 121
121 preamble = Unicode("" ,
122 preamble = Unicode( "" ,
122 123 config=True,
123 124 help="Path to a user-specified preamble file")
125
124 126 extract_figures = Bool( True,
125 127 config=True,
126 128 help="""extract base-64 encoded figures of the notebook into separate files,
@@ -154,16 +156,17 b' class Converter(Configurable):'
154 156 # keep in this way for readability's sake.
155 157 self.exclude_cells = exclude
156 158 self.infile = infile
157 self.infile_dir, infile_root = os.path.split(infile)
158 self.infile_root = os.path.splitext(infile_root)[0]
159 self.clean_name = clean_filename(self.infile_root)
160 # Handle the creation of a directory for ancillary files, for
161 # formats that need one.
162 files_dir = os.path.join(self.infile_dir, self.clean_name + '_files')
163 if not os.path.isdir(files_dir):
164 os.mkdir(files_dir)
165 self.files_dir = files_dir
166 self.outbase = os.path.join(self.infile_dir, self.infile_root)
159 if infile:
160 self.infile_dir, infile_root = os.path.split(infile)
161 self.infile_root = os.path.splitext(infile_root)[0]
162 self.clean_name = clean_filename(self.infile_root)
163 # Handle the creation of a directory for ancillary files, for
164 # formats that need one.
165 files_dir = os.path.join(self.infile_dir, self.clean_name + '_files')
166 if not os.path.isdir(files_dir):
167 os.mkdir(files_dir)
168 self.files_dir = files_dir
169 self.outbase = os.path.join(self.infile_dir, self.infile_root)
167 170
168 171 def __del__(self):
169 172 if os.path.isdir(self.files_dir) and not os.listdir(self.files_dir):
General Comments 0
You need to be logged in to leave comments. Login now