wmlindent: use startswith()/endswith() support for tuples instead of a for cycle

This commit is contained in:
Elvish_Hunter 2015-07-29 11:22:26 +02:00
parent 14ffaf8a30
commit 464c3d40b3

View File

@ -69,10 +69,7 @@ opener_prefixes = ["{FOREACH "]
def is_directive(str): def is_directive(str):
"Identify things that shouldn't be indented." "Identify things that shouldn't be indented."
for prefix in ("#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#ifver", "#ifnver", "#else", "#endif", "#define", "#enddef", "#undef"): return str.startswith(("#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#ifver", "#ifnver", "#else", "#endif", "#define", "#enddef", "#undef"))
if str.startswith(prefix):
return True
return False
def closer(str): def closer(str):
"Are we looking at a closing tag?" "Are we looking at a closing tag?"
@ -81,10 +78,7 @@ def closer(str):
elif str.startswith("[/") or str.startswith(")"): elif str.startswith("[/") or str.startswith(")"):
return True return True
else: else:
for prefix in closer_prefixes: return str.startswith(tuple(closer_prefixes))
if str.startswith(prefix):
return True
return False
def opener(str): def opener(str):
"Are we looking at an opening tag?" "Are we looking at an opening tag?"
@ -99,10 +93,7 @@ def opener(str):
elif str.endswith("(\n") and '#' not in str: elif str.endswith("(\n") and '#' not in str:
return True return True
else: else:
for prefix in opener_prefixes: return str.startswith(tuple(opener_prefixes))
if str.startswith(prefix):
return True
return False
class bailout: class bailout:
def __init__(self, filename, lineno, msg): def __init__(self, filename, lineno, msg):