From a3e1b2acccfe15c48c7f0c48d8bb98b0efb0cca2 Mon Sep 17 00:00:00 2001 From: Hemery Mathieu <mathieu.hemery@inria.fr> Date: Tue, 11 Feb 2025 17:09:26 +0100 Subject: [PATCH] %load magic add an extra cell after loading --- biocham_jupyter/kernel/biocham_kernel/kernel.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/biocham_jupyter/kernel/biocham_kernel/kernel.py b/biocham_jupyter/kernel/biocham_kernel/kernel.py index 9f5049de..19a1b7fd 100644 --- a/biocham_jupyter/kernel/biocham_kernel/kernel.py +++ b/biocham_jupyter/kernel/biocham_kernel/kernel.py @@ -207,11 +207,16 @@ class BiochamKernel(IPythonKernel): # pylint: disable=too-many-ancestors with open(bcfile, 'r') as bcinput: lines = bcinput.read().split('.\n') # create a cell after current cell for each dotted command - return 'loading {}'.format(bcfile), [{ + empty_cell = [{ 'source': 'set_next_input', - 'text': line.strip() + '.', + 'text': '', 'replace': False, - } for line in reversed(lines) if line.strip()] + }] + command_cells = [{'source': 'set_next_input', + 'text': line.strip() + '.', + 'replace': False, + } for line in reversed(lines) if line.strip()] + return 'loading {}'.format(bcfile), empty_cell + command_cells except FileNotFoundError: return "File doesn't exists", [] -- GitLab