diff --git a/bauh/api/abstract/model.py b/bauh/api/abstract/model.py index 1ac0008d..c9e8cce6 100644 --- a/bauh/api/abstract/model.py +++ b/bauh/api/abstract/model.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod from enum import Enum -from typing import List, Optional +from typing import List, Optional, Iterable from bauh.api.paths import CACHE_DIR @@ -202,7 +202,7 @@ class SoftwarePackage(ABC): """ pass - def get_custom_supported_actions(self) -> List[CustomSoftwareAction]: + def get_custom_actions(self) -> Optional[Iterable[CustomSoftwareAction]]: """ :return: custom supported actions """ diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index 3cef194d..6173b828 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -79,12 +79,12 @@ class AppImageManager(SoftwareManager): self.file_downloader = context.file_downloader self.configman = AppImageConfigManager() self._custom_actions: Optional[Iterable[CustomSoftwareAction]] = None - self.custom_app_actions = [CustomSoftwareAction(i18n_label_key='appimage.custom_action.manual_update', + self.custom_app_actions = (CustomSoftwareAction(i18n_label_key='appimage.custom_action.manual_update', i18n_status_key='appimage.custom_action.manual_update.status', manager_method='update_file', requires_root=False, icon_path=resource.get_path('img/upgrade.svg', ROOT_DIR), - requires_confirmation=False)] + requires_confirmation=False),) def install_file(self, root_password: str, watcher: ProcessWatcher) -> bool: file_chooser = FileChooserComponent(label=self.i18n['file'].capitalize(), diff --git a/bauh/gems/appimage/model.py b/bauh/gems/appimage/model.py index 9da6041a..985f6176 100644 --- a/bauh/gems/appimage/model.py +++ b/bauh/gems/appimage/model.py @@ -1,6 +1,6 @@ import re from io import StringIO -from typing import List, Optional +from typing import List, Optional, Iterable from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction from bauh.commons import resource @@ -19,7 +19,7 @@ class AppImage(SoftwarePackage): url_download: str = None, url_icon: str = None, url_screenshot: str = None, license: str = None, author: str = None, categories=None, icon_path: str = None, installed: bool = False, url_download_latest_version: str = None, local_file_path: str = None, imported: bool = False, - i18n: I18n = None, install_dir: str = None, custom_actions: List[CustomSoftwareAction] = None, updates_ignored: bool = False, + i18n: I18n = None, install_dir: str = None, custom_actions: Optional[Iterable[CustomSoftwareAction]] = None, updates_ignored: bool = False, symlink: str = None, **kwargs): super(AppImage, self).__init__(id=name, name=name, version=version, latest_version=version, icon_url=url_icon, license=license, description=description, @@ -108,7 +108,7 @@ class AppImage(SoftwarePackage): return self.name - def get_custom_supported_actions(self) -> List[CustomSoftwareAction]: + def get_custom_actions(self) -> Optional[Iterable[CustomSoftwareAction]]: if self.imported: return self.custom_actions diff --git a/bauh/gems/arch/model.py b/bauh/gems/arch/model.py index 6c628e49..c0c24808 100644 --- a/bauh/gems/arch/model.py +++ b/bauh/gems/arch/model.py @@ -1,4 +1,4 @@ -from typing import List, Set, Optional +from typing import List, Set, Optional, Iterable from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction from bauh.commons import resource @@ -200,7 +200,7 @@ class ArchPackage(SoftwarePackage): def get_cached_pkgbuild_path(self) -> str: return '{}/PKGBUILD'.format(self.get_disk_cache_path()) - def get_custom_supported_actions(self) -> List[CustomSoftwareAction]: + def get_custom_actions(self) -> Optional[Iterable[CustomSoftwareAction]]: if self.installed and self.repository == 'aur': actions = [ACTION_AUR_REINSTALL] diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index d1e60a73..eaba7086 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -43,7 +43,7 @@ class SnapManager(SoftwareManager): self.suggestions_cache = context.cache_factory.new() self.info_path = None self.configman = SnapConfigManager() - self.custom_actions = [ + self.custom_actions = ( CustomSoftwareAction(i18n_status_key='snap.action.refresh.status', i18n_label_key='snap.action.refresh.label', icon_path=resource.get_path('img/refresh.svg', ROOT_DIR), @@ -57,7 +57,7 @@ class SnapManager(SoftwareManager): manager_method='change_channel', requires_root=True, requires_confirmation=False) - ] + ) def _fill_categories(self, app: SnapApplication): categories = self.categories.get(app.name.lower()) diff --git a/bauh/gems/snap/model.py b/bauh/gems/snap/model.py index d873b54e..75a5a73b 100644 --- a/bauh/gems/snap/model.py +++ b/bauh/gems/snap/model.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Set +from typing import Optional, Set, Iterable from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction from bauh.commons import resource @@ -10,7 +10,7 @@ class SnapApplication(SoftwarePackage): def __init__(self, id: str = None, name: str = None, version: str = None, latest_version: str = None, description: str = None, publisher: str = None, rev: str = None, notes: str = None, confinement: str = None, verified_publisher: bool = False, - extra_actions: List[CustomSoftwareAction] = None, + extra_actions: Optional[Iterable[CustomSoftwareAction]] = None, screenshots: Optional[Set[str]] = None, license: Optional[str] = None, installed: bool = False, @@ -92,7 +92,7 @@ class SnapApplication(SoftwarePackage): def get_publisher(self): return self.publisher - def get_custom_supported_actions(self) -> List[CustomSoftwareAction]: + def get_custom_actions(self) -> Optional[Iterable[CustomSoftwareAction]]: if self.installed: return self.extra_actions diff --git a/bauh/view/qt/apps_table.py b/bauh/view/qt/apps_table.py index 76359d12..88fc73ad 100644 --- a/bauh/view/qt/apps_table.py +++ b/bauh/view/qt/apps_table.py @@ -104,7 +104,7 @@ class PackagesTable(QTableWidget): return pkg.model.has_history() or \ pkg.model.can_be_downgraded() or \ pkg.model.supports_ignored_updates() or \ - bool(pkg.model.get_custom_supported_actions()) + bool(pkg.model.get_custom_actions()) def show_pkg_actions(self, pkg: PackageView): menu_row = QMenu() @@ -154,8 +154,8 @@ class PackagesTable(QTableWidget): button_name=button_name, action=ignore_updates)) - if bool(pkg.model.get_custom_supported_actions()): - actions = [self._map_custom_action(pkg, a, menu_row) for a in pkg.model.get_custom_supported_actions()] + if bool(pkg.model.get_custom_actions()): + actions = [self._map_custom_action(pkg, a, menu_row) for a in pkg.model.get_custom_actions()] menu_row.addActions(actions) menu_row.adjustSize()