summaryrefslogtreecommitdiff
path: root/src/home/media/__init__.py
blob: e8268cfd62b55dff18b97058263b8f7b6ba631a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import importlib
import itertools

__map__ = {
    'types': ['MediaNodeType'],
    'record_client': ['SoundRecordClient', 'CameraRecordClient', 'RecordClient'],
    'node_server': ['MediaNodeServer'],
    'node_client': ['SoundNodeClient', 'CameraNodeClient', 'MediaNodeClient'],
    'storage': ['SoundRecordStorage', 'CameraRecordStorage', 'SoundRecordFile', 'CameraRecordFile', 'RecordFile'],
    'record': ['SoundRecorder', 'CameraRecorder']
}

__all__ = list(itertools.chain(*__map__.values()))

def __getattr__(name):
    if name in __all__:
        for file, names in __map__.items():
            if name in names:
                module = importlib.import_module(f'.{file}', __name__)
                return getattr(module, name)
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")