Skip to content

Commit 7050b09

Browse files
committed
Update packages.py to allow more versatile PackagesStore
1 parent 1f7117d commit 7050b09

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

aikido_zen/background_process/packages.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import importlib.metadata as importlib_metadata
44

55
from packaging.version import Version
6+
7+
from aikido_zen.helpers.get_current_unixtime_ms import get_unixtime_ms
68
from aikido_zen.helpers.logging import logger
79

810
# If any version is supported, this constant can be used
@@ -59,14 +61,22 @@ class PackagesStore:
5961
@staticmethod
6062
def get_packages():
6163
global packages
62-
return packages
64+
result = []
65+
for package in packages.values():
66+
if package.get("cleared", False):
67+
continue
68+
result.append(dict(package))
69+
return result
6370

6471
@staticmethod
65-
def add_package(package, version, supported):
72+
def add_package(package, version, supported=None):
6673
global packages
6774
packages[package] = {
75+
"name": package,
6876
"version": version,
69-
"supported": bool(supported),
77+
"requiredAt": get_unixtime_ms(),
78+
"supported": supported,
79+
"cleared": False,
7080
}
7181

7282
@staticmethod
@@ -75,3 +85,17 @@ def get_package(package_name):
7585
if package_name in packages:
7686
return packages[package_name]
7787
return None
88+
89+
@staticmethod
90+
def clear():
91+
global packages
92+
for package in packages:
93+
packages[package]["cleared"] = True
94+
95+
@staticmethod
96+
def import_list(imported_packages):
97+
for package in imported_packages:
98+
if PackagesStore.get_package(package["name"]):
99+
continue
100+
global packages
101+
packages[package["name"]] = package

0 commit comments

Comments
 (0)