blob: 739e829d07dcbbe61ef0880383dcdfded1a8fbe2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import genshi.template
import Bcfg2.Server.Lint
class Genshi(Bcfg2.Server.Lint.ServerPlugin):
""" Check Genshi templates for syntax errors """
def Run(self):
""" run plugin """
loader = genshi.template.TemplateLoader()
for plugin in ['Cfg', 'TGenshi']:
if plugin in self.core.plugins:
self.check_files(self.core.plugins[plugin].entries,
loader=loader)
def check_files(self, entries, loader=None):
if loader is None:
loader = genshi.template.TemplateLoader()
for eset in entries.values():
for fname, sdata in list(eset.entries.items()):
if fname.endswith(".genshi") or fname.endswith(".newtxt"):
try:
loader.load(sdata.name,
cls=genshi.template.NewTextTemplate)
except genshi.template.TemplateSyntaxError:
err = sys.exc_info()[1]
self.LintError("genshi-syntax-error",
"Genshi syntax error: %s" % err)
|