mirror of https://github.com/zulip/zulip.git
Extract check_our_files in check-templates.
(imported from commit 68049b19aacfb159a92e7142b9975a5376c0f9f5)
This commit is contained in:
parent
c9140a6def
commit
c7a9e08105
|
@ -88,25 +88,29 @@ def validate(fn, check_indent=True):
|
||||||
if state.depth != 0:
|
if state.depth != 0:
|
||||||
return state.matcher("(NO TAG)")
|
return state.matcher("(NO TAG)")
|
||||||
|
|
||||||
git_files = map(str.strip, subprocess.check_output(['git', 'ls-files']).split('\n'))
|
def check_our_files():
|
||||||
|
git_files = map(str.strip, subprocess.check_output(['git', 'ls-files']).split('\n'))
|
||||||
|
|
||||||
# Check all our handlebars templates.
|
# Check all our handlebars templates.
|
||||||
templates = [fn for fn in git_files if fn.endswith('.handlebars')]
|
templates = [fn for fn in git_files if fn.endswith('.handlebars')]
|
||||||
assert len(templates) >= 10 # sanity check that we are actually doing work
|
assert len(templates) >= 10 # sanity check that we are actually doing work
|
||||||
for fn in templates:
|
for fn in templates:
|
||||||
validate(fn)
|
validate(fn)
|
||||||
|
|
||||||
# Django templates are pretty messy now, so we do minimal checking.
|
# Django templates are pretty messy now, so we do minimal checking.
|
||||||
templates = sorted([fn for fn in git_files if fn.endswith('.html') and 'templates' in fn])
|
templates = sorted([fn for fn in git_files if fn.endswith('.html') and 'templates' in fn])
|
||||||
|
|
||||||
def ok(fn):
|
def ok(fn):
|
||||||
if 'api.html' in fn: return False
|
if 'api.html' in fn: return False
|
||||||
if 'base.html' in fn: return False
|
if 'base.html' in fn: return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
templates = filter(ok, templates)
|
templates = filter(ok, templates)
|
||||||
|
|
||||||
|
|
||||||
assert len(templates) >= 10 # sanity check that we are actually doing work
|
assert len(templates) >= 10 # sanity check that we are actually doing work
|
||||||
for fn in templates:
|
for fn in templates:
|
||||||
validate(fn, check_indent=False)
|
validate(fn, check_indent=False)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
check_our_files()
|
||||||
|
|
Loading…
Reference in New Issue