notionary 0.2.18__py3-none-any.whl → 0.2.19__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.
- notionary/blocks/shared/models.py +3 -0
- notionary/elements/__init__.py +0 -0
- notionary/page/content/page_content_retriever.py +17 -9
- notionary/page/formatting/markdown_to_notion_converter.py +1 -1
- {notionary-0.2.18.dist-info → notionary-0.2.19.dist-info}/METADATA +1 -1
- {notionary-0.2.18.dist-info → notionary-0.2.19.dist-info}/RECORD +8 -7
- {notionary-0.2.18.dist-info → notionary-0.2.19.dist-info}/LICENSE +0 -0
- {notionary-0.2.18.dist-info → notionary-0.2.19.dist-info}/WHEEL +0 -0
@@ -29,6 +29,7 @@ BlockColor = Literal[
|
|
29
29
|
"purple_background",
|
30
30
|
"red",
|
31
31
|
"red_background",
|
32
|
+
"default_background"
|
32
33
|
]
|
33
34
|
|
34
35
|
BlockType = Literal[
|
@@ -577,6 +578,8 @@ class Block(BaseModel):
|
|
577
578
|
archived: bool = False
|
578
579
|
in_trash: bool = False
|
579
580
|
has_children: bool = False
|
581
|
+
|
582
|
+
children: Optional[list[Block]] = None # for recursive structure
|
580
583
|
|
581
584
|
# Block type-specific content (only one will be populated based on type)
|
582
585
|
audio: Optional[AudioBlock] = None
|
File without changes
|
@@ -1,8 +1,10 @@
|
|
1
|
+
import json
|
1
2
|
from typing import Any, Dict, Optional
|
2
3
|
|
3
4
|
from notionary.blocks.registry.block_registry import BlockRegistry
|
4
5
|
|
5
6
|
from notionary.blocks import NotionBlockClient
|
7
|
+
from notionary.blocks.shared.models import Block
|
6
8
|
from notionary.page.notion_to_markdown_converter import (
|
7
9
|
NotionToMarkdownConverter,
|
8
10
|
)
|
@@ -23,30 +25,36 @@ class PageContentRetriever(LoggingMixin):
|
|
23
25
|
|
24
26
|
async def get_page_content(self) -> str:
|
25
27
|
blocks = await self._get_page_blocks_with_children()
|
26
|
-
|
28
|
+
|
29
|
+
# TODO: Fix this quick fix🧯 Quick-Fix: Konvertiere rekursive Block-Objekte in plain dicts
|
30
|
+
blocks_as_dicts = [block.model_dump(mode="python", exclude_unset=True) for block in blocks]
|
31
|
+
|
32
|
+
return self._notion_to_markdown_converter.convert(blocks_as_dicts)
|
27
33
|
|
28
34
|
async def _get_page_blocks_with_children(
|
29
35
|
self, parent_id: Optional[str] = None
|
30
|
-
) -> list[
|
31
|
-
|
32
|
-
await self.client.
|
36
|
+
) -> list[Block]:
|
37
|
+
response = (
|
38
|
+
await self.client.get_block_children(block_id=self.page_id)
|
33
39
|
if parent_id is None
|
34
40
|
else await self.client.get_block_children(parent_id)
|
35
41
|
)
|
36
42
|
|
37
|
-
if not
|
43
|
+
if not response or not response.results:
|
38
44
|
return []
|
39
45
|
|
46
|
+
blocks = response.results
|
47
|
+
|
40
48
|
for block in blocks:
|
41
|
-
if not block.
|
49
|
+
if not block.has_children:
|
42
50
|
continue
|
43
51
|
|
44
|
-
block_id = block.
|
52
|
+
block_id = block.id
|
45
53
|
if not block_id:
|
46
54
|
continue
|
47
55
|
|
48
56
|
children = await self._get_page_blocks_with_children(block_id)
|
49
57
|
if children:
|
50
|
-
block
|
58
|
+
block.children = children
|
51
59
|
|
52
|
-
return blocks
|
60
|
+
return blocks
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from notionary.blocks import ColumnElement, BlockRegistry
|
2
2
|
from notionary.page.formatting.line_processor import LineProcessor
|
3
3
|
|
4
|
-
|
4
|
+
# TODO: Hier rekursiven Baum Parser verwenden!
|
5
5
|
class MarkdownToNotionConverter:
|
6
6
|
"""Clean converter focused on block identification and conversion"""
|
7
7
|
|
@@ -68,7 +68,7 @@ notionary/blocks/registry/block_registry.py,sha256=O0yo3B6QIZa-a6gClt_rzaxO_ijws
|
|
68
68
|
notionary/blocks/registry/block_registry_builder.py,sha256=r7wVIjvfCRZWby9RabX9zBSeH_BuoqrRNCl-8yHwt5I,6551
|
69
69
|
notionary/blocks/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
70
70
|
notionary/blocks/shared/block_client.py,sha256=EF2xYcrpJ2pF5LYSc9UNDw74Izf25gw5a05-P4CRmZE,8997
|
71
|
-
notionary/blocks/shared/models.py,sha256=
|
71
|
+
notionary/blocks/shared/models.py,sha256=lpLtDOLxpiEQzEYAroaLpCgjCn4XoInsVyJHK-bBcDE,18007
|
72
72
|
notionary/blocks/shared/notion_block_element.py,sha256=pKsGRPrSa_IqZHmer4HL5DCzFuhqo34vYXptXoXToX0,1443
|
73
73
|
notionary/blocks/shared/text_inline_formatter.py,sha256=mCqFS05oJwSU5fPoUUHVeud_hU8G4Z5mYFx7KeMY-s8,8564
|
74
74
|
notionary/blocks/shared/text_inline_formatter_new.py,sha256=nYmoFQVuAkfouCpGYULxFr4hHVCnRgvf3zxoiHBxIKg,4665
|
@@ -100,6 +100,7 @@ notionary/database/exceptions.py,sha256=jwFdxoIQHLO3mO3p5t890--1FjbTX60fNyqBAe-s
|
|
100
100
|
notionary/database/factory.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
101
101
|
notionary/database/models/page_result.py,sha256=Vmm5_oYpYAkIIJVoTd1ZZGloeC3cmFLMYP255mAmtaw,233
|
102
102
|
notionary/database/notion_database.py,sha256=wSqPfVtOnDL-aKRrE9BSMP1cpHe0_8RYyfCMxrlJSNo,16746
|
103
|
+
notionary/elements/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
103
104
|
notionary/file_upload/__init__.py,sha256=7TNyiIgLMD_IGRXTwRiAmStokF3rLoG4zXPwNb9KQqk,168
|
104
105
|
notionary/file_upload/client.py,sha256=qlxgu7_Ia0wbBflInoGki4mR8Po_RZgfLjO2wa279jY,8581
|
105
106
|
notionary/file_upload/models.py,sha256=0mYtuGkZ_eh_YmX0uxqye5vg3wWgqWuwOupAmLJXMUY,1625
|
@@ -112,10 +113,10 @@ notionary/page/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
112
113
|
notionary/page/client.py,sha256=XQ72lOEwn-gO8fmhKSKHqSHs3hRmoKH0TkJ3TtblcAg,4030
|
113
114
|
notionary/page/content/markdown_whitespace_processor.py,sha256=azsYau4eDrFN9CY7kzlG-ketoVKSkqSTc1bFq_i7ggQ,2942
|
114
115
|
notionary/page/content/notion_text_length_utils.py,sha256=RZqlcolvBBR1krlTMGS8q9xiZYYDGTyxZAjKhhONQyk,2757
|
115
|
-
notionary/page/content/page_content_retriever.py,sha256=
|
116
|
+
notionary/page/content/page_content_retriever.py,sha256=NOJ4ubLgZJECtQYcactVkeB6eiIYRBTM1llk5fh_6uc,1901
|
116
117
|
notionary/page/content/page_content_writer.py,sha256=0evYwdR7dSWECer_nHGAQsXbbkcbpnGQuacNXp14nG8,5656
|
117
118
|
notionary/page/formatting/line_processor.py,sha256=zr1P2zG0lSGgBlP1KbFvcnazOUTHGnF_uQeFUtLakfw,5404
|
118
|
-
notionary/page/formatting/markdown_to_notion_converter.py,sha256=
|
119
|
+
notionary/page/formatting/markdown_to_notion_converter.py,sha256=tbgaoEPJ96-JfCsyEsEK5-abdfmXapm9F2CAEX2rpig,6073
|
119
120
|
notionary/page/markdown_syntax_prompt_generator.py,sha256=uHCPNV9aQi3GzLVimyUKwza29hfxu6DTMVIa_QevJbk,4987
|
120
121
|
notionary/page/notion_page.py,sha256=5RbKxlA2RBoGiNXjO4bvgV9OMIIKwsTPbM3XolDOU2w,19026
|
121
122
|
notionary/page/notion_to_markdown_converter.py,sha256=3zvP1HSnUp3YlvK3PfIqh8GUi7xAuVWGQB0c38uK5VU,6117
|
@@ -143,7 +144,7 @@ notionary/util/page_id_utils.py,sha256=AA00kRO-g3Cc50tf_XW_tb5RBuPKLuBxRa0D8LYhL
|
|
143
144
|
notionary/util/singleton.py,sha256=CKAvykndwPRZsA3n3MAY_XdCR59MBjjKP0vtm2BcvF0,428
|
144
145
|
notionary/util/singleton_metaclass.py,sha256=uNeHiqS6TwhljvG1RE4NflIp2HyMuMmrCg2xI-vxmHE,809
|
145
146
|
notionary/workspace.py,sha256=hp5JPVT_aQsZNuxg2R-DiODobcGlVP4CusxNhzpnxKw,3813
|
146
|
-
notionary-0.2.
|
147
|
-
notionary-0.2.
|
148
|
-
notionary-0.2.
|
149
|
-
notionary-0.2.
|
147
|
+
notionary-0.2.19.dist-info/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
|
148
|
+
notionary-0.2.19.dist-info/METADATA,sha256=iKAerIgfYBeA0i8JunODWf3Wr54rsL9ZDmmJLLWy6Ms,6867
|
149
|
+
notionary-0.2.19.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
150
|
+
notionary-0.2.19.dist-info/RECORD,,
|
File without changes
|
File without changes
|