mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-13 21:34:40 +03:00
Print the name of faulty jinja templates in pre-commit (#11484)
This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
from jinja2 import Environment
|
||||
from jinja2.exceptions import TemplateSyntaxError
|
||||
|
||||
|
||||
env = Environment()
|
||||
errors = False
|
||||
for template in sys.argv[1:]:
|
||||
with open(template) as t:
|
||||
env.parse(t.read())
|
||||
try:
|
||||
with open(template) as t:
|
||||
env.parse(t.read())
|
||||
except TemplateSyntaxError as e:
|
||||
print (template)
|
||||
traceback.print_exc()
|
||||
errors = True
|
||||
if errors:
|
||||
exit (1)
|
||||
|
||||
Reference in New Issue
Block a user