@@ -146,7 +146,9 @@ class TemplateExporter(Exporter):
146
146
"""
147
147
148
148
# 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
+ )
150
152
151
153
_template_cached = None
152
154
@@ -186,9 +188,9 @@ def default_config(self):
186
188
config = True , affects_template = True
187
189
)
188
190
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 )
192
194
193
195
raw_template = Unicode ("" , help = "raw template string" ).tag (affects_environment = True )
194
196
@@ -257,7 +259,8 @@ def _default_extra_template_basedirs(self):
257
259
template_extension = Unicode ().tag (config = True , affects_environment = True )
258
260
259
261
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." ,
261
264
).tag (affects_environment = True )
262
265
263
266
# Extension that the template files use.
@@ -271,11 +274,13 @@ def _template_extension_default(self):
271
274
return self .file_extension
272
275
273
276
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." ,
275
279
).tag (config = True )
276
280
277
281
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." ,
279
284
).tag (config = True )
280
285
281
286
exclude_output = Bool (
@@ -284,7 +289,8 @@ def _template_extension_default(self):
284
289
).tag (config = True )
285
290
286
291
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." ,
288
294
).tag (config = True )
289
295
290
296
exclude_output_stdin = Bool (
@@ -293,19 +299,23 @@ def _template_extension_default(self):
293
299
).tag (config = True )
294
300
295
301
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." ,
297
304
).tag (config = True )
298
305
299
306
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." ,
301
309
).tag (config = True )
302
310
303
311
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." ,
305
314
).tag (config = True )
306
315
307
316
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." ,
309
319
).tag (config = True )
310
320
311
321
extra_loaders = List (
@@ -344,9 +354,12 @@ def __init__(self, config=None, **kw):
344
354
super ().__init__ (config = config , ** kw )
345
355
346
356
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 ))
348
362
)
349
- self .observe (self ._invalidate_template_cache , list (self .traits (affects_template = True )))
350
363
351
364
def _load_template (self ):
352
365
"""Load the Jinja template object from the template file
@@ -557,7 +570,9 @@ def _template_paths(self, prune=True, root_dirs=None):
557
570
base_dir = os .path .join (root_dir , "nbconvert" , "templates" )
558
571
paths .append (base_dir )
559
572
560
- compatibility_dir = os .path .join (root_dir , "nbconvert" , "templates" , "compatibility" )
573
+ compatibility_dir = os .path .join (
574
+ root_dir , "nbconvert" , "templates" , "compatibility"
575
+ )
561
576
paths .append (compatibility_dir )
562
577
563
578
additional_paths = []
@@ -594,7 +609,9 @@ def get_template_names(self):
594
609
with open (conf_file ) as f :
595
610
conf = recursive_update (json .load (f ), conf )
596
611
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
+ )
598
615
if os .path .exists (template_dir ):
599
616
found_at_least_one = True
600
617
conf_file = os .path .join (template_dir , "conf.json" )
@@ -606,7 +623,11 @@ def get_template_names(self):
606
623
for root_dir in root_dirs :
607
624
compatibility_file = base_template + ".tpl"
608
625
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 ,
610
631
)
611
632
if os .path .exists (compatibility_path ):
612
633
found_at_least_one = True
@@ -627,7 +648,11 @@ def get_template_names(self):
627
648
merged_conf = recursive_update (dict (conf ), merged_conf )
628
649
base_template = conf .get ("base_template" )
629
650
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
+ ]
631
656
if self .output_mimetype and self .output_mimetype not in mimetypes and mimetypes :
632
657
supported_mimetypes = "\n \t " .join (mimetypes )
633
658
raise ValueError (
@@ -641,7 +666,9 @@ def get_prefix_root_dirs(self):
641
666
# relative to the package directory (first entry, meaning with highest precedence)
642
667
root_dirs = []
643
668
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
+ )
645
672
root_dirs .extend (jupyter_path ())
646
673
return root_dirs
647
674
0 commit comments