Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def default_config(self):
c = Config({
'CSSHTMLHeaderPreprocessor': {
'enabled': False
},
'VoilaExporter': {
'markdown_renderer_class': 'voila.exporter.VoilaMarkdownRenderer'
}
})
c.merge(super(VoilaExporter, self).default_config)
return c
resources = {
'base_url': self.base_url,
'nbextensions': nbextensions,
'theme': self.voila_configuration.theme
}
# include potential extra resources
extra_resources = self.voila_configuration.config.VoilaConfiguration.resources
# if no resources get configured from neither the CLI nor a config file,
# extra_resources is a traitlets.config.loader.LazyConfigValue object
if not isinstance(extra_resources, dict):
extra_resources = extra_resources.to_dict()
if extra_resources:
recursive_update(resources, extra_resources)
self.exporter = VoilaExporter(
template_path=self.nbconvert_template_paths,
config=self.traitlet_config,
contents_manager=self.contents_manager # for the image inlining
)
if self.voila_configuration.strip_sources:
self.exporter.exclude_input = True
self.exporter.exclude_output_prompt = True
self.exporter.exclude_input_prompt = True
# These functions allow the start of a kernel and execution of the notebook after (parts of) the template
# has been rendered and send to the client to allow progressive rendering.
# Template should first call kernel_start, and then decide to use notebook_execute
# or cell_generator to implement progressive cell rendering
extra_context = {
# NOTE: we can remove the lambda is we use jinja's async feature, which will automatically await the future
'kernel_start': lambda: self._jinja_kernel_start().result(), # pass the result (not the future) to the template
)
aliases = {
'port': 'Voila.port',
'static': 'Voila.static_root',
'strip_sources': 'VoilaConfiguration.strip_sources',
'autoreload': 'Voila.autoreload',
'template': 'VoilaConfiguration.template',
'theme': 'VoilaConfiguration.theme',
'base_url': 'Voila.base_url',
'server_url': 'Voila.server_url',
'enable_nbextensions': 'VoilaConfiguration.enable_nbextensions'
}
classes = [
VoilaConfiguration,
VoilaExecutePreprocessor,
VoilaExporter,
VoilaCSSPreprocessor
]
connection_dir_root = Unicode(
config=True,
help=_(
'Location of temporry connection files. Defaults '
'to system `tempfile.gettempdir()` value.'
)
)
connection_dir = Unicode()
base_url = Unicode(
'/',
config=True,
help=_(
'Path for voila API calls. If server_url is unset, this will be \