Skip to content

Commit

Permalink
refactor: unused items for registering events
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Oct 5, 2024
1 parent 2d09e32 commit 6fd4bb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dooit/ui/api/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def register(api: "PluginManager", path: Path) -> None:
foo = importlib.util.module_from_spec(spec)
try:
spec.loader.exec_module(foo)
for name, obj in vars(foo).items():
for obj in vars(foo).values():
if hasattr(obj, "__dooit_event"):
api.register(name, obj)
api.register(obj)
except Exception:
pass

Expand Down
6 changes: 3 additions & 3 deletions dooit/ui/api/plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ def scan(self):
def _register_event(self, event: str, obj: Callable):
self.events[event].append(obj)

def register(self, name, obj):
event = getattr(obj, "__dooit_event")
self._register_event(event, obj)
def register(self, obj):
if event := getattr(obj, "__event", None):
self._register_event(event, obj)

0 comments on commit 6fd4bb8

Please sign in to comment.