Skip to content

Commit

Permalink
Include self, reposition private logging function
Browse files Browse the repository at this point in the history
  • Loading branch information
mpacer committed Jan 22, 2017
1 parent 9a30050 commit 5120882
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions nbconvert/exporters/templateexporter.py
Expand Up @@ -204,6 +204,12 @@ def __init__(self, config=None, **kw):
self.observe(self._invalidate_template_cache,
list(self.traits(affects_template=True)))

def _log_template_loading(self,template_file):
""" abstract away some of the loggging for finding templates
"""
self.log.debug("Attempting to load template %s", template_file)
self.log.debug(" template_path: %s", os.pathsep.join(self.template_path))
pass

def _load_template(self):
"""Load the Jinja template object from the template file
Expand All @@ -220,33 +226,24 @@ def _load_template(self):
template_file = self.template_file

try:
_log_template_loading(template_file)
self._log_template_loading(template_file)
return self.environment.get_template(template_file)
except TemplateNotFound:
if self.template_file.endswith(self.template_extension):
try:
template_file = self.template_file[:-len(self.template_extension)]
_log_template_loading(template_file)
self._log_template_loading(template_file)
return self.environment.get_template(template_file)
except TemplateNotFound:
raise TemplateNotFound(template_file)
else:
try:
template_file = self.template_file + self.template_extension
_log_template_loading(template_file)
self._log_template_loading(template_file)
return self.environment.get_template(template_file)
except TemplateNotFound:
raise TemplateNotFound(template_file)

self.log.debug("Attempting to load template %s", template_file)
self.log.debug(" template_path: %s", os.pathsep.join(self.template_path))
return self.environment.get_template(template_file)

def _log_template_loading(template_file):
""" abstract away some of the loggging for finding templates
"""
self.log.debug("Attempting to load template %s", template_file)
self.log.debug(" template_path: %s", os.pathsep.join(self.template_path))
pass

def from_notebook_node(self, nb, resources=None, **kw):
"""
Expand Down

0 comments on commit 5120882

Please sign in to comment.