Update the Source to BackupPlan component and shared.

This commit is contained in:
2025-01-05 19:27:24 +02:00
parent c67dc14003
commit 594d9dea3f
50 changed files with 80 additions and 1329 deletions
View File
@@ -0,0 +1,4 @@
from .entities import BackupPlan
from .value_objects import BackupPlanId, Path, Source, Destination
__all__ = ['BackupPlan', 'BackupPlanId', 'Path', 'Source', 'Destination']
@@ -0,0 +1,3 @@
from .backup_plan import BackupPlan
__all__ = ['BackupPlan']
@@ -0,0 +1,14 @@
from dataclasses import dataclass, field
from typing import List
from ..value_objects import BackupPlanId, Source, Destination
from tui_rsync.core.shared_kernel.components.common.domain import Label
@dataclass
class BackupPlan:
source: Source
destinations: List[Destination]
id: BackupPlanId = field(default_factory=lambda: BackupPlanId.generate())
label: Label = field(default='')
@@ -0,0 +1,6 @@
from .backup_plan_id import BackupPlanId
from .path import Path
from .source import Source
from .destionation import Destination
__all__ = ['BackupPlanId', 'Path', 'Source', 'Destination']
@@ -0,0 +1,5 @@
from tui_rsync.core.shared_kernel.components.common.domain import UUID
class BackupPlanId(UUID):
pass
@@ -0,0 +1,5 @@
from .path import Path
class Destination(Path):
pass
@@ -0,0 +1,6 @@
from dataclasses import dataclass
@dataclass
class Path:
path: str
@@ -0,0 +1,5 @@
from .path import Path
class Source(Path):
pass
View File
@@ -0,0 +1,3 @@
from .domain import UUID, Label
__all__ = ['UUID', 'Label']
@@ -0,0 +1,3 @@
from .value_objects import UUID, Label
__all__ = ['UUID', 'Label']
@@ -0,0 +1,4 @@
from .uuid import UUID
from .label import Label
__all__ = ['UUID', 'Label']
@@ -0,0 +1,6 @@
from dataclasses import dataclass, field
@dataclass(frozen=True)
class Label:
label: str = field(default='')
@@ -0,0 +1,14 @@
from dataclasses import dataclass, field
import uuid
@dataclass(frozen=True)
class UUID:
id: str = field(default_factory=lambda: UUID.generate().id)
@classmethod
def generate(cls) -> 'UUID':
return cls(str(uuid.uuid4()))
def __str__(self):
return self.id