From ddf5f7ce811ea524eff74216ebd45848e0dfb20e Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 17 Sep 2019 15:28:30 -0300 Subject: [PATCH] refactoring Snap application check --- bauh/gems/snap/model.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bauh/gems/snap/model.py b/bauh/gems/snap/model.py index 730c6fb9..8522dcb0 100644 --- a/bauh/gems/snap/model.py +++ b/bauh/gems/snap/model.py @@ -13,6 +13,10 @@ EXTRA_INSTALLED_ACTIONS = [ requires_root=True) ] +KNOWN_RUNTIME_NAMES = {'snapd', 'core', 'core18'} +KNOWN_RUNTIME_PREFIXES = {'gtk-', 'gnome-', 'kde-', 'gtk2-'} +KNOWN_RUNTIME_TYPES = {'base', 'core', 'os'} + class SnapApplication(SoftwarePackage): @@ -46,9 +50,9 @@ class SnapApplication(SoftwarePackage): return self.get_default_icon_path() def is_application(self): - return not self.type and (self.name != 'snapd' and self.type not in ('core', 'base', 'os') and not self._name_starts_with(('gtk-', 'gnome-', 'kde-', 'gtk2-'))) + return not self.type and (self.name not in KNOWN_RUNTIME_NAMES and self.type not in KNOWN_RUNTIME_TYPES and not self._name_starts_with(KNOWN_RUNTIME_PREFIXES)) - def _name_starts_with(self, words: tuple): + def _name_starts_with(self, words: set): for word in words: if self.name.startswith(word): return True