Browse Source

Print the name of faulty jinja templates in pre-commit (#11484)

pull/11488/head
Max Gautier 2 months ago
committed by GitHub
parent
commit
b0be5f2dad
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 2 deletions
  1. 15
      tests/scripts/check-templates.py

15
tests/scripts/check-templates.py

@ -1,9 +1,20 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
import traceback
from jinja2 import Environment from jinja2 import Environment
from jinja2.exceptions import TemplateSyntaxError
env = Environment() env = Environment()
errors = False
for template in sys.argv[1:]: 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)
Loading…
Cancel
Save