From 15ae1edcb9afb08c23009f5391587184e9f02d12 Mon Sep 17 00:00:00 2001 From: MarinaGryphon Date: Fri, 17 Sep 2021 09:46:20 -0500 Subject: [PATCH] Updates check_icon_state_limit.py to use byondtoolsv3 --- test/run-test.sh | 4 +++- tools/check_icon_state_limit.py | 28 +++++++++++++++++++++++++ tools/dmitool/check_icon_state_limit.py | 28 ------------------------- 3 files changed, 31 insertions(+), 29 deletions(-) create mode 100644 tools/check_icon_state_limit.py delete mode 100644 tools/dmitool/check_icon_state_limit.py diff --git a/test/run-test.sh b/test/run-test.sh index a3d8ab6cab2..41cd4153d84 100755 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -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/ByondToolsv3.git@0.1.5#egg=ByondToolsv3 -q } function run_code_tests { @@ -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" } diff --git a/tools/check_icon_state_limit.py b/tools/check_icon_state_limit.py new file mode 100644 index 00000000000..3e37250b65e --- /dev/null +++ b/tools/check_icon_state_limit.py @@ -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) diff --git a/tools/dmitool/check_icon_state_limit.py b/tools/dmitool/check_icon_state_limit.py deleted file mode 100644 index 92efb577532..00000000000 --- a/tools/dmitool/check_icon_state_limit.py +++ /dev/null @@ -1,28 +0,0 @@ -import argparse, re, sys -from os import path, walk -import dmitool # This import is why this script is here. If someone can import this file cleanly from [repo root]/test/ instead, feel free - -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) - -bad_dmi_files = [] - -# This section parses all *.dmi files in the given directory, recursively. -for root, subdirs, files in walk(args.dir): - for filename in files: - if filename.endswith('.dmi'): - file_path = path.join(root, filename) - dmi_info = dmitool.info(file_path) - number_of_icon_states = len(dmi_info["states"]) - if number_of_icon_states > 512: - bad_dmi_files.append((file_path, number_of_icon_states)) - -if len(bad_dmi_files) > 0: - for dmi_path, icon_states in bad_dmi_files: - print("{0} had too many icon states. {1}/512.".format(dmi_path, icon_states)) - sys.exit(1)