diff options
author | Jelle Spijker <spijker.jelle@gmail.com> | 2021-12-05 18:23:23 +0300 |
---|---|---|
committer | Jelle Spijker <spijker.jelle@gmail.com> | 2021-12-05 18:23:23 +0300 |
commit | 305fb4ab09b6cfec6f930ead99240bf060a4d8c9 (patch) | |
tree | ff3ef77ea1cee0969b82c76644eb15c77e0ae7c7 | |
parent | bd2f2708034bddaf11a81e6775a1d21942b09f5f (diff) |
renamed locally_installed property
Contributes to: CURA-8587
-rw-r--r-- | cura/CuraPackageManager.py | 20 | ||||
-rw-r--r-- | plugins/Marketplace/LocalPackageList.py | 5 | ||||
-rw-r--r-- | plugins/Marketplace/RemotePackageList.py | 4 |
3 files changed, 13 insertions, 16 deletions
diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index 21cd0c69dc..4250af9072 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -19,22 +19,18 @@ if TYPE_CHECKING: class CuraPackageManager(PackageManager): def __init__(self, application: "QtApplication", parent: Optional["QObject"] = None) -> None: super().__init__(application, parent) - self._locally_installed_packages = None - self.installedPackagesChanged.connect(self._updateLocallyInstalledPackages) + self._local_packages: Optional[List[Dict[str, Any]]] = None + self.installedPackagesChanged.connect(self._updateLocalPackages) - def _updateLocallyInstalledPackages(self): - self._locally_installed_packages = self.getAllLocalPackages() + def _updateLocalPackages(self) -> None: + self._local_packages = self.getAllLocalPackages() @property - def locally_installed_packages(self): + def local_packages(self) -> List[Dict[str, Any]]: """locally installed packages, lazy execution""" - if self._locally_installed_packages is None: - self._updateLocallyInstalledPackages() - return self._locally_installed_packages - - @locally_installed_packages.setter - def locally_installed_packages(self, value): - self._locally_installed_packages = value + if self._local_packages is None: + self._updateLocalPackages() + return self._local_packages def initialize(self) -> None: self._installation_dirs_dict["materials"] = Resources.getStoragePath(CuraApplication.ResourceTypes.MaterialInstanceContainer) diff --git a/plugins/Marketplace/LocalPackageList.py b/plugins/Marketplace/LocalPackageList.py index 284f51c806..6bd22ee918 100644 --- a/plugins/Marketplace/LocalPackageList.py +++ b/plugins/Marketplace/LocalPackageList.py @@ -48,9 +48,10 @@ class LocalPackageList(PackageList): self.setIsLoading(True) # Obtain and sort the local packages - self.setItems([{"package": p} for p in [self._makePackageModel(p) for p in self._manager.locally_installed_packages]]) + Logger.debug(f"Number of local packages: {len(self._manager.local_packages)} -> {[p['package_id'] for p in self._manager.local_packages]}") + self.setItems([{"package": p} for p in [self._makePackageModel(p) for p in self._manager.local_packages]]) self.sort(attrgetter("sectionTitle", "canUpdate", "displayName"), key = "package", reverse = True) - self.checkForUpdates(self._manager.locally_installed_packages) + self.checkForUpdates(self._manager.local_packages) self.setIsLoading(False) self.setHasMore(False) # All packages should have been loaded at this time diff --git a/plugins/Marketplace/RemotePackageList.py b/plugins/Marketplace/RemotePackageList.py index fa05ca9526..a994d3d2d2 100644 --- a/plugins/Marketplace/RemotePackageList.py +++ b/plugins/Marketplace/RemotePackageList.py @@ -31,7 +31,7 @@ class RemotePackageList(PackageList): self._request_url = self._initialRequestUrl() self.isLoadingChanged.connect(self._onLoadingChanged) self.isLoadingChanged.emit() - self._locally_installed: Set[str] = { p["package_id"] for p in self._manager.locally_installed_packages } + self._local_packages: Set[str] = { p["package_id"] for p in self._manager.local_packages } def __del__(self) -> None: """ @@ -129,7 +129,7 @@ class RemotePackageList(PackageList): return for package_data in response_data["data"]: - if package_data["package_id"] in self._locally_installed: + if package_data["package_id"] in self._local_packages: continue # We should only show packages which are not already installed try: package = PackageModel(package_data, parent = self) |