Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
return False
return item_id in self._block_ids
class TableQueryResult(QueryResult):
_type = "table"
class BoardQueryResult(QueryResult):
_type = "board"
class CalendarQueryResult(QueryResult):
_type = "calendar"
def _get_block_ids(self, result):
block_ids = []
for week in result["weeks"]:
block_ids += week["items"]
return block_ids
class ListQueryResult(QueryResult):
_type = "list"
class GalleryQueryResult(QueryResult):
return iter(self._get_block(id) for id in self._block_ids)
def __reversed__(self):
return reversed(iter(self))
def __contains__(self, item):
if isinstance(item, str):
item_id = extract_id(item)
elif isinstance(item, Block):
item_id = item.id
else:
return False
return item_id in self._block_ids
class TableQueryResult(QueryResult):
_type = "table"
class BoardQueryResult(QueryResult):
_type = "board"
class CalendarQueryResult(QueryResult):
_type = "calendar"
def _get_block_ids(self, result):
block_ids = []
for week in result["weeks"]:
def execute(self):
result_class = QUERY_RESULT_TYPES.get(self.type, QueryResult)
return result_class(
self.collection,
self._client.query_collection(
collection_id=self.collection.id,
collection_view_id=self.collection_view.id,
search=self.search,
type=self.type,
aggregate=self.aggregate,
filter=self.filter,
filter_operator=self.filter_operator,
sort=self.sort,
calendar_by=self.calendar_by,
group_by=self.group_by,
),
_type = "calendar"
def _get_block_ids(self, result):
block_ids = []
for week in result["weeks"]:
block_ids += week["items"]
return block_ids
class ListQueryResult(QueryResult):
_type = "list"
class GalleryQueryResult(QueryResult):
_type = "gallery"
COLLECTION_VIEW_TYPES = {
cls._type: cls
for cls in locals().values()
if type(cls) == type and issubclass(cls, CollectionView) and hasattr(cls, "_type")
}
QUERY_RESULT_TYPES = {
cls._type: cls
for cls in locals().values()
if type(cls) == type and issubclass(cls, QueryResult) and hasattr(cls, "_type")
}
_type = "board"
class CalendarQueryResult(QueryResult):
_type = "calendar"
def _get_block_ids(self, result):
block_ids = []
for week in result["weeks"]:
block_ids += week["items"]
return block_ids
class ListQueryResult(QueryResult):
_type = "list"
class GalleryQueryResult(QueryResult):
_type = "gallery"
COLLECTION_VIEW_TYPES = {
cls._type: cls
for cls in locals().values()
if type(cls) == type and issubclass(cls, CollectionView) and hasattr(cls, "_type")
}
QUERY_RESULT_TYPES = {
class GalleryQueryResult(QueryResult):
_type = "gallery"
COLLECTION_VIEW_TYPES = {
cls._type: cls
for cls in locals().values()
if type(cls) == type and issubclass(cls, CollectionView) and hasattr(cls, "_type")
}
QUERY_RESULT_TYPES = {
cls._type: cls
for cls in locals().values()
if type(cls) == type and issubclass(cls, QueryResult) and hasattr(cls, "_type")
}
def __contains__(self, item):
if isinstance(item, str):
item_id = extract_id(item)
elif isinstance(item, Block):
item_id = item.id
else:
return False
return item_id in self._block_ids
class TableQueryResult(QueryResult):
_type = "table"
class BoardQueryResult(QueryResult):
_type = "board"
class CalendarQueryResult(QueryResult):
_type = "calendar"
def _get_block_ids(self, result):
block_ids = []
for week in result["weeks"]:
block_ids += week["items"]
return block_ids
class ListQueryResult(QueryResult):