mirror of https://github.com/zulip/zulip.git
Make fn param optional with template_parser.validate().
The caller can now pass in text directly. This is mostly for testing, but it could be useful in other situations.
This commit is contained in:
parent
1f8ba1d1b5
commit
5af47e0eef
|
@ -85,7 +85,7 @@ def check_html_templates(templates, modified_only):
|
|||
'templates/zerver/right-sidebar.html',
|
||||
'templates/zerver/search_operators.html',
|
||||
]
|
||||
validate(fn, check_indent=(fn not in bad_files))
|
||||
validate(fn=fn, check_indent=(fn not in bad_files))
|
||||
|
||||
def check_handlebar_templates(templates, modified_only):
|
||||
# type: (Iterable[str], bool) -> None
|
||||
|
@ -94,7 +94,7 @@ def check_handlebar_templates(templates, modified_only):
|
|||
if not modified_only:
|
||||
assert len(templates) >= 10 # sanity check that we are actually doing work
|
||||
for fn in templates:
|
||||
validate(fn, check_indent=True)
|
||||
validate(fn=fn, check_indent=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
check_our_files()
|
||||
|
|
|
@ -103,9 +103,16 @@ def tokenize(text):
|
|||
|
||||
return tokens
|
||||
|
||||
def validate(fn, check_indent=True):
|
||||
# type: (str, bool) -> None
|
||||
def validate(fn=None, text=None, check_indent=True):
|
||||
# type: (str, str, bool) -> None
|
||||
assert fn or text
|
||||
|
||||
if fn is None:
|
||||
fn = '<in memory file>'
|
||||
|
||||
if text is None:
|
||||
text = open(fn).read()
|
||||
|
||||
tokens = tokenize(text)
|
||||
|
||||
class State(object):
|
||||
|
|
Loading…
Reference in New Issue