From 6cd340ef24c516dadbe951290fc67534a7632b6a Mon Sep 17 00:00:00 2001 From: qwint Date: Sat, 14 Dec 2024 19:33:20 -0600 Subject: [PATCH] use existing patch extension register instead of iterating over potentials could use something like "".join(file.rpartition(".")[1:]) if we still don't want os loaded also i left in the iteration option in case there's an edge case I don't know about, tested a bizhawk game without it and had no issue --- worlds/Files.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/worlds/Files.py b/worlds/Files.py index 69a88218efd4..c71257d62d7b 100644 --- a/worlds/Files.py +++ b/worlds/Files.py @@ -14,7 +14,6 @@ semaphore = threading.Semaphore(os.cpu_count() or 4) del threading -del os class AutoPatchRegister(abc.ABCMeta): @@ -33,6 +32,9 @@ def __new__(mcs, name: str, bases: Tuple[type, ...], dct: Dict[str, Any]) -> Aut @staticmethod def get_handler(file: str) -> Optional[AutoPatchRegister]: + _, suffix = os.path.splitext(file) + if suffix in AutoPatchRegister.file_endings: + return AutoPatchRegister.file_endings[suffix] for file_ending, handler in AutoPatchRegister.file_endings.items(): if file.endswith(file_ending): return handler