-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclasses.py
36 lines (30 loc) · 1.02 KB
/
classes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from typing import Dict, List, Tuple, TypedDict, NamedTuple
from dataclasses import dataclass
Property = NamedTuple("Property", [("name", str), ("value", str)])
class Page(TypedDict):
"""Represents a Notion page
"""
page_id: str
created_time: str
last_edited_time: str
properties: Dict[str, Property]
url: str
class PropertyChange(TypedDict):
"""Represents a change in a property
"""
property_name: str
old_value: str
new_value: str
@dataclass
class ChangeSet():
"""Represents a set of changes between two dictionaries
"""
added: List[Page]
"""Pages that were added in the diff"""
removed: List[Page]
"""Pages that were removed in the diff"""
changed: List[Tuple[Page, List[PropertyChange]]]
"""Pages that had their properties changed in the diff. The key is the page id and the value is the list of
properties that were changed"""
def is_empty(self) -> bool:
return len(self.added) == 0 and len(self.removed) == 0 and len(self.changed) == 0