notion-database 1.2.1__tar.gz → 2.0.dev0__tar.gz

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.
Files changed (34) hide show
  1. {notion_database-1.2.1 → notion_database-2.0.dev0}/PKG-INFO +13 -12
  2. {notion_database-1.2.1 → notion_database-2.0.dev0}/README.md +10 -8
  3. notion_database-2.0.dev0/notion_database/NotionDatabase.py +107 -0
  4. notion_database-2.0.dev0/notion_database/__init__.py +7 -0
  5. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database/components/request.py +1 -1
  6. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/const}/__init__.py +0 -3
  7. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/service}/database.py +3 -3
  8. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/service}/page.py +4 -4
  9. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database.egg-info/PKG-INFO +13 -12
  10. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database.egg-info/SOURCES.txt +10 -8
  11. notion_database-2.0.dev0/notion_database.egg-info/requires.txt +2 -0
  12. {notion_database-1.2.1 → notion_database-2.0.dev0}/setup.py +3 -4
  13. {notion_database-1.2.1 → notion_database-2.0.dev0}/tests/test_children.py +1 -1
  14. {notion_database-1.2.1 → notion_database-2.0.dev0}/tests/test_cover.py +1 -1
  15. {notion_database-1.2.1 → notion_database-2.0.dev0}/tests/test_icon.py +1 -1
  16. {notion_database-1.2.1 → notion_database-2.0.dev0}/tests/test_properties.py +1 -1
  17. notion_database-1.2.1/notion_database.egg-info/requires.txt +0 -2
  18. {notion_database-1.2.1 → notion_database-2.0.dev0}/LICENSE +0 -0
  19. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database/components/__init__.py +0 -0
  20. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database/const/color.py +0 -0
  21. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database/const/query.py +0 -0
  22. {notion_database-1.2.1/notion_database/const → notion_database-2.0.dev0/notion_database/service}/__init__.py +0 -0
  23. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/service}/block.py +0 -0
  24. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/service}/children.py +0 -0
  25. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/service}/cover.py +0 -0
  26. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/service}/icon.py +0 -0
  27. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/service}/properties.py +0 -0
  28. {notion_database-1.2.1/notion_database → notion_database-2.0.dev0/notion_database/service}/search.py +0 -0
  29. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database/utils/__init__.py +0 -0
  30. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database/utils/deprecate.py +0 -0
  31. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database.egg-info/dependency_links.txt +0 -0
  32. {notion_database-1.2.1 → notion_database-2.0.dev0}/notion_database.egg-info/top_level.txt +0 -0
  33. {notion_database-1.2.1 → notion_database-2.0.dev0}/setup.cfg +0 -0
  34. {notion_database-1.2.1 → notion_database-2.0.dev0}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: notion-database
3
- Version: 1.2.1
3
+ Version: 2.0.dev0
4
4
  Summary: Python bindings for Notion Database API
5
5
  Home-page: https://github.com/minwook-shin/notion-database
6
6
  Author: minwook-shin
@@ -9,16 +9,15 @@ Project-URL: Bug Tracker, https://github.com/minwook-shin/notion-database/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
11
11
  Classifier: Operating System :: OS Independent
12
- Classifier: Programming Language :: Python :: 3.8
13
12
  Classifier: Programming Language :: Python :: 3.9
14
13
  Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
17
16
  Classifier: Development Status :: 5 - Production/Stable
18
- Requires-Python: >=3.8
17
+ Requires-Python: >=3.9
19
18
  Description-Content-Type: text/markdown
20
19
  License-File: LICENSE
21
- Requires-Dist: requests==2.32.0
20
+ Requires-Dist: requests==2.32.3
22
21
  Requires-Dist: urllib3<2.0
23
22
 
24
23
  [![Test Python Package](https://github.com/minwook-shin/notion-database/actions/workflows/python-publish.yml/badge.svg)](https://github.com/minwook-shin/notion-database/actions/workflows/python-publish.yml)
@@ -35,19 +34,18 @@ created by database from the official Notion API.
35
34
  ```python
36
35
  import os
37
36
 
38
- from notion_database.page import Page
39
- from notion_database.properties import Properties
37
+ from notion_database.service.properties import Properties
40
38
  from notion_database.const.query import Direction, Timestamp
41
- from notion_database.search import Search
39
+ from notion_database import NotionDatabase
42
40
 
43
- S = Search(integrations_token=os.getenv('NOTION_KEY'))
44
- S.search_database(query="", sort={"direction": Direction.ascending, "timestamp": Timestamp.last_edited_time})
45
- for i in S.result:
41
+ result = NotionDatabase.search_database(integrations_token=os.getenv('NOTION_KEY'),
42
+ sort={"direction": Direction.ascending, "timestamp": Timestamp.last_edited_time})
43
+
44
+ for i in result:
46
45
  PROPERTY = Properties()
47
46
  PROPERTY.set_title("title", "title")
48
47
  PROPERTY.set_rich_text("Description", "description text")
49
- P = Page(integrations_token=os.getenv('NOTION_KEY'))
50
- P.create_page(database_id=i["id"], properties=PROPERTY)
48
+ NotionDatabase.create_page(integrations_token=os.getenv('NOTION_KEY'), database_id=i["id"], properties=PROPERTY)
51
49
  ```
52
50
  See detailed example [here](example.py).
53
51
 
@@ -59,6 +57,9 @@ previous version is GPL, please be careful when using this out of version.
59
57
 
60
58
  ## What's new notion-version
61
59
 
60
+ * 2.0
61
+ * refactor the code to be more readable and maintainable.
62
+
62
63
  * 1.0.0
63
64
  * Now that we've implemented all features,
64
65
  * change the version rule to the semantic version.
@@ -12,19 +12,18 @@ created by database from the official Notion API.
12
12
  ```python
13
13
  import os
14
14
 
15
- from notion_database.page import Page
16
- from notion_database.properties import Properties
15
+ from notion_database.service.properties import Properties
17
16
  from notion_database.const.query import Direction, Timestamp
18
- from notion_database.search import Search
17
+ from notion_database import NotionDatabase
19
18
 
20
- S = Search(integrations_token=os.getenv('NOTION_KEY'))
21
- S.search_database(query="", sort={"direction": Direction.ascending, "timestamp": Timestamp.last_edited_time})
22
- for i in S.result:
19
+ result = NotionDatabase.search_database(integrations_token=os.getenv('NOTION_KEY'),
20
+ sort={"direction": Direction.ascending, "timestamp": Timestamp.last_edited_time})
21
+
22
+ for i in result:
23
23
  PROPERTY = Properties()
24
24
  PROPERTY.set_title("title", "title")
25
25
  PROPERTY.set_rich_text("Description", "description text")
26
- P = Page(integrations_token=os.getenv('NOTION_KEY'))
27
- P.create_page(database_id=i["id"], properties=PROPERTY)
26
+ NotionDatabase.create_page(integrations_token=os.getenv('NOTION_KEY'), database_id=i["id"], properties=PROPERTY)
28
27
  ```
29
28
  See detailed example [here](example.py).
30
29
 
@@ -36,6 +35,9 @@ previous version is GPL, please be careful when using this out of version.
36
35
 
37
36
  ## What's new notion-version
38
37
 
38
+ * 2.0
39
+ * refactor the code to be more readable and maintainable.
40
+
39
41
  * 1.0.0
40
42
  * Now that we've implemented all features,
41
43
  * change the version rule to the semantic version.
@@ -0,0 +1,107 @@
1
+ from typing import Dict
2
+
3
+ from notion_database.service.children import Children
4
+ from notion_database.service.cover import Cover
5
+ from notion_database.service.database import Database
6
+ from notion_database.service.icon import Icon
7
+ from notion_database.service.properties import Properties
8
+ from notion_database.service.search import Search
9
+ from notion_database.service.block import Block
10
+ from notion_database.service.page import Page
11
+
12
+
13
+ class NotionDatabase:
14
+ """
15
+ Notion API Search, Database class
16
+ """
17
+
18
+ # Search
19
+ @staticmethod
20
+ def search_database(integrations_token: str, sort: Dict, query: str = ""):
21
+ search = Search(integrations_token=integrations_token)
22
+ search.search_database(query=query, sort=sort)
23
+ return search.result
24
+
25
+ @staticmethod
26
+ def search_pages(integrations_token: str,
27
+ sort: Dict, query: str = "", page_size: int = 100, start_cursor: str = None):
28
+ search = Search(integrations_token=integrations_token)
29
+ search.search_pages(query=query, sort=sort, page_size=page_size, start_cursor=start_cursor)
30
+ return search.result
31
+
32
+ # Database
33
+ @staticmethod
34
+ def retrieve_database(integrations_token: str, database_id: str, get_properties: bool = False):
35
+ db = Database(integrations_token=integrations_token)
36
+ db.retrieve_database(database_id=database_id, get_properties=get_properties)
37
+ return db.result
38
+
39
+ @staticmethod
40
+ def run_query_database(integrations_token: str, database_id: str, db_filter: Dict = None, db_sort: Dict = None):
41
+ db = Database(integrations_token=integrations_token)
42
+ db.run_query_database(database_id=database_id, db_filter=db_filter, db_sort=db_sort)
43
+ return db.result
44
+
45
+ @staticmethod
46
+ def find_all_page(integrations_token: str, database_id: str, page_size: int = 100, start_cursor: str = None):
47
+ db = Database(integrations_token=integrations_token)
48
+ db.find_all_page(database_id=database_id, page_size=page_size, start_cursor=start_cursor)
49
+ return db.result
50
+
51
+ @staticmethod
52
+ def list_databases(integrations_token: str):
53
+ db = Database(integrations_token=integrations_token)
54
+ db.list_databases()
55
+ return db.result
56
+
57
+ @staticmethod
58
+ def create_database(integrations_token: str, page_id: str,
59
+ title: str, properties: Properties,
60
+ cover: Cover = None, icon: Icon = None, is_inline: bool = False):
61
+ db = Database(integrations_token=integrations_token)
62
+ db.create_database(page_id=page_id, title=title, properties=properties, cover=cover, icon=icon,
63
+ is_inline=is_inline)
64
+ return db.result
65
+
66
+ @staticmethod
67
+ def update_database(integrations_token: str, database_id: str, title: str,
68
+ remove_properties=None, add_properties=None, cover: Cover = None, icon: Icon = None):
69
+ db = Database(integrations_token=integrations_token)
70
+ db.update_database(database_id=database_id, title=title,
71
+ remove_properties=remove_properties, add_properties=add_properties, cover=cover, icon=icon)
72
+ return db.result
73
+
74
+ # Block
75
+ @staticmethod
76
+ def retrieve_block(integrations_token: str, block_id: str, is_children: bool = False,
77
+ page_size: int = 100, start_cursor: str = None):
78
+ block = Block(integrations_token=integrations_token)
79
+ block.retrieve_block(block_id=block_id, is_children=is_children, page_size=page_size, start_cursor=start_cursor)
80
+ return block.result
81
+
82
+ # Page
83
+ @staticmethod
84
+ def retrieve_page(integrations_token: str, page_id: str):
85
+ page = Page(integrations_token=integrations_token)
86
+ page.retrieve_page(page_id=page_id)
87
+ return page.result
88
+
89
+ @staticmethod
90
+ def create_page(integrations_token: str, database_id: str, properties: Properties = None,
91
+ children: Children = None, cover: Cover = None, icon: Icon = None):
92
+ page = Page(integrations_token=integrations_token)
93
+ page.create_page(database_id=database_id, properties=properties, children=children, cover=cover, icon=icon)
94
+ return page.result
95
+
96
+ @staticmethod
97
+ def update_page(integrations_token: str, page_id: str, properties: Properties = None,
98
+ cover: Cover = None, icon: Icon = None):
99
+ page = Page(integrations_token=integrations_token)
100
+ page.update_page(page_id=page_id, properties=properties, cover=cover, icon=icon)
101
+ return page.result
102
+
103
+ @staticmethod
104
+ def archive_page(integrations_token: str, page_id: str, archived: bool):
105
+ page = Page(integrations_token=integrations_token)
106
+ page.archive_page(page_id=page_id, archived=archived)
107
+ return page.result
@@ -0,0 +1,7 @@
1
+ """
2
+ init NOTION_VERSION
3
+ """
4
+ from notion_database.NotionDatabase import NotionDatabase
5
+
6
+
7
+ __all__ = ["NotionDatabase"]
@@ -6,7 +6,7 @@ from typing import Dict
6
6
 
7
7
  import requests
8
8
 
9
- from notion_database import NOTION_VERSION
9
+ from notion_database.const import NOTION_VERSION
10
10
 
11
11
 
12
12
  class Request:
@@ -1,4 +1 @@
1
- """
2
- init NOTION_VERSION
3
- """
4
1
  NOTION_VERSION = "2022-06-28"
@@ -5,11 +5,11 @@ from typing import Dict, List
5
5
 
6
6
  from notion_database.utils import deprecate
7
7
 
8
- from notion_database.properties import Properties
8
+ from notion_database.service.properties import Properties
9
9
  from notion_database.components.request import Request
10
10
 
11
- from notion_database.cover import Cover
12
- from notion_database.icon import Icon
11
+ from notion_database.service.cover import Cover
12
+ from notion_database.service.icon import Icon
13
13
 
14
14
 
15
15
  class Database:
@@ -4,12 +4,12 @@ Notion API Page
4
4
  import logging
5
5
  from typing import Dict
6
6
 
7
- from notion_database.children import Children
8
- from notion_database.properties import Properties
7
+ from notion_database.service.children import Children
8
+ from notion_database.service.properties import Properties
9
9
  from notion_database.components.request import Request
10
10
 
11
- from notion_database.cover import Cover
12
- from notion_database.icon import Icon
11
+ from notion_database.service.cover import Cover
12
+ from notion_database.service.icon import Icon
13
13
 
14
14
  LOGGER = logging.getLogger("Notion-Database")
15
15
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: notion-database
3
- Version: 1.2.1
3
+ Version: 2.0.dev0
4
4
  Summary: Python bindings for Notion Database API
5
5
  Home-page: https://github.com/minwook-shin/notion-database
6
6
  Author: minwook-shin
@@ -9,16 +9,15 @@ Project-URL: Bug Tracker, https://github.com/minwook-shin/notion-database/issues
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
11
11
  Classifier: Operating System :: OS Independent
12
- Classifier: Programming Language :: Python :: 3.8
13
12
  Classifier: Programming Language :: Python :: 3.9
14
13
  Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
17
16
  Classifier: Development Status :: 5 - Production/Stable
18
- Requires-Python: >=3.8
17
+ Requires-Python: >=3.9
19
18
  Description-Content-Type: text/markdown
20
19
  License-File: LICENSE
21
- Requires-Dist: requests==2.32.0
20
+ Requires-Dist: requests==2.32.3
22
21
  Requires-Dist: urllib3<2.0
23
22
 
24
23
  [![Test Python Package](https://github.com/minwook-shin/notion-database/actions/workflows/python-publish.yml/badge.svg)](https://github.com/minwook-shin/notion-database/actions/workflows/python-publish.yml)
@@ -35,19 +34,18 @@ created by database from the official Notion API.
35
34
  ```python
36
35
  import os
37
36
 
38
- from notion_database.page import Page
39
- from notion_database.properties import Properties
37
+ from notion_database.service.properties import Properties
40
38
  from notion_database.const.query import Direction, Timestamp
41
- from notion_database.search import Search
39
+ from notion_database import NotionDatabase
42
40
 
43
- S = Search(integrations_token=os.getenv('NOTION_KEY'))
44
- S.search_database(query="", sort={"direction": Direction.ascending, "timestamp": Timestamp.last_edited_time})
45
- for i in S.result:
41
+ result = NotionDatabase.search_database(integrations_token=os.getenv('NOTION_KEY'),
42
+ sort={"direction": Direction.ascending, "timestamp": Timestamp.last_edited_time})
43
+
44
+ for i in result:
46
45
  PROPERTY = Properties()
47
46
  PROPERTY.set_title("title", "title")
48
47
  PROPERTY.set_rich_text("Description", "description text")
49
- P = Page(integrations_token=os.getenv('NOTION_KEY'))
50
- P.create_page(database_id=i["id"], properties=PROPERTY)
48
+ NotionDatabase.create_page(integrations_token=os.getenv('NOTION_KEY'), database_id=i["id"], properties=PROPERTY)
51
49
  ```
52
50
  See detailed example [here](example.py).
53
51
 
@@ -59,6 +57,9 @@ previous version is GPL, please be careful when using this out of version.
59
57
 
60
58
  ## What's new notion-version
61
59
 
60
+ * 2.0
61
+ * refactor the code to be more readable and maintainable.
62
+
62
63
  * 1.0.0
63
64
  * Now that we've implemented all features,
64
65
  * change the version rule to the semantic version.
@@ -1,15 +1,8 @@
1
1
  LICENSE
2
2
  README.md
3
3
  setup.py
4
+ notion_database/NotionDatabase.py
4
5
  notion_database/__init__.py
5
- notion_database/block.py
6
- notion_database/children.py
7
- notion_database/cover.py
8
- notion_database/database.py
9
- notion_database/icon.py
10
- notion_database/page.py
11
- notion_database/properties.py
12
- notion_database/search.py
13
6
  notion_database.egg-info/PKG-INFO
14
7
  notion_database.egg-info/SOURCES.txt
15
8
  notion_database.egg-info/dependency_links.txt
@@ -20,6 +13,15 @@ notion_database/components/request.py
20
13
  notion_database/const/__init__.py
21
14
  notion_database/const/color.py
22
15
  notion_database/const/query.py
16
+ notion_database/service/__init__.py
17
+ notion_database/service/block.py
18
+ notion_database/service/children.py
19
+ notion_database/service/cover.py
20
+ notion_database/service/database.py
21
+ notion_database/service/icon.py
22
+ notion_database/service/page.py
23
+ notion_database/service/properties.py
24
+ notion_database/service/search.py
23
25
  notion_database/utils/__init__.py
24
26
  notion_database/utils/deprecate.py
25
27
  tests/__init__.py
@@ -0,0 +1,2 @@
1
+ requests==2.32.3
2
+ urllib3<2.0
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="notion-database",
8
- version="1.2.1",
8
+ version="2.0.dev0",
9
9
  author="minwook-shin",
10
10
  author_email="minwook0106@gmail.com",
11
11
  description=" Python bindings for Notion Database API",
@@ -16,14 +16,13 @@ setuptools.setup(
16
16
  "Bug Tracker": "https://github.com/minwook-shin/notion-database/issues",
17
17
  },
18
18
  install_requires=[
19
- "requests==2.32.0",
19
+ "requests==2.32.3",
20
20
  "urllib3<2.0"
21
21
  ],
22
22
  classifiers=[
23
23
  "Programming Language :: Python :: 3",
24
24
  "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
25
25
  "Operating System :: OS Independent",
26
- 'Programming Language :: Python :: 3.8',
27
26
  'Programming Language :: Python :: 3.9',
28
27
  'Programming Language :: Python :: 3.10',
29
28
  'Programming Language :: Python :: 3.11',
@@ -31,5 +30,5 @@ setuptools.setup(
31
30
  'Development Status :: 5 - Production/Stable'
32
31
  ],
33
32
  packages=setuptools.find_packages(),
34
- python_requires=">=3.8",
33
+ python_requires=">=3.9",
35
34
  )
@@ -1,6 +1,6 @@
1
1
  import unittest
2
2
 
3
- from notion_database.children import Children
3
+ from notion_database.service.children import Children
4
4
 
5
5
 
6
6
  class TestChildrenMethods(unittest.TestCase):
@@ -1,6 +1,6 @@
1
1
  import unittest
2
2
 
3
- from notion_database.cover import Cover
3
+ from notion_database.service.cover import Cover
4
4
 
5
5
 
6
6
  class TestCoverMethods(unittest.TestCase):
@@ -1,6 +1,6 @@
1
1
  import unittest
2
2
 
3
- from notion_database.icon import Icon
3
+ from notion_database.service.icon import Icon
4
4
 
5
5
 
6
6
  class TestIconMethods(unittest.TestCase):
@@ -1,6 +1,6 @@
1
1
  import unittest
2
2
 
3
- from notion_database.properties import Properties
3
+ from notion_database.service.properties import Properties
4
4
 
5
5
 
6
6
  class TestPropertyMethods(unittest.TestCase):
@@ -1,2 +0,0 @@
1
- requests==2.32.0
2
- urllib3<2.0