| Total Complexity | 2 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import attr |
||
| 2 | |||
| 3 | from so_magic.utils import SubclassRegistry |
||
| 4 | |||
| 5 | |||
| 6 | class EngineTabularRetriever(metaclass=SubclassRegistry): pass |
||
| 7 | |||
| 8 | |||
| 9 | class EngineTabularIterator(metaclass=SubclassRegistry): pass |
||
| 10 | |||
| 11 | |||
| 12 | class EngineTabularMutator(metaclass=SubclassRegistry): pass |
||
| 13 | |||
| 14 | |||
| 15 | @attr.s |
||
| 16 | class BackendSpecifications: |
||
| 17 | name_abbreviation = attr.ib(init=True) |
||
| 18 | name = attr.ib(init=True, default=attr.Factory(lambda self: self.name_abbreviation, takes_self=True)) |
||
| 19 | |||
| 20 | def __call__(self, *args, **kwargs): |
||
| 21 | backend = args[0] |
||
| 22 | backend.retriever = EngineTabularRetriever.subclasses[self.name_abbreviation] |
||
| 23 | backend.iterator = EngineTabularIterator.subclasses[self.name_abbreviation] |
||
| 24 | backend.mutator = EngineTabularMutator.subclasses[self.name_abbreviation] |
||
| 25 | backend.id = self.name_abbreviation |
||
| 26 | |||
| 27 | @classmethod |
||
| 28 | def from_dict(cls, a_dict): |
||
| 29 | return BackendSpecifications(a_dict['id'], a_dict.get('name', a_dict['id'])) |
||
| 30 |