notionary 0.2.26__py3-none-any.whl → 0.2.27__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.
@@ -46,6 +46,7 @@ class NotionPage(LoggingMixin):
46
46
  archived: bool,
47
47
  in_trash: bool,
48
48
  emoji_icon: Optional[str] = None,
49
+ external_icon_url: Optional[str] = None,
49
50
  properties: Optional[dict[str, Any]] = None,
50
51
  parent_database: Optional[NotionDatabase] = None,
51
52
  token: Optional[str] = None,
@@ -59,6 +60,7 @@ class NotionPage(LoggingMixin):
59
60
  self._is_archived = archived
60
61
  self._is_in_trash = in_trash
61
62
  self._emoji_icon = emoji_icon
63
+ self._external_icon_url = external_icon_url
62
64
  self._properties = properties
63
65
  self._parent_database = parent_database
64
66
 
@@ -192,6 +194,13 @@ class NotionPage(LoggingMixin):
192
194
  """
193
195
  return self._url
194
196
 
197
+ @property
198
+ def external_icon_url(self) -> Optional[str]:
199
+ """
200
+ Get the icon of the page.
201
+ """
202
+ return self._external_icon_url
203
+
195
204
  @property
196
205
  def emoji_icon(self) -> Optional[str]:
197
206
  """
@@ -345,12 +354,32 @@ class NotionPage(LoggingMixin):
345
354
  )
346
355
 
347
356
  self._emoji = page_response.icon.emoji
357
+ self._external_icon_url = None
348
358
  return page_response.icon.emoji
349
359
  except Exception as e:
350
360
 
351
361
  self.logger.error(f"Error updating page emoji: {str(e)}")
352
362
  return None
353
363
 
364
+ async def set_external_icon(self, url: str) -> Optional[str]:
365
+ """
366
+ Sets the page icon to an external image.
367
+ """
368
+ try:
369
+ icon = {"type": "external", "external": {"url": url}}
370
+ page_response = await self._client.patch_page(
371
+ page_id=self._page_id, data={"icon": icon}
372
+ )
373
+
374
+ self._icon = url
375
+ self._emoji = None
376
+ self.logger.info(f"Successfully updated page external icon to: {url}")
377
+ return page_response.icon.external.url
378
+
379
+ except Exception as e:
380
+ self.logger.error(f"Error updating page external icon: {str(e)}")
381
+ return None
382
+
354
383
  async def create_child_database(self, title: str) -> NotionDatabase:
355
384
  from notionary import NotionDatabase
356
385
 
@@ -599,7 +628,8 @@ class NotionPage(LoggingMixin):
599
628
  from notionary.database.database import NotionDatabase
600
629
 
601
630
  title = cls._extract_title(page_response)
602
- emoji = cls._extract_emoji(page_response)
631
+ emoji_icon = cls._extract_page_emoji_icon(page_response)
632
+ external_icon_url = cls._extract_external_icon_url(page_response)
603
633
  parent_database_id = cls._extract_parent_database_id(page_response)
604
634
 
605
635
  parent_database = (
@@ -612,7 +642,8 @@ class NotionPage(LoggingMixin):
612
642
  page_id=page_response.id,
613
643
  title=title,
614
644
  url=page_response.url,
615
- emoji_icon=emoji,
645
+ emoji_icon=emoji_icon,
646
+ external_icon_url=external_icon_url,
616
647
  archived=page_response.archived,
617
648
  in_trash=page_response.in_trash,
618
649
  properties=page_response.properties,
@@ -649,15 +680,22 @@ class NotionPage(LoggingMixin):
649
680
  return ""
650
681
 
651
682
  @staticmethod
652
- def _extract_emoji(page_response: NotionPageResponse) -> Optional[str]:
653
- """Extract emoji from database response."""
683
+ def _extract_page_emoji_icon(page_response: NotionPageResponse) -> Optional[str]:
684
+ """Extract external icon URL from page response."""
654
685
  if not page_response.icon:
655
686
  return None
656
687
 
657
688
  if page_response.icon.type == "emoji":
658
689
  return page_response.icon.emoji
659
690
 
660
- return None
691
+ @staticmethod
692
+ def _extract_external_icon_url(page_response: NotionPageResponse) -> Optional[str]:
693
+ """Extract emoji from database response."""
694
+ if not page_response.icon:
695
+ return None
696
+
697
+ if page_response.icon.type == "external":
698
+ return page_response.icon.external.url
661
699
 
662
700
  @staticmethod
663
701
  def _extract_parent_database_id(page_response: NotionPageResponse) -> Optional[str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: notionary
3
- Version: 0.2.26
3
+ Version: 0.2.27
4
4
  Summary: Python library for programmatic Notion workspace management - databases, pages, and content with advanced Markdown support
5
5
  License: MIT
6
6
  Author: Mathis Arends
@@ -138,7 +138,7 @@ notionary/file_upload/notion_file_upload.py,sha256=vOEEh8g8Sj4JedrK9e-NYjJ0HXH3i
138
138
  notionary/page/client.py,sha256=IOsjWOsmODxOq-7OF0y-gcuC2HUbMIT0SvJZHrH9weQ,4520
139
139
  notionary/page/markdown_whitespace_processor.py,sha256=SbWLL6bdeTGds_khDNX2mQe00lGYUFvH6PX8_xpNvBA,4634
140
140
  notionary/page/models.py,sha256=zk9QOgCDzVfYfT1Gp2bL1_Bw-QUyfWxwTTIPzIayQ7g,6945
141
- notionary/page/notion_page.py,sha256=P8J2lvq7xM0UwbL0wEFGi9w7jNPg43ewutmYpJINe1w,23662
141
+ notionary/page/notion_page.py,sha256=_Hj0U9gl3laRKs3l1Cd8tBODXZrHYxrK2Z5gw0O0Fvo,25146
142
142
  notionary/page/page_content_deleting_service.py,sha256=G3im6VotG1tgI-SaqoQR-gSnOloF6CEnft1qxLps4as,4546
143
143
  notionary/page/page_content_writer.py,sha256=t8N7yfW--ac7szvDmTdecFEfcF5Nz95vyCQ-lpYcOUw,3046
144
144
  notionary/page/page_context.py,sha256=27vrTRZP7NsaS4dEp4pBNR30Re2hh00qKlL3xt4YtpI,1773
@@ -196,7 +196,7 @@ notionary/util/page_id_utils.py,sha256=AA00kRO-g3Cc50tf_XW_tb5RBuPKLuBxRa0D8LYhL
196
196
  notionary/util/singleton.py,sha256=CKAvykndwPRZsA3n3MAY_XdCR59MBjjKP0vtm2BcvF0,428
197
197
  notionary/util/singleton_metaclass.py,sha256=DMvrh0IbAV8nIG1oX-2Yz57Uk1YHB647DNxoI3pAT3s,809
198
198
  notionary/workspace.py,sha256=QP4WcOIdQnlVr4M7hpGaFT-Fori_QRhsV-SBC2lnwTU,3809
199
- notionary-0.2.26.dist-info/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
200
- notionary-0.2.26.dist-info/METADATA,sha256=YQ47PvnCFcARf1p99-fZWoYnedbR0S5G2rQRUa6e4KY,9143
201
- notionary-0.2.26.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
202
- notionary-0.2.26.dist-info/RECORD,,
199
+ notionary-0.2.27.dist-info/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
200
+ notionary-0.2.27.dist-info/METADATA,sha256=NabOWlvkZwSL3tGqEiC1DGDd-cWAUNPJaT6hdFH3KAo,9143
201
+ notionary-0.2.27.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
202
+ notionary-0.2.27.dist-info/RECORD,,