in notebooks/notebook_template_review.py [0:0]
def validate(self, notebook: Notebook) -> bool:
"""
Parse the restart cells
"""
ret = True
while True:
cont = False
cell = notebook.peek()
for line in cell['source']:
if 'pip' in line:
ret = notebook.report_error(ErrorCode.ERROR_INSTALLATION_SINGLE_PIP3, f"All pip installations must be in a single code cell: {line}")
cont = True
break
if not cont:
break
notebook.pop()
cell = notebook.peek()
if not cell['source'][0].startswith("### Restart the kernel"):
ret = notebook.report_error(ErrorCode.ERROR_RESTART_NOTFOUND, "Restart the kernel section not found")
else:
notebook.pop()
cell = notebook.get() # code cell
if cell['cell_type'] != 'code':
ret = notebook.report_error(ErrorCode.ERROR_RESTART_CODE_NOTFOUND, "Restart the kernel code section not found")
return ret