summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2008-09-29 16:59:53 +0000
committerSol Jerome <solj@ices.utexas.edu>2008-09-29 16:59:53 +0000
commit44db9bfa747b33ac8e4b820a0fe80cd857cbecdf (patch)
treeeb43a35c4a05c4a7495947914518a16a8a4756b9 /src/lib
parent9935853fa13c834d644512a561835b72a5bf3dc8 (diff)
downloadbcfg2-44db9bfa747b33ac8e4b820a0fe80cd857cbecdf.tar.gz
bcfg2-44db9bfa747b33ac8e4b820a0fe80cd857cbecdf.tar.bz2
bcfg2-44db9bfa747b33ac8e4b820a0fe80cd857cbecdf.zip
Support for new Genshi text template syntax (patch from Kamil Kisiel)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4926 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Plugins/TGenshi.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/lib/Server/Plugins/TGenshi.py b/src/lib/Server/Plugins/TGenshi.py
index 8331d9735..471bde091 100644
--- a/src/lib/Server/Plugins/TGenshi.py
+++ b/src/lib/Server/Plugins/TGenshi.py
@@ -1,7 +1,8 @@
'''This module implements a templating generator based on Genshi'''
__revision__ = '$Revision$'
-from genshi.template import TemplateLoader, TextTemplate, MarkupTemplate, TemplateError
+from genshi.template import TemplateLoader, NewTextTemplate, \
+ TextTemplate, MarkupTemplate, TemplateError
import logging
import Bcfg2.Server.Plugin
import genshi.core, genshi.input
@@ -30,6 +31,8 @@ class TemplateFile:
matchname = self.name[:self.name.find('.H')]
if matchname.endswith('.txt'):
self.template_cls = TextTemplate
+ elif matchname.endswith('.newtxt'):
+ self.template_cls = NewTextTemplate
else:
self.template_cls = MarkupTemplate
@@ -53,7 +56,7 @@ class TemplateFile:
stream = self.template.generate( \
name=fname, metadata=metadata, path=self.name,
properties=self.properties).filter(removecomment)
- if isinstance(self.template, TextTemplate):
+ if isinstance(self.template, TextTemplate) or isinstance(self.template, NewTextTemplate):
textdata = stream.render('text')
if type(textdata) == unicode:
entry.text = textdata
@@ -72,12 +75,18 @@ class TemplateFile:
except TemplateError, terror:
logger.error('Genshi template error: %s' % terror)
raise Bcfg2.Server.Plugin.PluginExecutionError
+ except AttributeError, err:
+ logger.error('Genshi template loading error: %s' % err)
+ raise Bcfg2.Server.Plugin.PluginExecutionError
class TGenshi(Bcfg2.Server.Plugin.GroupSpool):
- '''The TGenshi generator implements a templating mechanism for configuration files'''
+ '''
+ The TGenshi generator implements a templating
+ mechanism for configuration files
+ '''
__name__ = 'TGenshi'
__version__ = '$Id$'
__author__ = 'jeff@ocjtech.us'
use_props = True
- filename_pattern = 'template\.(txt|xml)'
+ filename_pattern = 'template\.(txt|newtxt|xml)'
es_child_cls = TemplateFile