import divera
import divera.models
[docs]def get_all_models():
"""
Find all models that can be accessed with the API.
:return: A list of all classes that derive from divera.models.Model
"""
models = []
for a in dir(divera):
attribute = divera.__getattribute__(a)
# Exclude hidden attributes
if a.startswith("_"):
continue
# It one of the logic expressions fails, that also means the model should not be included
try:
if issubclass(attribute, divera.models.Model) and attribute is not divera.models.Model:
models.append(attribute)
except TypeError:
continue
return models
[docs]def get_nesting_depth(
cls,
parent_cls=object,
start_level: int = 0,
):
if len(cls.__bases__) == 0:
return start_level
else:
return max(
map(
lambda c: get_nesting_depth(c, parent_cls, start_level + 1),
cls.__bases__,
)
)
[docs]def get_recommended_websocket_url(
domain: str,
):
# Make sure the domain actually is a domain and not an url
if '://' in domain:
domain = domain.split('://')[1]
domain = domain.split('/')[0]
if domain == 'app.divera247.com':
return 'wss://ws.divera247.com'
else:
return f'wss://{domain}'