Commit 78ef793b by Chris Jerdonek

Added optional template_extension argument to Locator.make_file_name().

parent 3f119240
......@@ -76,10 +76,22 @@ class Locator(object):
return re.sub('[A-Z]', repl, template_name)[1:]
def make_file_name(self, template_name):
def make_file_name(self, template_name, template_extension=None):
"""
Generate and return the file name for the given template name.
Arguments:
template_extension: defaults to the instance's extension.
"""
file_name = template_name
if self.template_extension is not False:
file_name += os.path.extsep + self.template_extension
if template_extension is None:
template_extension = self.template_extension
if template_extension is not False:
file_name += os.path.extsep + template_extension
return file_name
......
......@@ -63,6 +63,11 @@ class LocatorTests(unittest.TestCase):
locator.template_extension = ''
self.assertEquals(locator.make_file_name('foo'), 'foo.')
def test_make_file_name__template_extension_argument(self):
locator = Locator()
self.assertEquals(locator.make_file_name('foo', template_extension='bar'), 'foo.bar')
def test_find_path_by_name(self):
locator = Locator()
path = locator.find_path_by_name(search_dirs=['examples'], template_name='simple')
......
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