mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 22:45:28 +00:00
wmlindent: use startswith()/endswith() support for tuples instead of a for cycle
This commit is contained in:
parent
14ffaf8a30
commit
464c3d40b3
@ -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):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user