diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-11 17:18:37 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-11 17:18:37 -0700 |
commit | 1c11a941ca832c06ba125e1da226030504c58033 (patch) | |
tree | 29485b0b9f4d1cf2b83592b1af35ab8b5921ba87 | |
parent | 7a719072faac3b0947d163968bd6e311859ceb3b (diff) | |
download | vyos-cloud-init-1c11a941ca832c06ba125e1da226030504c58033.tar.gz vyos-cloud-init-1c11a941ca832c06ba125e1da226030504c58033.zip |
Start using tempita instead of the more complicated cheetah.
-rw-r--r-- | cloudinit/templater.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/cloudinit/templater.py b/cloudinit/templater.py index 04cc5a6f..5839911c 100644 --- a/cloudinit/templater.py +++ b/cloudinit/templater.py @@ -20,15 +20,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from Cheetah.Template import Template +from tempita import Template from cloudinit import util -def render_to_file(template_fn, outfile, searchList): - contents = Template(file=template_fn, searchList=[searchList]).respond() +def render_from_file(fn, params): + return render_string(util.load_file(fn), params, name=fn) + + +def render_to_file(name, outfile, params): + contents = render_from_file(name, params) util.write_file(outfile, contents) -def render_string(template, searchList): - return Template(template, searchList=[searchList]).respond() +def render_string(content, params, name=None): + tpl = Template(content, name=name) + if not params: + params = dict() + return tpl.substitute(params) |