notionary 0.1.7__py3-none-any.whl → 0.1.9__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.
@@ -48,25 +48,30 @@ class PageContentManager(LoggingMixin):
48
48
  return "No content to delete."
49
49
 
50
50
  deleted = 0
51
- for b in results:
52
- if await self._client.delete(f"blocks/{b['id']}"):
51
+ skipped = 0
52
+ for block in results:
53
+ if block.get("type") in ["child_database", "database", "linked_database"]:
54
+ skipped += 1
55
+ continue
56
+
57
+ if await self._client.delete(f"blocks/{block['id']}"):
53
58
  deleted += 1
54
59
 
55
- return f"Deleted {deleted}/{len(results)} blocks."
60
+ return f"Deleted {deleted}/{len(results)} blocks. Skipped {skipped} database blocks."
56
61
 
57
62
  async def get_blocks(self) -> List[Dict[str, Any]]:
58
63
  result = await self._client.get(f"blocks/{self.page_id}/children")
59
64
  if not result:
60
65
  self.logger.error("Error retrieving page content: %s", result.error)
61
66
  return []
62
- return result.data.get("results", [])
67
+ return result.get("results", [])
63
68
 
64
69
  async def get_block_children(self, block_id: str) -> List[Dict[str, Any]]:
65
70
  result = await self._client.get(f"blocks/{block_id}/children")
66
71
  if not result:
67
72
  self.logger.error("Error retrieving block children: %s", result.error)
68
73
  return []
69
- return result.data.get("results", [])
74
+ return result.get("results", [])
70
75
 
71
76
  async def get_page_blocks_with_children(self) -> List[Dict[str, Any]]:
72
77
  blocks = await self.get_blocks()
@@ -305,6 +305,7 @@ async def main():
305
305
 
306
306
  print("\nDemonstration abgeschlossen.")
307
307
 
308
+
308
309
  if __name__ == "__main__":
309
310
  asyncio.run(main())
310
311
  print("\nDemonstration completed.")
@@ -4,36 +4,39 @@ from typing import Optional
4
4
  UUID_PATTERN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
5
5
  UUID_RAW_PATTERN = r"([a-f0-9]{32})"
6
6
 
7
-
8
7
  def extract_uuid(source: str) -> Optional[str]:
8
+ if is_valid_uuid(source):
9
+ return source
10
+
9
11
  match = re.search(UUID_RAW_PATTERN, source.lower())
10
12
  if not match:
11
13
  return None
12
-
14
+
13
15
  uuid_raw = match.group(1)
14
16
  return f"{uuid_raw[0:8]}-{uuid_raw[8:12]}-{uuid_raw[12:16]}-{uuid_raw[16:20]}-{uuid_raw[20:32]}"
15
17
 
16
-
17
18
  def is_valid_uuid(uuid: str) -> bool:
18
19
  return bool(re.match(UUID_PATTERN, uuid.lower()))
19
20
 
20
-
21
21
  def format_uuid(value: str) -> Optional[str]:
22
22
  if is_valid_uuid(value):
23
23
  return value
24
24
  return extract_uuid(value)
25
25
 
26
-
27
26
  def extract_and_validate_page_id(page_id: Optional[str], url: Optional[str]) -> str:
28
27
  if not page_id and not url:
29
28
  raise ValueError("Either page_id or url must be provided")
30
-
29
+
31
30
  candidate = page_id or url
31
+
32
+ if is_valid_uuid(candidate):
33
+ return candidate
34
+
32
35
  extracted_id = extract_uuid(candidate)
33
36
  if not extracted_id:
34
37
  raise ValueError(f"Could not extract a valid UUID from: {candidate}")
35
-
38
+
36
39
  formatted = format_uuid(extracted_id)
37
- if not is_valid_uuid(formatted):
40
+ if not formatted or not is_valid_uuid(formatted):
38
41
  raise ValueError(f"Invalid UUID format: {formatted}")
39
42
  return formatted
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.1.7
3
+ Version: 0.1.9
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
@@ -26,8 +26,8 @@ notionary/core/database/notion_database_manager.py,sha256=cEQHf8bTcgA3hLMgsbMGSX
26
26
  notionary/core/database/notion_database_manager_factory.py,sha256=SoWUiM5zdajmR1ppYHTdPgHrdZbwuTMdoXW3_tBffyU,6831
27
27
  notionary/core/database/notion_database_schema.py,sha256=WUIjG7I5kusk4GOOdmVSHIKc2Z8SeOgJ1FuGpTn4avQ,3304
28
28
  notionary/core/database/models/page_result.py,sha256=Vmm5_oYpYAkIIJVoTd1ZZGloeC3cmFLMYP255mAmtaw,233
29
- notionary/core/page/notion_page_manager.py,sha256=NH4mNZ9jgRxmc3gay1ymG0Qcc5k_YX9eSkCMUnB9ghw,13247
30
- notionary/core/page/content/page_content_manager.py,sha256=CZGb8vXWADxwo_xBrZ7mmKEW_HSFhlVNjOgWMfYgGJc,3142
29
+ notionary/core/page/notion_page_manager.py,sha256=tKYCtrqOOGKQR_qcFUX9WpZWZGhG5wPwmZa19XtIxns,13249
30
+ notionary/core/page/content/page_content_manager.py,sha256=GjgxVwi5NOMsvGwBNj-woq940ZupzALCQegDyIcsgMg,3358
31
31
  notionary/core/page/metadata/metadata_editor.py,sha256=U3Ff9GRk28dqT9M1xsl6Q3Cj47-hB1n2pNJzeDXy4ks,4938
32
32
  notionary/core/page/metadata/notion_icon_manager.py,sha256=v9pUG61TOT8x9UzDqBtQW6S5XQzWostq7IwrURnWvF4,1499
33
33
  notionary/core/page/metadata/notion_page_cover_manager.py,sha256=nDWXeEztKyPscq5dRxIZ6d6IqV7E3vR-Qg1N8KzP_fo,1831
@@ -43,10 +43,10 @@ notionary/core/page/relations/relation_operation_result.py,sha256=XkO4rK0ha_FRsf
43
43
  notionary/exceptions/database_exceptions.py,sha256=I-Tx6bYRLpi5pjGPtbT-Mqxvz3BFgYTiuZxknJeLxtI,2638
44
44
  notionary/exceptions/page_creation_exception.py,sha256=4v7IuZD6GsQLrqhDLriGjuG3ML638gAO53zDCrLePuU,281
45
45
  notionary/util/logging_mixin.py,sha256=fKsx9t90bwvL74ZX3dU-sXdC4TZCQyO6qU9I8txkw_U,1369
46
- notionary/util/page_id_utils.py,sha256=vgCEp6BdsSJuEtLZVjrRAU9p6moLW-vymM7va8fhErI,1220
46
+ notionary/util/page_id_utils.py,sha256=9XexVGy8jY5iOlueS1MXFWHtRRmZ8js-EO3hT0_wg2E,1381
47
47
  notionary/util/singleton_decorator.py,sha256=GTNMfIlVNRUVMw_c88xqd12-DcqZJjmyidN54yqiNVw,472
48
- notionary-0.1.7.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
49
- notionary-0.1.7.dist-info/METADATA,sha256=l0WogkR1uSHB6R6ZMCQPIlE4ajYyQ9HfnUDbccNYYfg,6153
50
- notionary-0.1.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
51
- notionary-0.1.7.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
52
- notionary-0.1.7.dist-info/RECORD,,
48
+ notionary-0.1.9.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
49
+ notionary-0.1.9.dist-info/METADATA,sha256=q3KrPXR-bccNYMdF8HT7EeEvyiyBy9GqhESh4-oMcz8,6153
50
+ notionary-0.1.9.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
51
+ notionary-0.1.9.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
52
+ notionary-0.1.9.dist-info/RECORD,,