blob: 552c495b2a08e907cf4cdd1608884698b40f926f (
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
|
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:
self.LintError("genshi-syntax-error",
"Genshi syntax error: %s" % err)
|