wmlindent: use startswith()/endswith() support for tuples instead of a for cycle
This commit is contained in:
parent
14ffaf8a30
commit
464c3d40b3
1 changed files with 3 additions and 12 deletions
|
@ -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?"
|
||||
|
@ -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?"
|
||||
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue