summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/TGenshi.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/TGenshi.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/TGenshi.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/TGenshi.py b/src/lib/Bcfg2/Server/Plugins/TGenshi.py
index c4dd40614..c7335a0c0 100644
--- a/src/lib/Bcfg2/Server/Plugins/TGenshi.py
+++ b/src/lib/Bcfg2/Server/Plugins/TGenshi.py
@@ -1,12 +1,10 @@
"""This module implements a templating generator based on Genshi."""
-import binascii
import logging
import sys
import Bcfg2.Server.Plugin
-# py3k compatibility
-if sys.hexversion >= 0x03000000:
- unicode = str
+
+from Bcfg2.Bcfg2Py3k import unicode, b64encode
logger = logging.getLogger('Bcfg2.Plugins.TGenshi')
@@ -18,7 +16,7 @@ try:
TextTemplate, MarkupTemplate, TemplateError
except ImportError:
logger.error("TGenshi: Failed to import Genshi. Is it installed?")
- raise Bcfg2.Server.Plugin.PluginInitError
+ raise
try:
from genshi.template import NewTextTemplate
have_ntt = True
@@ -33,7 +31,7 @@ def removecomment(stream):
yield kind, data, pos
-class TemplateFile:
+class TemplateFile(object):
"""Template file creates Genshi template structures for the loaded file."""
def __init__(self, name, specific, encoding):
@@ -99,7 +97,7 @@ class TemplateFile:
else:
if entry.get('encoding') == 'base64':
# take care of case where file needs base64 encoding
- entry.text = binascii.b2a_base64(textdata)
+ entry.text = b64encode(textdata)
else:
entry.text = unicode(textdata, self.encoding)
else:
@@ -123,6 +121,10 @@ class TemplateFile:
raise Bcfg2.Server.Plugin.PluginExecutionError('Genshi template loading error: %s' % err)
+class TemplateEntrySet(Bcfg2.Server.Plugin.EntrySet):
+ basename_is_regex = True
+
+
class TGenshi(Bcfg2.Server.Plugin.GroupSpool):
"""
The TGenshi generator implements a templating
@@ -132,4 +134,6 @@ class TGenshi(Bcfg2.Server.Plugin.GroupSpool):
name = 'TGenshi'
__author__ = 'jeff@ocjtech.us'
filename_pattern = 'template\.(txt|newtxt|xml)'
+ es_cls = TemplateEntrySet
es_child_cls = TemplateFile
+ deprecated = True