projects ordering in KiwiCommand.run
This commit is contained in:
parent
ff8df05708
commit
61cbfb40d9
2 changed files with 21 additions and 9 deletions
|
@ -105,11 +105,7 @@ class KiwiCommand:
|
|||
|
||||
_logger.debug(f"{instance.directory!r}: {project_names!r}, {service_names!r}")
|
||||
|
||||
projects = [
|
||||
project
|
||||
for project in instance.projects
|
||||
if project.name in project_names
|
||||
]
|
||||
projects = instance.get_projects(project_names)
|
||||
|
||||
if not projects:
|
||||
# run for whole instance
|
||||
|
@ -118,7 +114,7 @@ class KiwiCommand:
|
|||
|
||||
elif not service_names:
|
||||
# run for entire project(s)
|
||||
for project_name, project in zip(project_names, projects):
|
||||
for project_name, project in projects.items():
|
||||
if project is None:
|
||||
_logger.debug(f"running for new project {project_name}, kwargs={kwargs}")
|
||||
cls.run_for_new_project(instance, project_name, **kwargs)
|
||||
|
@ -133,8 +129,8 @@ class KiwiCommand:
|
|||
|
||||
else:
|
||||
# run for some services
|
||||
project_name = project_names[0]
|
||||
project = projects[0]
|
||||
project_name = list(projects)[0]
|
||||
project = projects[project_name]
|
||||
|
||||
if project is None:
|
||||
cls.print_error(f"Project '{project_name}' not in kiwi-scp instance at '{instance.directory}'!")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from pathlib import Path
|
||||
from typing import Generator
|
||||
from typing import Generator, Dict, Sequence
|
||||
|
||||
import attr
|
||||
|
||||
|
@ -24,3 +24,19 @@ class Instance:
|
|||
directory=self.directory.joinpath(project.name),
|
||||
parent=self,
|
||||
)
|
||||
|
||||
def get_projects(self, project_names: Sequence[str]) -> Dict[str, Project]:
|
||||
existing_projects = {
|
||||
project.name: project
|
||||
for project in self.projects
|
||||
if project.name in project_names
|
||||
}
|
||||
nonexistent_projects = {
|
||||
name: None
|
||||
for name in project_names
|
||||
if name not in existing_projects
|
||||
}
|
||||
return {
|
||||
**existing_projects,
|
||||
**nonexistent_projects
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue