Commit d26bdf33 by Chris Jerdonek

Minor tweaks to the SpecLoader class.

parent aabb1c6b
......@@ -141,27 +141,28 @@ class SpecLoader(object):
self.loader = loader
self.search_dirs = search_dirs
def _find_relative(self, view):
def _find_relative(self, spec):
"""
Return the relative template path as a (dir, file_name) pair.
Return the path to the template as a relative (dir, file_name) pair.
"""
if view.template_rel_path is not None:
return os.path.split(view.template_rel_path)
template_dir = view.template_rel_directory
The directory returned is relative to the directory containing the
class definition of the given object. The method returns None for
this directory if the directory is unknown without first searching
the search directories.
# Otherwise, we don't know the directory.
"""
if spec.template_rel_path is not None:
return os.path.split(spec.template_rel_path)
# TODO: share code with the loader attribute here.
locator = Locator(extension=self.loader.extension)
# Otherwise, determine the file name separately.
locator = self.loader._make_locator()
template_name = (view.template_name if view.template_name is not None else
locator.make_template_name(view))
template_name = (spec.template_name if spec.template_name is not None else
locator.make_template_name(spec))
file_name = locator.make_file_name(template_name, view.template_extension)
file_name = locator.make_file_name(template_name, spec.template_extension)
return (template_dir, file_name)
return (spec.template_rel_directory, file_name)
def _find(self, spec):
"""
......@@ -170,8 +171,7 @@ class SpecLoader(object):
"""
dir_path, file_name = self._find_relative(spec)
# TODO: share code with the loader attribute here.
locator = Locator(extension=self.loader.extension)
locator = self.loader._make_locator()
if dir_path is None:
# Then we need to search for the path.
......
# coding: utf-8
"""
Unit tests of view.py.
Unit tests for template_spec.py.
"""
......
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