blob: 994867b8be08257a918200c1a35179b0ccee3231 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
"""Functions for collections."""
from .session import session_info
from .client import user_logged_in
from .client import oauth2_get, no_token_get
def num_collections() -> int:
"""Compute the number of collections available for the current session."""
anon_id = session_info()["anon_id"]
all_collections = no_token_get(
f"auth/user/collections/{anon_id}/list").either(
lambda _err: [], lambda colls: colls)
if user_logged_in():
all_collections = all_collections + oauth2_get(
"auth/user/collections/list").either(
lambda _err: [], lambda colls: colls)
return len(all_collections)
|