os.mkdir(config_dir) if os.path.exists(data_dir) is False: os.mkdir(data_dir) # # 3. Update nbconvert configuration # json_config = os.path.join(jupyter_config_dir(), 'jupyter_nbconvert_config.json') print("Configuring %s" % json_config) if os.path.isfile(json_config) is True: cl = JSONFileConfigLoader(json_config) config = cl.load_config() else: config = Config() newconfig = Config() # Set template path, pre- and postprocessors of notebook extensions newconfig.Exporter.template_path = ['.', os.path.join(data_dir, 'templates')] config.merge(newconfig) config.version = 1 s = json.dumps(config, indent=2, separators=(',', ': '), sort_keys=True) with open(json_config, 'w') as f: f.write(s) py_config = os.path.join(jupyter_config_dir(), 'jupyter_nbconvert_config.py') print("Configuring %s" % py_config) new_py_config = 'nbconvert_config.py' #'jupyter_nbconvert_config.py' update_config(py_config, new_py_config)
# 3. Update nbconvert configuration # json_config = os.path.join(jupyter_config_dir(), 'jupyter_nbconvert_config.json') print("Configuring %s" % json_config) if os.path.isfile(json_config) is True: cl = JSONFileConfigLoader(json_config) config = cl.load_config() else: config = Config() newconfig = Config() # Set template path, pre- and postprocessors of notebook extensions newconfig.Exporter.template_path = [os.path.join(data_dir, 'templates')] newconfig.Exporter.preprocessors = ["pre_codefolding.CodeFoldingPreprocessor", "pre_pymarkdown.PyMarkdownPreprocessor"] newconfig.NbConvertApp.postprocessor_class = 'post_embedhtml.EmbedPostProcessor' config.merge(newconfig) config.version = 1 s=json.dumps(config, indent=2, separators=(',', ': '), sort_keys=True) with open(json_config, 'w') as f: f.write(s) py_config = os.path.join(jupyter_config_dir(), 'jupyter_nbconvert_config.py') print("Configuring %s" % py_config) new_py_config = 'jupyter_nbconvert_config.py' update_config(py_config, new_py_config) # # 4. Update notebook configuration # fname = os.path.join(config_dir, 'jupyter_notebook_config.json') print("Configuring %s" % fname)