Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if prop["type"] in ["multi_select"]:
val = [v.strip() for v in val[0][0].split(",")] if val else []
if prop["type"] in ["person"]:
val = (
[self._client.get_user(item[1][0][1]) for item in val if item[0] == "‣"]
if val
else []
)
if prop["type"] in ["email", "phone_number", "url"]:
val = val[0][0] if val else ""
if prop["type"] in ["date"]:
val = NotionDate.from_notion(val)
if prop["type"] in ["file"]:
val = (
[
add_signed_prefix_as_needed(item[1][0][1], client=self._client)
for item in val
if item[0] != ","
]
if val
else []
)
if prop["type"] in ["checkbox"]:
val = val[0][0] == "Yes" if val else False
if prop["type"] in ["relation"]:
val = (
[
self._client.get_block(item[1][0][1])
for item in val
if item[0] == "‣"
]
if val
view.set("collection_id", self._parent._collection.id)
view_ids = self._parent.get(CollectionViewBlockViews.child_list_key, [])
view_ids.append(view.id)
self._parent.set(CollectionViewBlockViews.child_list_key, view_ids)
# At this point, the view does not see to be completely initialized yet.
# Hack: wait a bit before e.g. setting a query.
time.sleep(3)
return view
class CollectionViewPageBlock(CollectionViewBlock):
icon = field_map(
"format.page_icon",
api_to_python=add_signed_prefix_as_needed,
python_to_api=remove_signed_prefix_as_needed,
)
_type = "collection_view_page"
class FramerBlock(EmbedBlock):
_type = "framer"
class TweetBlock(EmbedBlock):
_type = "tweet"