1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-22 04:43:00 +00:00

QoL: Projects default bool conversion (nonempty)

This commit is contained in:
Jörn-Michael Miehe 2020-08-20 15:08:41 +02:00
parent 4bd602a245
commit 40e476ba7b
3 changed files with 6 additions and 6 deletions

View file

@ -16,6 +16,9 @@ class Projects:
in self.__projects in self.__projects
]) ])
def __bool__(self):
return bool(self.__projects)
@classmethod @classmethod
def from_names(cls, project_names): def from_names(cls, project_names):
result = cls() result = cls()
@ -52,9 +55,6 @@ class Projects:
return cls() return cls()
def empty(self):
return not self.__projects
def filter_exists(self): def filter_exists(self):
result = Projects() result = Projects()
result.__projects = [ result.__projects = [

View file

@ -70,7 +70,7 @@ class ProjectCommand(SubCommand):
def run(self, runner, args): def run(self, runner, args):
projects = Projects.from_args(args) projects = Projects.from_args(args)
if not projects.empty(): if projects:
# project(s) given # project(s) given
logging.info(f"{self._action} projects {projects}") logging.info(f"{self._action} projects {projects}")
return self._run_projects(runner, args, projects) return self._run_projects(runner, args, projects)

View file

@ -40,12 +40,12 @@ class InspectCommand(ServiceCommand):
projects = Projects.from_dir() projects = Projects.from_dir()
enabled_projects = projects.filter_enabled() enabled_projects = projects.filter_enabled()
if not enabled_projects.empty(): if enabled_projects:
print(f"Enabled projects:") print(f"Enabled projects:")
_print_list(enabled_projects) _print_list(enabled_projects)
disabled_projects = projects.filter_disabled() disabled_projects = projects.filter_disabled()
if not disabled_projects.empty(): if disabled_projects:
print(f"Disabled projects:") print(f"Disabled projects:")
_print_list(disabled_projects) _print_list(disabled_projects)