@@ -146,7 +146,9 @@ class TemplateExporter(Exporter):
146146 """
147147
148148 # finish the docstring
149- __doc__ = __doc__ .format (filters = "- " + "\n - " .join (sorted (default_filters .keys ())))
149+ __doc__ = __doc__ .format (
150+ filters = "- " + "\n - " .join (sorted (default_filters .keys ()))
151+ )
150152
151153 _template_cached = None
152154
@@ -186,9 +188,9 @@ def default_config(self):
186188 config = True , affects_template = True
187189 )
188190
189- template_file = Unicode (None , allow_none = True , help = "Name of the template file to use" ). tag (
190- config = True , affects_template = True
191- )
191+ template_file = Unicode (
192+ None , allow_none = True , help = "Name of the template file to use"
193+ ). tag ( config = True , affects_template = True )
192194
193195 raw_template = Unicode ("" , help = "raw template string" ).tag (affects_environment = True )
194196
@@ -257,7 +259,8 @@ def _default_extra_template_basedirs(self):
257259 template_extension = Unicode ().tag (config = True , affects_environment = True )
258260
259261 template_data_paths = List (
260- jupyter_path ("nbconvert" , "templates" ), help = "Path where templates can be installed too."
262+ jupyter_path ("nbconvert" , "templates" ),
263+ help = "Path where templates can be installed too." ,
261264 ).tag (affects_environment = True )
262265
263266 # Extension that the template files use.
@@ -271,11 +274,13 @@ def _template_extension_default(self):
271274 return self .file_extension
272275
273276 exclude_input = Bool (
274- False , help = "This allows you to exclude code cell inputs from all templates if set to True."
277+ False ,
278+ help = "This allows you to exclude code cell inputs from all templates if set to True." ,
275279 ).tag (config = True )
276280
277281 exclude_input_prompt = Bool (
278- False , help = "This allows you to exclude input prompts from all templates if set to True."
282+ False ,
283+ help = "This allows you to exclude input prompts from all templates if set to True." ,
279284 ).tag (config = True )
280285
281286 exclude_output = Bool (
@@ -284,7 +289,8 @@ def _template_extension_default(self):
284289 ).tag (config = True )
285290
286291 exclude_output_prompt = Bool (
287- False , help = "This allows you to exclude output prompts from all templates if set to True."
292+ False ,
293+ help = "This allows you to exclude output prompts from all templates if set to True." ,
288294 ).tag (config = True )
289295
290296 exclude_output_stdin = Bool (
@@ -293,19 +299,23 @@ def _template_extension_default(self):
293299 ).tag (config = True )
294300
295301 exclude_code_cell = Bool (
296- False , help = "This allows you to exclude code cells from all templates if set to True."
302+ False ,
303+ help = "This allows you to exclude code cells from all templates if set to True." ,
297304 ).tag (config = True )
298305
299306 exclude_markdown = Bool (
300- False , help = "This allows you to exclude markdown cells from all templates if set to True."
307+ False ,
308+ help = "This allows you to exclude markdown cells from all templates if set to True." ,
301309 ).tag (config = True )
302310
303311 exclude_raw = Bool (
304- False , help = "This allows you to exclude raw cells from all templates if set to True."
312+ False ,
313+ help = "This allows you to exclude raw cells from all templates if set to True." ,
305314 ).tag (config = True )
306315
307316 exclude_unknown = Bool (
308- False , help = "This allows you to exclude unknown cells from all templates if set to True."
317+ False ,
318+ help = "This allows you to exclude unknown cells from all templates if set to True." ,
309319 ).tag (config = True )
310320
311321 extra_loaders = List (
@@ -344,9 +354,12 @@ def __init__(self, config=None, **kw):
344354 super ().__init__ (config = config , ** kw )
345355
346356 self .observe (
347- self ._invalidate_environment_cache , list (self .traits (affects_environment = True ))
357+ self ._invalidate_environment_cache ,
358+ list (self .traits (affects_environment = True )),
359+ )
360+ self .observe (
361+ self ._invalidate_template_cache , list (self .traits (affects_template = True ))
348362 )
349- self .observe (self ._invalidate_template_cache , list (self .traits (affects_template = True )))
350363
351364 def _load_template (self ):
352365 """Load the Jinja template object from the template file
@@ -557,7 +570,9 @@ def _template_paths(self, prune=True, root_dirs=None):
557570 base_dir = os .path .join (root_dir , "nbconvert" , "templates" )
558571 paths .append (base_dir )
559572
560- compatibility_dir = os .path .join (root_dir , "nbconvert" , "templates" , "compatibility" )
573+ compatibility_dir = os .path .join (
574+ root_dir , "nbconvert" , "templates" , "compatibility"
575+ )
561576 paths .append (compatibility_dir )
562577
563578 additional_paths = []
@@ -594,7 +609,9 @@ def get_template_names(self):
594609 with open (conf_file ) as f :
595610 conf = recursive_update (json .load (f ), conf )
596611 for root_dir in root_dirs :
597- template_dir = os .path .join (root_dir , "nbconvert" , "templates" , base_template )
612+ template_dir = os .path .join (
613+ root_dir , "nbconvert" , "templates" , base_template
614+ )
598615 if os .path .exists (template_dir ):
599616 found_at_least_one = True
600617 conf_file = os .path .join (template_dir , "conf.json" )
@@ -606,7 +623,11 @@ def get_template_names(self):
606623 for root_dir in root_dirs :
607624 compatibility_file = base_template + ".tpl"
608625 compatibility_path = os .path .join (
609- root_dir , "nbconvert" , "templates" , "compatibility" , compatibility_file
626+ root_dir ,
627+ "nbconvert" ,
628+ "templates" ,
629+ "compatibility" ,
630+ compatibility_file ,
610631 )
611632 if os .path .exists (compatibility_path ):
612633 found_at_least_one = True
@@ -627,7 +648,11 @@ def get_template_names(self):
627648 merged_conf = recursive_update (dict (conf ), merged_conf )
628649 base_template = conf .get ("base_template" )
629650 conf = merged_conf
630- mimetypes = [mimetype for mimetype , enabled in conf .get ("mimetypes" , {}).items () if enabled ]
651+ mimetypes = [
652+ mimetype
653+ for mimetype , enabled in conf .get ("mimetypes" , {}).items ()
654+ if enabled
655+ ]
631656 if self .output_mimetype and self .output_mimetype not in mimetypes and mimetypes :
632657 supported_mimetypes = "\n \t " .join (mimetypes )
633658 raise ValueError (
@@ -641,7 +666,9 @@ def get_prefix_root_dirs(self):
641666 # relative to the package directory (first entry, meaning with highest precedence)
642667 root_dirs = []
643668 if DEV_MODE :
644- root_dirs .append (os .path .abspath (os .path .join (ROOT , ".." , ".." , "share" , "jupyter" )))
669+ root_dirs .append (
670+ os .path .abspath (os .path .join (ROOT , ".." , ".." , "share" , "jupyter" ))
671+ )
645672 root_dirs .extend (jupyter_path ())
646673 return root_dirs
647674
0 commit comments