wmllint: automatically remove {MAGENTA_IS_THE_TEAM_COLOR}

This commit is contained in:
Elvish_Hunter 2021-12-03 11:47:48 +01:00
parent ca6cafb88f
commit 912625be84
2 changed files with 17 additions and 0 deletions

View file

@ -43,6 +43,7 @@
* Correct unit display adjustments on certain tiles when at zoom level other than 100% (issue #5974)
* Fix the engine exiting immediately due to a corrupt .mo file (issue #6194)
* Removed support for writing BMP screenshots (PR #6206).
* wmllint now automatically removes {MAGENTA_IS_THE_TEAM_COLOR}.
## Version 1.16.0+dev
### Add-ons client

View file

@ -2681,6 +2681,22 @@ def hack_syntax(filename, lines):
in_side_one_tag = False
side_one_tag_needs_side_one = True
break
# handle removal of {MAGENTA_IS_THE_TEAM_COLOR}
for i, line in enumerate(lines):
if "no-syntax-rewrite" in line:
break
m = re.match(r"(\s*)\{MAGENTA_IS_THE_TEAM_COLOR\}(.*)", line)
if m:
new_line = m.group(1) + m.group(2).lstrip()
if new_line.isspace():
# only empty spaces, make the line blank
# don't remove the line to not alter the other for cycles
lines[i] = "\n"
else:
# keep indentation and comments
lines[i] = new_line + "\n"
print('"{}", line {}: removed MAGENTA_IS_THE_TEAM_COLOR'.format(filename,
i+1))
# More syntax transformations would go here.
return lines