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]] = []
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="")
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
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