mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-12 17:57:43 +00:00
(Added) sync group function.
This commit is contained in:
@@ -109,6 +109,16 @@ class Destination(BaseModel):
|
||||
class Group(BaseModel):
|
||||
label = CharField(unique=True)
|
||||
|
||||
@staticmethod
|
||||
def is_exist(label) -> bool:
|
||||
return Group.select().where(Group.label == label).exists()
|
||||
|
||||
@staticmethod
|
||||
def get_group(label):
|
||||
if not Group.is_exist(label):
|
||||
return None
|
||||
return Group.select().where(Group.label == label).get()
|
||||
|
||||
@staticmethod
|
||||
def create_save(label:str, source_labels:list[str]):
|
||||
group = Group.create(
|
||||
@@ -122,6 +132,12 @@ class Group(BaseModel):
|
||||
group.save()
|
||||
return group
|
||||
|
||||
def get_sources(self):
|
||||
"""
|
||||
Return iterator of the group sources.
|
||||
"""
|
||||
return (group_src.source for group_src in self.sources)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.label}"
|
||||
|
||||
@@ -144,6 +160,10 @@ def create_tables():
|
||||
]
|
||||
db.create_tables(tables, safe=True)
|
||||
|
||||
def all_group_labels():
|
||||
with db:
|
||||
return Group.select(Group.label)
|
||||
|
||||
def all_labels():
|
||||
with db:
|
||||
return Source.select(Source.label)
|
||||
|
||||
Reference in New Issue
Block a user