voila/voila/handler.py
def fix_notebook(self, notebook):
        """Returns a notebook object with a valid kernelspec.

        In case the kernel is not found, we search for a matching kernel based on the language.
        """

        # Fetch kernel name from the notebook metadata
        if 'kernelspec' not in notebook.metadata:
            notebook.metadata.kernelspec = nbformat.NotebookNode()
        kernelspec = notebook.metadata.kernelspec
        kernel_name = kernelspec.get('name', self.kernel_manager.default_kernel_name)
        # We use `maybe_future` to support RemoteKernelSpecManager
        all_kernel_specs = yield tornado.gen.maybe_future(self.kernel_spec_manager.get_all_specs())
        # Find a spec matching the language if the kernel name does not exist in the kernelspecs
        if kernel_name not in all_kernel_specs:
            missing_kernel_name = kernel_name
            kernel_name = yield self.find_kernel_name_for_language(kernelspec.language.lower(), kernel_specs=all_kernel_specs)
            self.log.warning('Could not find a kernel named %r, will use  %r', missing_kernel_name, kernel_name)
        # We make sure the notebook's kernelspec is correct
        notebook.metadata.kernelspec.name = kernel_name
        notebook.metadata.kernelspec.display_name = all_kernel_specs[kernel_name]['spec']['display_name']
        notebook.metadata.kernelspec.language = all_kernel_specs[kernel_name]['spec']['language']
        raise tornado.gen.Return(notebook)
Returns a notebook object with a valid kernelspec.

        In case the kernel is not found, we search for a matching kernel based on the language.
        
Returns a notebook object with a valid kernelspec.
In case the kernel is not found, we search for a matching kernel based on the language.
Returns a notebook object with a valid kernelspec . In case the kernel is not found we search for a matching kernel based on the language .
def fix_notebook(self, notebook):
        if 'kernelspec' not in notebook.metadata:
            notebook.metadata.kernelspec = nbformat.NotebookNode()
        kernelspec = notebook.metadata.kernelspec
        kernel_name = kernelspec.get('name', self.kernel_manager.default_kernel_name)
        all_kernel_specs = yield tornado.gen.maybe_future(self.kernel_spec_manager.get_all_specs())
        if kernel_name not in all_kernel_specs:
            missing_kernel_name = kernel_name
            kernel_name = yield self.find_kernel_name_for_language(kernelspec.language.lower(), kernel_specs=all_kernel_specs)
            self.log.warning('Could not find a kernel named %r, will use  %r', missing_kernel_name, kernel_name)
        notebook.metadata.kernelspec.name = kernel_name
        notebook.metadata.kernelspec.display_name = all_kernel_specs[kernel_name]['spec']['display_name']
        notebook.metadata.kernelspec.language = all_kernel_specs[kernel_name]['spec']['language']
        raise tornado.gen.Return(notebook)
def fix_notebook ( self , notebook ) : if 'kernelspec' not in notebook . metadata : notebook . metadata . kernelspec = nbformat . NotebookNode ( ) kernelspec = notebook . metadata . kernelspec kernel_name = kernelspec . get ( 'name' , self . kernel_manager . default_kernel_name ) all_kernel_specs = yield tornado . gen . maybe_future ( self . kernel_spec_manager . get_all_specs ( ) ) if kernel_name not in all_kernel_specs : missing_kernel_name = kernel_name kernel_name = yield self . find_kernel_name_for_language ( kernelspec . language . lower ( ) , kernel_specs = all_kernel_specs ) self . log . warning ( 'Could not find a kernel named %r, will use  %r' , missing_kernel_name , kernel_name ) notebook . metadata . kernelspec . name = kernel_name notebook . metadata . kernelspec . display_name = all_kernel_specs [ kernel_name ] [ 'spec' ] [ 'display_name' ] notebook . metadata . kernelspec . language = all_kernel_specs [ kernel_name ] [ 'spec' ] [ 'language' ] raise tornado . gen . Return ( notebook )
Returns a notebook object with a valid kernelspec.
Returns a notebook object with a valid kernelspec .
"""Returns a notebook object with a valid kernelspec.

        In case the kernel is not found, we search for a matching kernel based on the language.
        """ # Fetch kernel name from the notebook metadata # We use `maybe_future` to support RemoteKernelSpecManager # Find a spec matching the language if the kernel name does not exist in the kernelspecs # We make sure the notebook's kernelspec is correct
self
notebook