diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-03-31 10:29:40 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-03-31 10:29:40 -0700 |
commit | f6b36707e2b0c5fed1a59f096f750bad70668272 (patch) | |
tree | a9acf8e34da65690a9c70bf267a86464fc5b3037 | |
parent | 0acab11d58bfd17bcabc673dd44a2318559373f1 (diff) | |
download | pystache-f6b36707e2b0c5fed1a59f096f750bad70668272.tar.gz |
Refactored loader.Loader to use a _make_locator() method.
-rw-r--r-- | pystache/loader.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pystache/loader.py b/pystache/loader.py index d7cdca1..fe7be16 100644 --- a/pystache/loader.py +++ b/pystache/loader.py @@ -51,8 +51,8 @@ class Loader(object): It should accept a string of type str and an optional encoding name and return a string of type unicode. Defaults to calling - Python's built-in function unicode() using the package encoding - and decode-errors defaults. + Python's built-in function unicode() using the package string + encoding and decode errors defaults. """ if extension is None: @@ -68,6 +68,9 @@ class Loader(object): self.file_encoding = file_encoding self.to_unicode = to_unicode + def _make_locator(self): + return Locator(extension=self.extension) + def unicode(self, s, encoding=None): """ Convert a string to unicode using the given encoding, and return it. @@ -116,7 +119,7 @@ class Loader(object): search_dirs: the list of directories in which to search. """ - locator = Locator(extension=self.extension) + locator = self._make_locator() path = locator.find_path_by_name(search_dirs, name) @@ -134,7 +137,7 @@ class Loader(object): search_dirs: the list of directories in which to search. """ - locator = Locator(extension=self.extension) + locator = self._make_locator() path = locator.find_path_by_object(search_dirs, obj) |