File size: 693 Bytes
3faa99b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from importlib import import_module
from inspect import isclass
from pathlib import Path
from pkgutil import iter_modules

from .base import BaseSession

sessions_class = []
sessions_names = []

package_dir = Path(__file__).resolve().parent
for _b, module_name, _p in iter_modules([str(package_dir)]):
    module = import_module(f"{__name__}.{module_name}")
    for attribute_name in dir(module):
        attribute = getattr(module, attribute_name)
        if (
            isclass(attribute)
            and issubclass(attribute, BaseSession)
            and attribute != BaseSession
        ):
            sessions_class.append(attribute)
            sessions_names.append(attribute.name())