Commit d26bdf33 by Chris Jerdonek

Minor tweaks to the SpecLoader class.

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