2021-10-22 15:50:26 +00:00
|
|
|
from pathlib import Path
|
2021-12-02 16:08:14 +00:00
|
|
|
from typing import Generator
|
2021-10-22 15:50:26 +00:00
|
|
|
|
|
|
|
import attr
|
|
|
|
|
2021-12-02 16:08:14 +00:00
|
|
|
from .config import KiwiConfig
|
|
|
|
from .project import Project
|
2021-11-03 15:32:01 +00:00
|
|
|
|
|
|
|
|
2021-12-02 15:01:19 +00:00
|
|
|
@attr.s
|
2021-11-03 15:32:01 +00:00
|
|
|
class Instance:
|
|
|
|
directory: Path = attr.ib(default=Path('.'))
|
|
|
|
|
|
|
|
@property
|
|
|
|
def config(self) -> KiwiConfig:
|
|
|
|
"""shorthand: get the current configuration"""
|
|
|
|
|
|
|
|
return KiwiConfig.from_directory(self.directory)
|
|
|
|
|
2021-12-02 15:01:19 +00:00
|
|
|
@property
|
|
|
|
def projects(self) -> Generator[Project, None, None]:
|
2021-12-02 01:38:29 +00:00
|
|
|
for project in self.config.projects:
|
2021-12-02 15:01:19 +00:00
|
|
|
yield Project(
|
|
|
|
directory=self.directory.joinpath(project.name),
|
|
|
|
parent=self,
|
|
|
|
)
|