| Total Complexity | 5 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from abc import ABC, abstractmethod |
||
| 2 | |||
| 3 | from data.features.features import TrackingFeature |
||
| 4 | |||
| 5 | |||
| 6 | class AbstractFeatureFactory(ABC): |
||
| 7 | @abstractmethod |
||
| 8 | def get_feature(self, *args, **kwargs) -> TrackingFeature: |
||
| 9 | raise NotImplementedError |
||
| 10 | |||
| 11 | |||
| 12 | class FeatureFactory(AbstractFeatureFactory): |
||
| 13 | |||
| 14 | @classmethod |
||
| 15 | def register_as_subclass(cls, backend_type): |
||
| 16 | def wrapper(subclass): |
||
| 17 | cls.subclasses[backend_type] = subclass |
||
| 18 | return subclass |
||
| 19 | |||
| 20 | return wrapper |
||
| 21 | |||
| 22 | @classmethod |
||
| 23 | def create(cls, backend_type, *args, **kwargs): |
||
| 24 | if backend_type not in cls.subclasses: |
||
| 25 | raise ValueError('Bad "BinnerFactory Backend type" type \'{}\''.format(backend_type)) |
||
| 26 | return cls.subclasses[backend_type](*args, **kwargs) |
||
| 27 | |||
| 28 | def get_feature(self, *args, **kwargs) -> TrackingFeature: |
||
| 29 | raise NotImplementedError |
||
| 30 |