Skip to content

Commit

Permalink
Updates check_icon_state_limit.py to use byondtoolsv3
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinaGryphon authored and comma committed Sep 18, 2021
1 parent b4be6cc commit 15ae1ed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
4 changes: 3 additions & 1 deletion test/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function setup_python3 {
pip3 install --upgrade pip -q
pip3 install pyyaml==5.3 -q
pip3 install beautifulsoup4==4.8.2 -q
pip3 install git+https://github.com/ComicIronic/[email protected]#egg=ByondToolsv3 -q
}

function run_code_tests {
Expand All @@ -206,7 +207,8 @@ function run_code_tests {
run_test "check tags" "python3 tools/TagMatcher/tag-matcher.py ."
run_test "check color hex" "python3 tools/ColorHexChecker/color-hex-checker.py ."
run_test "check punctuation" "python3 tools/PunctuationChecker/punctuation-checker.py ."
run_test "check icon state limit" "python3 tools/dmitool/check_icon_state_limit.py ."
run_test "check icon state limit (icons)" "python3 tools/check_icon_state_limit.py icons"
run_test "check icon state limit (mods)" "python3 tools/check_icon_state_limit.py mods"
run_test_ci "check changelog builds" "python3 tools/changelog/ss13_genchangelog.py html/changelog.html html/changelogs"
}

Expand Down
28 changes: 28 additions & 0 deletions tools/check_icon_state_limit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import argparse, sys, logging
from os import path, walk
from byond.DMI import DMI

opt = argparse.ArgumentParser()
opt.add_argument('dir', help='The directory to scan for *.dmi files with an excess number of icon states.')
args = opt.parse_args()

if(not path.isdir(args.dir)):
print('Not a directory')
sys.exit(1)

failed = False
logging.getLogger().setLevel(logging.ERROR) # we don't care that byond is bad at pngs
# This section parses all *.dmi files in the given directory, recursively.
for root, subdirs, files in walk(args.dir):
for filename in files:
if not filename.endswith('.dmi'):
continue
file_path = path.join(root, filename)
dmi = DMI(file_path)
dmi.loadMetadata()
number_of_icon_states = len(dmi.states)
if number_of_icon_states > 512:
failed = True
print("{0} had too many icon states. {1}/512".format(file_path, number_of_icon_states))
if failed:
sys.exit(1)
28 changes: 0 additions & 28 deletions tools/dmitool/check_icon_state_limit.py

This file was deleted.

0 comments on commit 15ae1ed

Please sign in to comment.