wmllint: automatically remove {SOUND:SLOW} and {SOUND:POISON} lines
Part of point 5 of issue #6403
This commit is contained in:
parent
e73bb70179
commit
7976fefbb6
2 changed files with 19 additions and 5 deletions
|
@ -56,6 +56,7 @@
|
|||
* The checks for the old special notes system have been removed from wmllint; the `notecheck off`, `notecheck on` and `match <ability> with <note>` magic comments no longer have any effect.
|
||||
* Resolved title screen flashing during the loading screen (issue #2395)
|
||||
* Fixed erratic keyboard and mouse scroll speed (issue #3607)
|
||||
* wmllint automatically removes the obsolete lines `{SOUND:SLOW}` and `{SOUND:POISON}`
|
||||
|
||||
## Version 1.16.2
|
||||
### Campaigns
|
||||
|
|
|
@ -223,6 +223,13 @@ aliaschanges = (
|
|||
("Vi", "Vt"),
|
||||
)
|
||||
|
||||
# Deprecated lines that ought to be removed globally. Suppressed by noconvert.
|
||||
obsolete_lines = (
|
||||
"{MAGENTA_IS_THE_TEAM_COLOR}",
|
||||
"{SOUND:SLOW}",
|
||||
"{SOUND:POISON}",
|
||||
)
|
||||
|
||||
# Global changes meant to be done on all lines. Suppressed by noconvert.
|
||||
linechanges = (
|
||||
("canrecruit=1", "canrecruit=yes"),
|
||||
|
@ -2649,13 +2656,19 @@ 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}
|
||||
# handle removal of obsolete lines without replacement
|
||||
# obsolete_lines contains normal strings, so re.escape is needed to embed them into this regex
|
||||
obsolete_re = re.compile(r"(\s*)(" + "|".join([re.escape(l) for l in obsolete_lines]) + r")(.*)")
|
||||
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 "wmllint: noconvert" in line:
|
||||
continue
|
||||
m = obsolete_re.match(line)
|
||||
if m:
|
||||
new_line = m.group(1) + m.group(2).lstrip()
|
||||
# match group 1 is the indentation
|
||||
# match group 3 contains everything after the removed part (like comments)
|
||||
new_line = m.group(1) + m.group(3).lstrip()
|
||||
if new_line.isspace():
|
||||
# only empty spaces, make the line blank
|
||||
# don't remove the line to not alter the other for cycles
|
||||
|
@ -2663,8 +2676,8 @@ def hack_syntax(filename, lines):
|
|||
else:
|
||||
# keep indentation and comments
|
||||
lines[i] = new_line + "\n"
|
||||
print('"{}", line {}: removed MAGENTA_IS_THE_TEAM_COLOR'.format(filename,
|
||||
i+1))
|
||||
# match group 2 contains the removed part
|
||||
print('"{}", line {}: removed {}'.format(filename, i+1, m.group(2)))
|
||||
# handle deprecation of [unit] placement=map_overwrite/map_passable/leader_passable
|
||||
in_unit = False
|
||||
for i, line in enumerate(lines):
|
||||
|
|
Loading…
Add table
Reference in a new issue