Skip to content

Commit c550db4

Browse files
authored
Merges check_icon_dupenames.py and check_icon_conflicts.py (ParadiseSS13#28587)
* merges check_icon_conflicts and check_icon_dupenames into check_icons.py * oopsies * god damn it
1 parent 5b3942d commit c550db4

File tree

4 files changed

+57
-79
lines changed

4 files changed

+57
-79
lines changed

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ jobs:
5252
python tools/ci/check_map_sizes.py
5353
python tools/ci/verify_sql_version.py
5454
python tools/ci/no_duplicate_definitions.py
55-
python -m tools.ci.check_icon_conflicts
56-
python -m tools.ci.check_icon_dupenames
55+
python tools/ci/check_icons.py
5756
python -m tools.ci.check_legacy_attack_chain
5857
python -m tools.maplint.source --github
5958

tools/ci/check_icon_conflicts.py

-37
This file was deleted.

tools/ci/check_icon_dupenames.py

-40
This file was deleted.

tools/ci/check_icons.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from glob import glob
2+
from time import time
3+
from collections import defaultdict
4+
5+
from avulto import DMI
6+
7+
def check_duplicate_names(dmi: DMI) -> list[str]:
8+
states = set()
9+
failures = []
10+
for state in dmi.states():
11+
# Movement states have the same name as their non-movement counterparts
12+
if (state.name, state.movement) in states:
13+
duplicates.append(f"duplicate state name `{state.name}`")
14+
states.add((state.name, state.movement))
15+
return failures
16+
17+
def check_conflicted(dmi: DMI) -> list[str]:
18+
failures = []
19+
for state in dmi.state_names():
20+
if '!CONFLICT!' in state:
21+
failures.append(f"conflicted state {state}")
22+
return failures
23+
24+
ICON_CHECKS = [
25+
check_duplicate_names,
26+
check_conflicted,
27+
]
28+
29+
if __name__ == "__main__":
30+
print("check_icons started")
31+
32+
count = 0
33+
exit_code = 0
34+
start = time()
35+
36+
findings = defaultdict(list)
37+
38+
for dmi_path in glob("**/*.dmi", recursive=True):
39+
dmi = DMI.from_file(dmi_path)
40+
for check in ICON_CHECKS:
41+
if failures := check(dmi):
42+
findings[dmi_path].extend(failures)
43+
count += 1
44+
45+
if findings:
46+
exit_code = 1
47+
48+
for filename in sorted(findings.keys()):
49+
failures = findings[filename]
50+
for failure in sorted(failures):
51+
print(f"{filename}: {failure}")
52+
53+
end = time()
54+
print(f"\ncheck_icons checked {count} files in {end - start:.2f}s")
55+
56+
exit(exit_code)

0 commit comments

Comments
 (0)