From ef832008b45621676cf5d5cb092b1547a5d74ddc Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Tue, 31 Jan 2023 11:26:15 -0800 Subject: [PATCH] Fixes the dme validator erroring on an error for duplicate lines (#73061) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## About The Pull Request Wouldn't show the actual error due to an error in the throw: ``` Traceback (most recent call last): File "P:\goonstation\tools\ci\validate_dme.py", line 92, in sorted_lines = sorted(lines, key = functools.cmp_to_key(compare_lines)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "P:\goonstation\tools\ci\validate_dme.py", line 90, in compare_lines raise f"Two lines were exactly the same ({a} vs. {b})" TypeError: exceptions must derive from BaseException ``` With my change: ``` Traceback (most recent call last): File "P:\goonstation\tools\ci\validate_dme.py", line 92, in sorted_lines = sorted(lines, key = functools.cmp_to_key(compare_lines)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "P:\goonstation\tools\ci\validate_dme.py", line 90, in compare_lines raise ValueError(f"Two lines were exactly the same ({a} vs. {b})") ValueError: Two lines were exactly the same (code\serialization.dm vs. code\serialization.dm) ``` I thought about `ImportWarning` but too much work to decide ## Why It's Good For The Game not broeken from ur favorite Big Daddy upstream ❤️ ## Changelog no --------- Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- tools/validate_dme.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/validate_dme.py b/tools/validate_dme.py index 0e1920ee39a..ce1499f82fd 100644 --- a/tools/validate_dme.py +++ b/tools/validate_dme.py @@ -84,7 +84,8 @@ def compare_lines(a, b): if a_segment != b_segment: return (a_segment > b_segment) - (a_segment < b_segment) - raise f"Two lines were exactly the same ({a} vs. {b})" + print(f"Two lines were exactly the same ({a} vs. {b})") + sys.exit(1) sorted_lines = sorted(lines, key = functools.cmp_to_key(compare_lines)) for (index, line) in enumerate(lines):