Commit dd7e8367 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Centralize logging

parent b270a167
import jinja2
import logging
from . import log
import os
from bookbook.latex import combine_and_convert
from pathlib import Path
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)
class BookContext:
"""
......
......@@ -8,6 +8,7 @@ Define a NbCourse object containing:
from pathlib import Path, PosixPath
import yaml
from doit.tools import create_folder, config_changed
from . import log
from .utils import update_material, clean_tree, get_file_list, update_dict, \
zip_files
from .pages import HomePage, MarkdownPage
......@@ -16,11 +17,8 @@ import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from nbconvert import HTMLExporter, SlidesExporter
from .mydoit import MyDoitMain, ClassTaskLoader
import logging
import sys
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
DEFAULT_CONFIG_FILE = "nbcourse.yml"
......@@ -28,39 +26,39 @@ DEFAULT_CONFIG_FILE = "nbcourse.yml"
class NbCourse:
default_conf = {
'theme': {
'dir': 'theme/default',
'material': ('css', 'img')
},
'nb': {
'dir': '.',
'timeout': 60,
'material': ()
},
'pages': {
'dir': 'pages',
'home': 'index.html'
},
'book': {
'titlepage': 'titlepage.tex',
'file': None,
},
'local_reveal': False,
'slug_title': 'course',
'output_dir': 'build',
'title': 'A course',
'subtitle': None,
'favicon': None,
'picture': None,
'authors': [],
'chapter_preview_only': [],
'license': None,
'links': {'manual': {
'title': 'Manual',
'target': 'manual.html',
}
}
}
'theme': {
'dir': 'theme/default',
'material': ('css', 'img')
},
'nb': {
'dir': '.',
'timeout': 60,
'material': ()
},
'pages': {
'dir': 'pages',
'home': 'index.html'
},
'book': {
'titlepage': 'titlepage.tex',
'file': None,
},
'local_reveal': False,
'slug_title': 'course',
'output_dir': 'build',
'title': 'A course',
'subtitle': None,
'favicon': None,
'picture': None,
'authors': [],
'chapter_preview_only': [],
'license': None,
'links': {'manual': {
'title': 'Manual',
'target': 'manual.html',
}
}
}
def __init__(self, user_conf=None):
"""Build from user_conf"""
......@@ -72,12 +70,12 @@ class NbCourse:
self.conf[key]['material_paths'] = [
self.conf[key]['path'] / Path(d)
for d in self.conf[key]['material']
]
]
self.conf['pages']['path'] = Path(self.conf['pages']['dir'])
self.conf['output_path'] = Path(self.conf['output_dir'])
if self.conf['local_reveal']:
self.conf['reveal_path'] = Path(__file__).parent / \
Path('reveal.js')
Path('reveal.js')
self.notebooks = tuple(self.conf['nb']['path'].glob('*-*.ipynb'))
if user_conf and not self.notebooks:
log.error("""
......
from . import log
import nbformat
import re
import logging
import markdown
from pathlib import Path
from pprint import pformat
......@@ -9,9 +9,6 @@ from bs4 import BeautifulSoup
import frontmatter
import sys
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
class Page:
"""An abstract class for a static web page"""
......@@ -64,7 +61,7 @@ class HomePage(Page):
nb = nbformat.read(str(path), as_version=4)
if nb.cells[0].cell_type != 'markdown':
log.error(f"The first cell of the notebook {path} should be Markdown type " +
log.error(f"The first cell of the notebook {path} should be Markdown type " +
f"({nb.cells[0].cell_type} instead).")
sys.exit()
lines = nb.cells[0].source.splitlines()
......
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