change to dictionary.get

This commit is contained in:
Silvris
2024-02-28 23:19:14 -06:00
parent 8ce5a64ac5
commit 4b8f31a749

View File

@@ -56,18 +56,18 @@ class AutoPatchExtensionRegister(type):
@staticmethod
def get_handler(game: str) -> Union[AutoPatchExtensionRegister, List[AutoPatchExtensionRegister]]:
for extension_type, handler in AutoPatchExtensionRegister.extension_types.items():
if extension_type == game:
if handler.required_extensions:
handlers = [handler]
for required in handler.required_extensions:
if required in AutoPatchExtensionRegister.extension_types:
handlers.append(AutoPatchExtensionRegister.extension_types[required])
else:
raise NotImplementedError(f"No handler for {required}.")
return handlers
else:
return handler
if game in AutoPatchExtensionRegister.extension_types:
handler = AutoPatchExtensionRegister.extension_types.get(game)
if handler.required_extensions:
handlers = [handler]
for required in handler.required_extensions:
if required in AutoPatchExtensionRegister.extension_types:
handlers.append(AutoPatchExtensionRegister.extension_types.get(required))
else:
raise NotImplementedError(f"No handler for {required}.")
return handlers
else:
return handler
return APPatchExtension