Commit d24e76fb authored by Matthieu Boileau's avatar Matthieu Boileau

Message and exit on file not found

parent 8f807537
Pipeline #7631 failed with stage
in 1 minute and 50 seconds
......@@ -17,6 +17,7 @@ from nbconvert.preprocessors import ExecutePreprocessor
from nbconvert import HTMLExporter, SlidesExporter
from .mydoit import MyDoitMain, ClassTaskLoader
import logging
import sys
log = logging.getLogger(__name__)
......@@ -82,7 +83,9 @@ class NbCourse:
self.conf['reveal_path'] = nbcourse_libdir / Path('reveal.js')
self.notebooks = tuple(self.conf['nb']['path'].glob('*-*.ipynb'))
if not help and not self.notebooks:
log.warning("No notebooks found! Check 'nb:dir:' field in nbcourse.yml file.")
log.error("No notebooks found!\n" + \
"Check 'nb:dir:' field in nbcourse.yml file.")
if self.conf['book']['file']:
self.titlepage_path = self.conf['pages']['path'] / \
......@@ -136,8 +139,13 @@ class NbCourse:
# Load user conf as file and update default conf
config_file = user_conf
# Load YAML file as dict
with open(config_file, 'r') as f:
user_conf_dict = yaml.safe_load(f)
with open(config_file, 'r') as f:
user_conf_dict = yaml.safe_load(f)
except FileNotFoundError as e:
log.error(f'"{e.filename}" file not found.\n' + \
"Consider initializing an nbcourse project with 'nbcourse --init'.")
update_dict(conf, user_conf_dict)
conf['project_path'] = config_file.absolute().parent
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment