Skip to content

Commit 91114db

Browse files
committed
add column block
1 parent fd961bf commit 91114db

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Python 3 tools for interacting with Notion API:
66

77
- Relational database wrapper
88

9+
## Changelog
10+
11+
- 11/11: Add column list, column block
12+
913
## Installation
1014

1115
`pip install notiondb`

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="notiondb",
8-
version="1.0.0",
8+
version="1.0.1",
99
author="Viet Hoang",
1010
author_email="[email protected]",
1111
description="Python 3 tools for interacting with Notion API",

src/notiondb/block.py

+22
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ def language(self):
111111
return self._language
112112

113113

114+
class ColumnBlock(BaseBlock):
115+
116+
def __init__(self, blocks: List[BaseBlock]):
117+
super().__init__(value=None)
118+
self._children = blocks
119+
120+
block_type = 'column'
121+
122+
properties = ['children']
123+
124+
def children(self):
125+
return [block.value for block in self._children]
126+
127+
128+
class ColumnListBlock(ColumnBlock):
129+
130+
def __init__(self, columns: List[ColumnBlock]):
131+
super().__init__(blocks=columns)
132+
133+
block_type = 'column_list'
134+
135+
114136
class ChildPageBlock(BaseBlock):
115137

116138
block_type = 'child_page'

tests/test_database.py

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ def test_model_c_append_children(self):
164164
TableOfContentsBlock(),
165165
BreadcrumbBlock(),
166166
DividerBlock(),
167+
ColumnListBlock(columns=[
168+
ColumnBlock([ParagraphBlock('paragraph 1'), ParagraphBlock('paragraph 2')]),
169+
ColumnBlock([ParagraphBlock('paragraph 3'), ParagraphBlock('paragraph 4')]),
170+
]),
167171
ParagraphBlock('paragraph 1'),
168172
ParagraphBlock('paragraph 2', link='https://developers.notion.com/reference/block'),
169173
HeadingOneBlock('heading 1'),

0 commit comments

Comments
 (0)