You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Faced index out of bound issue before, need to handle the empty/null title list case. Below is the updated working version
def _add_node(self, block: any, **kwargs):
"""
:param block: any type of block, page, database
:kwargs url: page or database url
"""
url = block.get('url', '')
title = block.get('title', None)
if not title or not isinstance(title, str):
if block.get('object') == 'database':
title_list = block.get('title', [])
if title_list and isinstance(title_list, list) and 'plain_text' in title_list[0]:
title = title_list[0]['plain_text']
else:
title = 'Untitled'
elif block.get('object') == 'page':
properties = block.get('properties', {})
if block.get('parent', {}).get('type') != "database_id":
title_list = properties.get('title', {}).get('title', [])
if title_list and isinstance(title_list, list) and 'plain_text' in title_list[0]:
title = title_list[0]['plain_text']
else:
title = 'Untitled'
else:
title_list = properties.get('Name', {}).get('title', [])
if title_list and isinstance(title_list, list) and 'plain_text' in title_list[0]:
title = title_list[0]['plain_text']
else:
title = 'Untitled'
else:
title = block.get(block.get('type'), {}).get('title', 'Untitled')
print("+node:", title)
self._graph.add_node(
block.get('id', 'unknown_id'),
label=title,
title=f'<a href="{url}">open page</a>',
color=COLOR_NODE,
size=10,
borderWidth=0
)
The text was updated successfully, but these errors were encountered:
Faced index out of bound issue before, need to handle the empty/null title list case. Below is the updated working version
The text was updated successfully, but these errors were encountered: