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
])
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 = [

View file

@ -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)

View file

@ -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)