From 0c366586f5037f2f91ac0452fc47936ddb9716e3 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Thu, 5 Aug 2010 21:33:52 +0000 Subject: TGenshi/TCheetah: Add base64 encoding support for files handled by non-Cfg plugins Reported by Chris Brinker in IRC. We should now have the ability to use encoding=base64 in info/info.xml files for paths that are handled by the TGenshi and TCheetah plugins. I think this common code for the three plugins can be merged once we implement Kisielk's idea for having a single Cfg/TGenshi/TCheetah tree. Signed-off-by: Sol Jerome git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@6002 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/TCheetah.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lib/Server/Plugins/TCheetah.py') diff --git a/src/lib/Server/Plugins/TCheetah.py b/src/lib/Server/Plugins/TCheetah.py index 91c830620..d40f4baf3 100644 --- a/src/lib/Server/Plugins/TCheetah.py +++ b/src/lib/Server/Plugins/TCheetah.py @@ -1,6 +1,7 @@ '''This module implements a templating generator based on Cheetah''' __revision__ = '$Revision$' +import binascii import logging import sys import traceback @@ -54,7 +55,11 @@ class TemplateFile: if type(self.template) == unicode: entry.text = self.template else: - entry.text = unicode(str(self.template), self.encoding) + if entry.get('encoding') == 'base64': + # take care of case where file needs base64 encoding + entry.text = binascii.b2a_base64(self.template) + else: + entry.text = unicode(str(self.template), self.encoding) except: (a, b, c) = sys.exc_info() msg = traceback.format_exception(a, b, c, limit=2)[-1][:-1] -- cgit v1.2.3-1-g7c22