From dcdbae5156efa4717814f040c58537b2b90734d1 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 30 Mar 2021 19:30:04 +0200 Subject: [PATCH] implemented application group class it's object holds environments --- pype/lib/applications.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pype/lib/applications.py b/pype/lib/applications.py index a006538db1..e2596cbacb 100644 --- a/pype/lib/applications.py +++ b/pype/lib/applications.py @@ -90,6 +90,37 @@ class ApplicationLaunchFailed(Exception): pass +class ApplicationGroup: + def __init__(self, name, data, manager): + self.name = name + self.manager = manager + self._data = data + + self.enabled = data.get("enabled", True) + self.label = data.get("label") or name + self.icon = data.get("icon") or None + self._environment = data.get("environment") or {} + + host_name = data.get("host_name", None) + self.is_host = host_name is not None + self.host_name = host_name + + variants = data.get("variants") or {} + + self.variants = variants + + def __repr__(self): + return "<{}> - {}".format(self.__class__.__name__, self.name) + + def __iter__(self): + for variant in self.variants.values(): + yield variant + + @property + def environment(self): + return copy.deepcopy(self._environment) + + class ApplicationManager: def __init__(self): self.log = PypeLogger().get_logger(self.__class__.__name__)