Source code for divera.utils

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__, ) )