notionary 0.1.15__tar.gz → 0.1.16__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 (62) hide show
  1. {notionary-0.1.15 → notionary-0.1.16}/PKG-INFO +1 -1
  2. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/relations/notion_page_relation_manager.py +29 -14
  3. notionary-0.1.16/notionary/page/relations/notion_page_title_resolver.py +87 -0
  4. {notionary-0.1.15 → notionary-0.1.16}/notionary.egg-info/PKG-INFO +1 -1
  5. {notionary-0.1.15 → notionary-0.1.16}/setup.py +1 -1
  6. notionary-0.1.15/notionary/page/relations/notion_page_title_resolver.py +0 -43
  7. {notionary-0.1.15 → notionary-0.1.16}/LICENSE +0 -0
  8. {notionary-0.1.15 → notionary-0.1.16}/README.md +0 -0
  9. {notionary-0.1.15 → notionary-0.1.16}/notionary/__init__.py +0 -0
  10. {notionary-0.1.15 → notionary-0.1.16}/notionary/database/database_discovery.py +0 -0
  11. {notionary-0.1.15 → notionary-0.1.16}/notionary/database/database_info_service.py +0 -0
  12. {notionary-0.1.15 → notionary-0.1.16}/notionary/database/models/page_result.py +0 -0
  13. {notionary-0.1.15 → notionary-0.1.16}/notionary/database/notion_database.py +0 -0
  14. {notionary-0.1.15 → notionary-0.1.16}/notionary/database/notion_database_factory.py +0 -0
  15. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/audio_element.py +0 -0
  16. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/block_element_registry.py +0 -0
  17. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/block_element_registry_builder.py +0 -0
  18. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/bookmark_element.py +0 -0
  19. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/callout_element.py +0 -0
  20. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/code_block_element.py +0 -0
  21. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/column_element.py +0 -0
  22. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/divider_element.py +0 -0
  23. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/embed_element.py +0 -0
  24. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/heading_element.py +0 -0
  25. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/image_element.py +0 -0
  26. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/list_element.py +0 -0
  27. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/mention_element.py +0 -0
  28. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/notion_block_element.py +0 -0
  29. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/paragraph_element.py +0 -0
  30. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/qoute_element.py +0 -0
  31. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/table_element.py +0 -0
  32. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/text_inline_formatter.py +0 -0
  33. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/todo_lists.py +0 -0
  34. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/toggle_element.py +0 -0
  35. {notionary-0.1.15 → notionary-0.1.16}/notionary/elements/video_element.py +0 -0
  36. {notionary-0.1.15 → notionary-0.1.16}/notionary/exceptions/database_exceptions.py +0 -0
  37. {notionary-0.1.15 → notionary-0.1.16}/notionary/exceptions/page_creation_exception.py +0 -0
  38. {notionary-0.1.15 → notionary-0.1.16}/notionary/notion_client.py +0 -0
  39. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/content/notion_page_content_chunker.py +0 -0
  40. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/content/page_content_manager.py +0 -0
  41. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/markdown_to_notion_converter.py +0 -0
  42. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/metadata/metadata_editor.py +0 -0
  43. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/metadata/notion_icon_manager.py +0 -0
  44. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/metadata/notion_page_cover_manager.py +0 -0
  45. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/notion_page.py +0 -0
  46. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/notion_page_factory.py +0 -0
  47. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/notion_to_markdown_converter.py +0 -0
  48. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/properites/database_property_service.py +0 -0
  49. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/properites/page_property_manager.py +0 -0
  50. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/properites/property_formatter.py +0 -0
  51. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/properites/property_operation_result.py +0 -0
  52. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/properites/property_value_extractor.py +0 -0
  53. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/relations/page_database_relation.py +0 -0
  54. {notionary-0.1.15 → notionary-0.1.16}/notionary/page/relations/relation_operation_result.py +0 -0
  55. {notionary-0.1.15 → notionary-0.1.16}/notionary/util/logging_mixin.py +0 -0
  56. {notionary-0.1.15 → notionary-0.1.16}/notionary/util/page_id_utils.py +0 -0
  57. {notionary-0.1.15 → notionary-0.1.16}/notionary/util/singleton_decorator.py +0 -0
  58. {notionary-0.1.15 → notionary-0.1.16}/notionary.egg-info/SOURCES.txt +0 -0
  59. {notionary-0.1.15 → notionary-0.1.16}/notionary.egg-info/dependency_links.txt +0 -0
  60. {notionary-0.1.15 → notionary-0.1.16}/notionary.egg-info/requires.txt +0 -0
  61. {notionary-0.1.15 → notionary-0.1.16}/notionary.egg-info/top_level.txt +0 -0
  62. {notionary-0.1.15 → notionary-0.1.16}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.1.15
3
+ Version: 0.1.16
4
4
  Summary: A toolkit to convert between Markdown and Notion blocks
5
5
  Home-page: https://github.com/mathisarends/notionary
6
6
  Author: Mathis Arends
@@ -88,26 +88,40 @@ class NotionRelationManager(LoggingMixin):
88
88
  ]
89
89
 
90
90
  async def get_relation_values(self, property_name: str) -> List[str]:
91
- """
92
- Returns the current relation values for a property.
91
+ """
92
+ Returns the titles of the pages linked via a relation property.
93
93
 
94
- Args:
95
- property_name: Name of the relation property
94
+ Args:
95
+ property_name: Name of the relation property
96
96
 
97
- Returns:
98
- List[str]: List of linked page IDs
99
- """
100
- properties = await self._get_page_properties()
97
+ Returns:
98
+ List[str]: List of linked page titles
99
+ """
100
+ properties = await self._get_page_properties()
101
101
 
102
- if property_name not in properties:
103
- return []
102
+ if property_name not in properties:
103
+ return []
104
104
 
105
- prop_data = properties[property_name]
105
+ prop_data = properties[property_name]
106
106
 
107
- if prop_data.get("type") != "relation" or "relation" not in prop_data:
108
- return []
107
+ if prop_data.get("type") != "relation" or "relation" not in prop_data:
108
+ return []
109
+
110
+ resolver = NotionPageTitleResolver(self._client)
111
+ titles = []
109
112
 
110
- return [rel.get("id") for rel in prop_data["relation"]]
113
+ for rel in prop_data["relation"]:
114
+ page_id = rel.get("id")
115
+ if not page_id:
116
+ continue
117
+
118
+ title = await resolver.get_title_by_page_id(page_id)
119
+ if not title:
120
+ continue
121
+
122
+ titles.append(title)
123
+
124
+ return titles
111
125
 
112
126
  async def get_relation_details(
113
127
  self, property_name: str
@@ -373,6 +387,7 @@ class NotionRelationManager(LoggingMixin):
373
387
  async def get_all_relations(self) -> Dict[str, List[str]]:
374
388
  """Returns all relation properties and their values."""
375
389
  relation_properties = await self.get_relation_property_ids()
390
+
376
391
  if not relation_properties:
377
392
  return {}
378
393
 
@@ -0,0 +1,87 @@
1
+ from typing import Optional
2
+ from notionary.notion_client import NotionClient
3
+ from notionary.util.logging_mixin import LoggingMixin
4
+
5
+
6
+ class NotionPageTitleResolver(LoggingMixin):
7
+ def __init__(self, client: NotionClient):
8
+ self._client = client
9
+
10
+ async def get_page_id_by_title(self, title: str) -> Optional[str]:
11
+ """
12
+ Searches for a Notion page by its title and returns the corresponding page ID if found.
13
+ """
14
+ try:
15
+ search_results = await self._client.post(
16
+ "search",
17
+ {"query": title, "filter": {"value": "page", "property": "object"}},
18
+ )
19
+
20
+ for result in search_results.get("results", []):
21
+ properties = result.get("properties", {})
22
+ if not properties:
23
+ continue
24
+
25
+ for prop_value in properties.values():
26
+ if prop_value.get("type") != "title":
27
+ continue
28
+
29
+ title_texts = prop_value.get("title", [])
30
+ if not title_texts:
31
+ continue
32
+
33
+ page_title = " ".join(
34
+ [t.get("plain_text", "") for t in title_texts]
35
+ )
36
+
37
+ if not page_title:
38
+ continue
39
+
40
+ if page_title == title or title in page_title:
41
+ self.logger.debug(
42
+ "Found page: '%s' with ID: %s",
43
+ page_title,
44
+ result.get("id"),
45
+ )
46
+ return result.get("id")
47
+
48
+ self.logger.debug("No page found with title '%s'", title)
49
+ return None
50
+
51
+ except Exception as e:
52
+ self.logger.error("Error while searching for page '%s': %s", title, e)
53
+ return None
54
+
55
+
56
+ async def get_title_by_page_id(self, page_id: str) -> Optional[str]:
57
+ """
58
+ Retrieves the title of a Notion page by its page ID.
59
+
60
+ Args:
61
+ page_id: The ID of the Notion page.
62
+
63
+ Returns:
64
+ The title of the page, or None if not found.
65
+ """
66
+ try:
67
+ page = await self._client.get(f"pages/{page_id}")
68
+ properties = page.get("properties", {})
69
+
70
+ for prop in properties.values():
71
+ if prop.get("type") != "title":
72
+ continue
73
+
74
+ title_parts = prop.get("title", [])
75
+ if not title_parts:
76
+ continue
77
+
78
+ title = " ".join([t.get("plain_text", "") for t in title_parts])
79
+ if title:
80
+ return title
81
+
82
+ self.logger.debug("No title found for page ID '%s'", page_id)
83
+ return None
84
+
85
+ except Exception as e:
86
+ self.logger.error("Error retrieving title for page ID '%s': %s", page_id, e)
87
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.1.15
3
+ Version: 0.1.16
4
4
  Summary: A toolkit to convert between Markdown and Notion blocks
5
5
  Home-page: https://github.com/mathisarends/notionary
6
6
  Author: Mathis Arends
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name="notionary",
5
- version="0.1.15",
5
+ version="0.1.16",
6
6
  packages=find_namespace_packages(include=["notionary*"]),
7
7
  install_requires=[
8
8
  "notion-client>=2.0.0",
@@ -1,43 +0,0 @@
1
- from typing import Optional
2
- from notionary.notion_client import NotionClient
3
- from notionary.util.logging_mixin import LoggingMixin
4
-
5
-
6
- class NotionPageTitleResolver(LoggingMixin):
7
- def __init__(self, client: NotionClient):
8
- self._client = client
9
-
10
- async def get_page_id_by_title(self, title: str) -> Optional[str]:
11
- """
12
- Searches for a Notion page by its title and returns the corresponding page ID if found.
13
- """
14
- try:
15
- search_results = await self._client.post(
16
- "search",
17
- {"query": title, "filter": {"value": "page", "property": "object"}},
18
- )
19
-
20
- for result in search_results.get("results", []):
21
- properties = result.get("properties", {})
22
-
23
- for prop_value in properties.values():
24
- if prop_value.get("type") == "title":
25
- title_texts = prop_value.get("title", [])
26
-
27
- page_title = " ".join(
28
- [t.get("plain_text", "") for t in title_texts]
29
- )
30
-
31
- if page_title == title or title in page_title:
32
- self.logger.debug(
33
- "Found page: '%s' with ID: %s",
34
- page_title,
35
- result.get("id"),
36
- )
37
- return result.get("id")
38
-
39
- self.logger.debug("No page found with title '%s'", title)
40
- return None
41
- except Exception as e:
42
- self.logger.error("Error while searching for page '%s': %s", title, e)
43
- return None
File without changes
File without changes
File without changes