Skip to content

Commit

Permalink
use existing patch extension register instead of iterating over poten…
Browse files Browse the repository at this point in the history
…tials

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
  • Loading branch information
qwint committed Dec 15, 2024
1 parent ccea6bc commit 6cd340e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion worlds/Files.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
semaphore = threading.Semaphore(os.cpu_count() or 4)

del threading
del os


class AutoPatchRegister(abc.ABCMeta):
Expand All @@ -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
Expand Down

0 comments on commit 6cd340e

Please sign in to comment.