Skip to content

Commit

Permalink
wmlindent: use startswith()/endswith() support for tuples instead of …
Browse files Browse the repository at this point in the history
…a for cycle
  • Loading branch information
Elvish-Hunter committed Jul 29, 2015
1 parent 14ffaf8 commit 464c3d4
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions data/tools/wmlindent
Expand Up @@ -69,10 +69,7 @@ opener_prefixes = ["{FOREACH "]

def is_directive(str):
"Identify things that shouldn't be indented."
for prefix in ("#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#ifver", "#ifnver", "#else", "#endif", "#define", "#enddef", "#undef"):
if str.startswith(prefix):
return True
return False
return str.startswith(("#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#ifver", "#ifnver", "#else", "#endif", "#define", "#enddef", "#undef"))

def closer(str):
"Are we looking at a closing tag?"
Expand All @@ -81,10 +78,7 @@ def closer(str):
elif str.startswith("[/") or str.startswith(")"):
return True
else:
for prefix in closer_prefixes:
if str.startswith(prefix):
return True
return False
return str.startswith(tuple(closer_prefixes))

def opener(str):
"Are we looking at an opening tag?"
Expand All @@ -99,10 +93,7 @@ def opener(str):
elif str.endswith("(\n") and '#' not in str:
return True
else:
for prefix in opener_prefixes:
if str.startswith(prefix):
return True
return False
return str.startswith(tuple(opener_prefixes))

class bailout:
def __init__(self, filename, lineno, msg):
Expand Down

0 comments on commit 464c3d4

Please sign in to comment.