summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/TGenshi.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-04-08 16:42:45 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-04-08 16:42:45 +0000
commit48ab43cff593b9020633004c4393e8bf91b5b88b (patch)
tree4d6f2966a784470d84dd9e65839edea66e5d1c18 /src/lib/Server/Plugins/TGenshi.py
parentc3aa4519176032ab496f29e57be19f6b1de56d0f (diff)
downloadbcfg2-48ab43cff593b9020633004c4393e8bf91b5b88b.tar.gz
bcfg2-48ab43cff593b9020633004c4393e8bf91b5b88b.tar.bz2
bcfg2-48ab43cff593b9020633004c4393e8bf91b5b88b.zip
Switch SGenshi over to using EntrySet classes as well (SGenshi templates can now be client and group specific, and can use properties internally)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4486 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins/TGenshi.py')
-rw-r--r--src/lib/Server/Plugins/TGenshi.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/Server/Plugins/TGenshi.py b/src/lib/Server/Plugins/TGenshi.py
index d7199d78c..0b9acfe58 100644
--- a/src/lib/Server/Plugins/TGenshi.py
+++ b/src/lib/Server/Plugins/TGenshi.py
@@ -4,9 +4,17 @@ __revision__ = '$Revision$'
from genshi.template import TemplateLoader, TextTemplate, MarkupTemplate, TemplateError
import logging
import Bcfg2.Server.Plugin
+import genshi.core
logger = logging.getLogger('Bcfg2.Plugins.TGenshi')
+def removecomment(stream):
+ """A genshi filter that removes comments from the stream."""
+ for kind, data, pos in stream:
+ if kind is genshi.core.COMMENT:
+ continue
+ yield kind, data, pos
+
class TemplateFile:
'''Template file creates Genshi template structures for the loaded file'''
def __init__(self, name, properties, specific):
@@ -38,9 +46,9 @@ class TemplateFile:
'''Build literal file information'''
fname = entry.get('realname', entry.get('name'))
try:
- stream = self.template.generate(name=fname,
- metadata=metadata,
- properties=self.properties)
+ stream = self.template.generate( \
+ name=fname, metadata=metadata,
+ properties=self.properties).filter(removecomment)
if isinstance(self.template, TextTemplate):
entry.text = stream.render('text')
else: