From 40e476ba7b92a1ca6f8e11189fc34005a6954b32 Mon Sep 17 00:00:00 2001 From: ldericher Date: Thu, 20 Aug 2020 15:08:41 +0200 Subject: [PATCH] QoL: Projects default bool conversion (nonempty) --- src/kiwi/projects.py | 6 +++--- src/kiwi/subcommand.py | 2 +- src/kiwi/subcommands/inspect.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kiwi/projects.py b/src/kiwi/projects.py index 65c75d0..620fc81 100644 --- a/src/kiwi/projects.py +++ b/src/kiwi/projects.py @@ -16,6 +16,9 @@ class Projects: in self.__projects ]) + def __bool__(self): + return bool(self.__projects) + @classmethod def from_names(cls, project_names): result = cls() @@ -52,9 +55,6 @@ class Projects: return cls() - def empty(self): - return not self.__projects - def filter_exists(self): result = Projects() result.__projects = [ diff --git a/src/kiwi/subcommand.py b/src/kiwi/subcommand.py index fb472ff..150a222 100644 --- a/src/kiwi/subcommand.py +++ b/src/kiwi/subcommand.py @@ -70,7 +70,7 @@ class ProjectCommand(SubCommand): def run(self, runner, args): projects = Projects.from_args(args) - if not projects.empty(): + if projects: # project(s) given logging.info(f"{self._action} projects {projects}") return self._run_projects(runner, args, projects) diff --git a/src/kiwi/subcommands/inspect.py b/src/kiwi/subcommands/inspect.py index ae679f1..1a36b03 100644 --- a/src/kiwi/subcommands/inspect.py +++ b/src/kiwi/subcommands/inspect.py @@ -40,12 +40,12 @@ class InspectCommand(ServiceCommand): projects = Projects.from_dir() enabled_projects = projects.filter_enabled() - if not enabled_projects.empty(): + if enabled_projects: print(f"Enabled projects:") _print_list(enabled_projects) disabled_projects = projects.filter_disabled() - if not disabled_projects.empty(): + if disabled_projects: print(f"Disabled projects:") _print_list(disabled_projects)