From 1a415b187119fbdc4e08112a6afb23f1caf2b9ad Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 8 Jun 2012 17:59:31 -0700 Subject: Ensure files end with ".tmpl" if they don't initially. --- cloudinit/templater.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cloudinit/templater.py') diff --git a/cloudinit/templater.py b/cloudinit/templater.py index b6b320ab..5a3563a2 100644 --- a/cloudinit/templater.py +++ b/cloudinit/templater.py @@ -2,14 +2,17 @@ import os from Cheetah.Template import Template +from cloudinit import settings from cloudinit import util -TEMPLATE_DIR = '/etc/cloud/templates/' - def render_to_file(template, outfile, searchList): - contents = Template(file=os.path.join(TEMPLATE_DIR, template), - searchList=[searchList]).respond() + fn = template + (base, ext) = os.path.splitext(fn) + if ext != ".tmpl": + fn = "%s.tmpl" % (fn) + fn = os.path.join(settings.TEMPLATE_DIR, fn) + contents = Template(file=fn, searchList=[searchList]).respond() util.write_file(outfile, contents) -- cgit v1.2.3