| Total Complexity | 6 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import attr |
||
| 2 | import abc |
||
| 3 | |||
| 4 | |||
| 5 | class Backend(abc.ABC): |
||
| 6 | subclasses = {} |
||
| 7 | |||
| 8 | @classmethod |
||
| 9 | def register_as_subclass(cls, backend_type): |
||
| 10 | def wrapper(subclass): |
||
| 11 | cls.subclasses[backend_type] = subclass |
||
| 12 | return subclass |
||
| 13 | return wrapper |
||
| 14 | |||
| 15 | @classmethod |
||
| 16 | def create(cls, backend_type, *args, **kwargs): |
||
| 17 | if backend_type not in cls.subclasses: |
||
| 18 | raise ValueError('Bad "Data Backend type" type \'{}\''.format(backend_type)) |
||
| 19 | return cls.subclasses[backend_type](*args, **kwargs) |
||
| 20 | |||
| 21 | @property |
||
| 22 | @abc.abstractmethod |
||
| 23 | def features_factory(self): |
||
| 24 | raise NotImplementedError |
||
| 25 | |||
| 26 | @property |
||
| 27 | @abc.abstractmethod |
||
| 28 | def commands_manager(self): |
||
| 29 | raise NotImplementedError |
||
| 30 | |||
| 31 | @property |
||
| 32 | @abc.abstractmethod |
||
| 33 | def computing(self): |
||
| 34 | raise NotImplementedError |
||
| 35 |