23 lines
710 B
Python
23 lines
710 B
Python
class ChangeSet:
|
|
def __init__(self):
|
|
self.operations : list[dict[str, str]] = []
|
|
|
|
def add(self, type: str, id: str):
|
|
self.operations.append({ 'operation': 'add', 'type': type, 'id': id })
|
|
return self
|
|
|
|
def delete(self, type: str, id: str):
|
|
self.operations.append({ 'operation': 'delete', 'type': type, 'id': id })
|
|
return self
|
|
|
|
def update(self, type: str, id: str, properties: list[str]):
|
|
self.operations.append({ 'operation': 'update', 'type': type, 'id': id, 'properties': properties })
|
|
return self
|
|
|
|
def append(self, other):
|
|
self.operations += other.operations
|
|
return self
|
|
|
|
def compress(self):
|
|
return self
|