notion-cascade-insert 0.0.7__py3-none-any.whl → 0.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- notion_cascade_insert/_modidx.py +19 -20
- notion_cascade_insert/core.py +10 -21
- {notion_cascade_insert-0.0.7.dist-info → notion_cascade_insert-0.0.8.dist-info}/METADATA +1 -1
- notion_cascade_insert-0.0.8.dist-info/RECORD +10 -0
- notion_cascade_insert-0.0.7.dist-info/RECORD +0 -10
- {notion_cascade_insert-0.0.7.dist-info → notion_cascade_insert-0.0.8.dist-info}/WHEEL +0 -0
- {notion_cascade_insert-0.0.7.dist-info → notion_cascade_insert-0.0.8.dist-info}/entry_points.txt +0 -0
- {notion_cascade_insert-0.0.7.dist-info → notion_cascade_insert-0.0.8.dist-info}/licenses/LICENSE +0 -0
- {notion_cascade_insert-0.0.7.dist-info → notion_cascade_insert-0.0.8.dist-info}/top_level.txt +0 -0
notion_cascade_insert/_modidx.py
CHANGED
|
@@ -5,42 +5,41 @@ d = { 'settings': { 'branch': 'main',
|
|
|
5
5
|
'doc_host': 'https://amezaikupan.github.io',
|
|
6
6
|
'git_url': 'https://github.com/amezaikupan/notion_cascade_insert',
|
|
7
7
|
'lib_path': 'notion_cascade_insert'},
|
|
8
|
-
'syms': { 'notion_cascade_insert.core': { 'notion_cascade_insert.core.AutoLogger': ( '
|
|
8
|
+
'syms': { 'notion_cascade_insert.core': { 'notion_cascade_insert.core.AutoLogger': ( 'core.html#autologger',
|
|
9
9
|
'notion_cascade_insert/core.py'),
|
|
10
|
-
'notion_cascade_insert.core.AutoLogger.__init__': ( '
|
|
10
|
+
'notion_cascade_insert.core.AutoLogger.__init__': ( 'core.html#autologger.__init__',
|
|
11
11
|
'notion_cascade_insert/core.py'),
|
|
12
|
-
'notion_cascade_insert.core.AutoLogger.handle_update': ( '
|
|
12
|
+
'notion_cascade_insert.core.AutoLogger.handle_update': ( 'core.html#autologger.handle_update',
|
|
13
13
|
'notion_cascade_insert/core.py'),
|
|
14
|
-
'notion_cascade_insert.core.AutoLogger.process': ( '
|
|
14
|
+
'notion_cascade_insert.core.AutoLogger.process': ( 'core.html#autologger.process',
|
|
15
15
|
'notion_cascade_insert/core.py'),
|
|
16
|
-
'notion_cascade_insert.core.AutoLogger.undo_all': ( '
|
|
16
|
+
'notion_cascade_insert.core.AutoLogger.undo_all': ( 'core.html#autologger.undo_all',
|
|
17
17
|
'notion_cascade_insert/core.py'),
|
|
18
|
-
'notion_cascade_insert.core.Database': (
|
|
19
|
-
|
|
20
|
-
'notion_cascade_insert.core.Database.__init__': ( 'core_dup1.html#database.__init__',
|
|
18
|
+
'notion_cascade_insert.core.Database': ('core.html#database', 'notion_cascade_insert/core.py'),
|
|
19
|
+
'notion_cascade_insert.core.Database.__init__': ( 'core.html#database.__init__',
|
|
21
20
|
'notion_cascade_insert/core.py'),
|
|
22
|
-
'notion_cascade_insert.core.Database.check_db_exists': ( '
|
|
21
|
+
'notion_cascade_insert.core.Database.check_db_exists': ( 'core.html#database.check_db_exists',
|
|
23
22
|
'notion_cascade_insert/core.py'),
|
|
24
|
-
'notion_cascade_insert.core.Database.get_data_source_schema': ( '
|
|
23
|
+
'notion_cascade_insert.core.Database.get_data_source_schema': ( 'core.html#database.get_data_source_schema',
|
|
25
24
|
'notion_cascade_insert/core.py'),
|
|
26
|
-
'notion_cascade_insert.core.JunctionDB': ( '
|
|
25
|
+
'notion_cascade_insert.core.JunctionDB': ( 'core.html#junctiondb',
|
|
27
26
|
'notion_cascade_insert/core.py'),
|
|
28
|
-
'notion_cascade_insert.core.JunctionDB.__init__': ( '
|
|
27
|
+
'notion_cascade_insert.core.JunctionDB.__init__': ( 'core.html#junctiondb.__init__',
|
|
29
28
|
'notion_cascade_insert/core.py'),
|
|
30
|
-
'notion_cascade_insert.core.JunctionDB.get_items': ( '
|
|
29
|
+
'notion_cascade_insert.core.JunctionDB.get_items': ( 'core.html#junctiondb.get_items',
|
|
31
30
|
'notion_cascade_insert/core.py'),
|
|
32
|
-
'notion_cascade_insert.core.LogDB': ('
|
|
33
|
-
'notion_cascade_insert.core.LogDB.__init__': ( '
|
|
31
|
+
'notion_cascade_insert.core.LogDB': ('core.html#logdb', 'notion_cascade_insert/core.py'),
|
|
32
|
+
'notion_cascade_insert.core.LogDB.__init__': ( 'core.html#logdb.__init__',
|
|
34
33
|
'notion_cascade_insert/core.py'),
|
|
35
|
-
'notion_cascade_insert.core.LogDB.create_entry': ( '
|
|
34
|
+
'notion_cascade_insert.core.LogDB.create_entry': ( 'core.html#logdb.create_entry',
|
|
36
35
|
'notion_cascade_insert/core.py'),
|
|
37
|
-
'notion_cascade_insert.core.LogDB.get_entries_for_trigger': ( '
|
|
36
|
+
'notion_cascade_insert.core.LogDB.get_entries_for_trigger': ( 'core.html#logdb.get_entries_for_trigger',
|
|
38
37
|
'notion_cascade_insert/core.py'),
|
|
39
|
-
'notion_cascade_insert.core.TriggerDB': ( '
|
|
38
|
+
'notion_cascade_insert.core.TriggerDB': ( 'core.html#triggerdb',
|
|
40
39
|
'notion_cascade_insert/core.py'),
|
|
41
|
-
'notion_cascade_insert.core.TriggerDB.__init__': ( '
|
|
40
|
+
'notion_cascade_insert.core.TriggerDB.__init__': ( 'core.html#triggerdb.__init__',
|
|
42
41
|
'notion_cascade_insert/core.py'),
|
|
43
|
-
'notion_cascade_insert.core.TriggerDB.get_page_data': ( '
|
|
42
|
+
'notion_cascade_insert.core.TriggerDB.get_page_data': ( 'core.html#triggerdb.get_page_data',
|
|
44
43
|
'notion_cascade_insert/core.py')},
|
|
45
44
|
'notion_cascade_insert.webhook': { 'notion_cascade_insert.webhook.NotionWebhook': ( 'webhook.html#notionwebhook',
|
|
46
45
|
'notion_cascade_insert/webhook.py'),
|
notion_cascade_insert/core.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"""Notion Automation for multiple page creation"""
|
|
2
2
|
|
|
3
|
-
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/
|
|
3
|
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
|
4
4
|
|
|
5
5
|
# %% auto #0
|
|
6
6
|
__all__ = ['Database', 'TriggerDB', 'JunctionDB', 'LogDB', 'AutoLogger']
|
|
7
7
|
|
|
8
|
-
# %% ../nbs/
|
|
8
|
+
# %% ../nbs/00_core.ipynb #6211d16e
|
|
9
9
|
from fastcore.basics import patch
|
|
10
10
|
|
|
11
|
-
# %% ../nbs/
|
|
11
|
+
# %% ../nbs/00_core.ipynb #68712bbc
|
|
12
12
|
class Database:
|
|
13
13
|
"""Base class for interacting with a Notion database."""
|
|
14
14
|
def __init__(self,
|
|
@@ -40,7 +40,7 @@ class Database:
|
|
|
40
40
|
print(f"✗ Database not found: {e}")
|
|
41
41
|
return False
|
|
42
42
|
|
|
43
|
-
# %% ../nbs/
|
|
43
|
+
# %% ../nbs/00_core.ipynb #52b04240
|
|
44
44
|
class TriggerDB(Database):
|
|
45
45
|
"""
|
|
46
46
|
Database that triggers logging when updated.
|
|
@@ -52,7 +52,6 @@ class TriggerDB(Database):
|
|
|
52
52
|
status_prop, # Name of status property
|
|
53
53
|
relation_prop, # Name of relation property
|
|
54
54
|
qty_prop, # Name of the quantity property
|
|
55
|
-
buf_qty_prop = None # Name of the quantity buffer
|
|
56
55
|
):
|
|
57
56
|
"""Initialize a TriggerDB instance.
|
|
58
57
|
"""
|
|
@@ -60,7 +59,6 @@ class TriggerDB(Database):
|
|
|
60
59
|
self.status_prop = status_prop
|
|
61
60
|
self.relation_prop = relation_prop
|
|
62
61
|
self.qty_prop = qty_prop
|
|
63
|
-
self.buf_qty_prop = buf_qty_prop
|
|
64
62
|
|
|
65
63
|
#| exec_doc
|
|
66
64
|
def get_page_data(self,
|
|
@@ -78,14 +76,9 @@ class TriggerDB(Database):
|
|
|
78
76
|
# In case the quantity is a formula
|
|
79
77
|
qty = page['properties'][self.qty_prop]['formula']['number']
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
buf_qty = page['properties'][self.buf_qty_prop]['number']
|
|
83
|
-
else:
|
|
84
|
-
buf_qty = None
|
|
79
|
+
return status, relation_id, qty
|
|
85
80
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
# %% ../nbs/00_core_dup1.ipynb #82d6f2e9
|
|
81
|
+
# %% ../nbs/00_core.ipynb #82d6f2e9
|
|
89
82
|
class JunctionDB(Database):
|
|
90
83
|
"""Database that connects trigger items to log items with amounts.
|
|
91
84
|
|
|
@@ -148,7 +141,7 @@ class LogDB(Database):
|
|
|
148
141
|
|
|
149
142
|
|
|
150
143
|
|
|
151
|
-
# %% ../nbs/
|
|
144
|
+
# %% ../nbs/00_core.ipynb #b5e31e9a
|
|
152
145
|
class AutoLogger:
|
|
153
146
|
"""Orchestrates automatic logging from trigger to log via junction.
|
|
154
147
|
|
|
@@ -170,25 +163,21 @@ class AutoLogger:
|
|
|
170
163
|
reason:str # Reason for log entry
|
|
171
164
|
):
|
|
172
165
|
"""Process a trigger page and create log entries."""
|
|
173
|
-
status, relation_id, qty
|
|
174
|
-
|
|
175
|
-
if buf_qty is not None:
|
|
176
|
-
qty = qty + buf_qty
|
|
177
|
-
|
|
166
|
+
status, relation_id, qty = self.trigger_db.get_page_data(page_id)
|
|
178
167
|
if status != self.trigger_status: return f"Status is {status}, not {self.trigger_status}"
|
|
179
168
|
items = self.junction_db.get_items(relation_id)
|
|
180
169
|
if not items: return "No items found in junction"
|
|
181
170
|
for item_id, amt in items.items(): self.log_db.create_entry(item_id, self.multiplier * qty * amt, page_id, reason)
|
|
182
171
|
return f"Logged {len(items)} items"
|
|
183
172
|
|
|
184
|
-
# %% ../nbs/
|
|
173
|
+
# %% ../nbs/00_core.ipynb #e56edb4d
|
|
185
174
|
@patch
|
|
186
175
|
def get_entries_for_trigger(self:LogDB, trigger_page_id):
|
|
187
176
|
"Find all log entries linked to a specific trigger page"
|
|
188
177
|
results = self.notion.data_sources.query(data_source_id=self.data_source_id, filter={"property": self.trigger_prop, "relation": {"contains": trigger_page_id}})
|
|
189
178
|
return [(p['id'], p['properties'][self.item_prop]['relation'][0]['id'], p['properties'][self.amount_prop]['number']) for p in results['results']]
|
|
190
179
|
|
|
191
|
-
# %% ../nbs/
|
|
180
|
+
# %% ../nbs/00_core.ipynb #ae4afffa
|
|
192
181
|
@patch
|
|
193
182
|
def undo_all(self:AutoLogger, page_id, reason='Undo Changes'):
|
|
194
183
|
"Reverse all existing log entries for a trigger page"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
notion_cascade_insert/__init__.py,sha256=5xwqLdMZM_ZnPsqMkiL2IvhkKWd4s63fu7gJpmDQlH8,322
|
|
2
|
+
notion_cascade_insert/_modidx.py,sha256=VAD0TLHCIbcd5a8Fgr378dXyw_shDAl2ss-GM4_4LMc,6140
|
|
3
|
+
notion_cascade_insert/core.py,sha256=jepyX4iC-2F3FxDqnXge4uvV4oxrtIcsLHYQG84ec6Y,8395
|
|
4
|
+
notion_cascade_insert/webhook.py,sha256=myE6iRY232Zd2uBSfuepPcIPm4mopEYWmFzvfaWxF30,1214
|
|
5
|
+
notion_cascade_insert-0.0.8.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
|
|
6
|
+
notion_cascade_insert-0.0.8.dist-info/METADATA,sha256=41pAhYAZvMJwtMj08Ms1j2iRaTcNDPDLNDLEiZ5Eguk,3724
|
|
7
|
+
notion_cascade_insert-0.0.8.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
+
notion_cascade_insert-0.0.8.dist-info/entry_points.txt,sha256=XqKv0P7bGQlZ7SqZcyTdvIaQJI8GlMHtcJP9NPOhQbA,64
|
|
9
|
+
notion_cascade_insert-0.0.8.dist-info/top_level.txt,sha256=XRld1ok2pAh3DC9o3ZByqlORHGblJMVMOjE0pQRROE4,22
|
|
10
|
+
notion_cascade_insert-0.0.8.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
notion_cascade_insert/__init__.py,sha256=5xwqLdMZM_ZnPsqMkiL2IvhkKWd4s63fu7gJpmDQlH8,322
|
|
2
|
-
notion_cascade_insert/_modidx.py,sha256=yCG8Vl2PMLbKROgIahT3gclRbM9EzbRmJjF_MG8Dxwc,6321
|
|
3
|
-
notion_cascade_insert/core.py,sha256=DCPZB0OPZqiJeAgmTt4oCi4BUialSTdt2SiDLLjJGkM,8785
|
|
4
|
-
notion_cascade_insert/webhook.py,sha256=myE6iRY232Zd2uBSfuepPcIPm4mopEYWmFzvfaWxF30,1214
|
|
5
|
-
notion_cascade_insert-0.0.7.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
|
|
6
|
-
notion_cascade_insert-0.0.7.dist-info/METADATA,sha256=cht_LS29ndurvVBsIckmZZv9xE5s-CQTznxHq2V0Xwo,3724
|
|
7
|
-
notion_cascade_insert-0.0.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
-
notion_cascade_insert-0.0.7.dist-info/entry_points.txt,sha256=XqKv0P7bGQlZ7SqZcyTdvIaQJI8GlMHtcJP9NPOhQbA,64
|
|
9
|
-
notion_cascade_insert-0.0.7.dist-info/top_level.txt,sha256=XRld1ok2pAh3DC9o3ZByqlORHGblJMVMOjE0pQRROE4,22
|
|
10
|
-
notion_cascade_insert-0.0.7.dist-info/RECORD,,
|
|
File without changes
|
{notion_cascade_insert-0.0.7.dist-info → notion_cascade_insert-0.0.8.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{notion_cascade_insert-0.0.7.dist-info → notion_cascade_insert-0.0.8.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{notion_cascade_insert-0.0.7.dist-info → notion_cascade_insert-0.0.8.dist-info}/top_level.txt
RENAMED
|
File without changes
|