From bf8b702f05e769c258aaaa56a0755783fba609a3 Mon Sep 17 00:00:00 2001 From: mar77i Date: Sat, 24 Jan 2026 04:14:43 +0100 Subject: [PATCH] Simplify apps registry --- localapps.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/localapps.py b/localapps.py index 197e0e2..41ede00 100755 --- a/localapps.py +++ b/localapps.py @@ -9,22 +9,9 @@ from stat import S_IXGRP, S_IXOTH, S_IXUSR from subprocess import check_output -class IterableHolder(type): - def __init__(self, name, bases, namespace, attr_name=None): - super().__init__(name, bases, namespace) - self.attr_name = attr_name - - def __new__(cls, *args, **kwargs): - kwargs.pop("attr_name", None) - return super().__new__(cls, *args, **kwargs) - - def __iter__(self): - return iter(getattr(self, self.attr_name)) - - -class AppBase(metaclass=IterableHolder, attr_name="registry"): +class AppBase: NAME: str - APPS_DIR = Path("~/local_apps").expanduser() + APPS_DIR = Path("~/apps").expanduser() BIN_PATH: Path registry: list[type[AppBase]] = [] @@ -146,7 +133,7 @@ class LocalAppsManager: getattr(self, self.args.action)() def list(self): - for app in AppBase: + for app in AppBase.registry: latest = app.get_latest_version() assert latest is not None print(app.NAME, "latest", latest, end="") @@ -157,7 +144,7 @@ class LocalAppsManager: print(" installed", installed) def upgrade(self): - for app in AppBase: + for app in AppBase.registry: installed = app.get_installed_version() if installed is None: continue @@ -165,7 +152,9 @@ class LocalAppsManager: def get_pending_apps(self): app_names = [app_name.upper() for app_name in self.args.app_names] - pending_apps = [app for app in AppBase if app.NAME.upper() in app_names] + pending_apps = [ + app for app in AppBase.registry if app.NAME.upper() in app_names + ] if len(pending_apps) != len(app_names): missing_apps = [ app_name -- 2.51.0