Passed
Push — dev ( 1b3874...6a1e3c )
by Konstantinos
03:33
created

green_magic.data.data_manager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 26
dl 0
loc 36
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A DataManager.__attrs_post_init__() 0 2 1
A DataMediator.notify() 0 2 1
A DataManager.commands() 0 3 1
A DataManager.command() 0 3 1
A DataMediator.__init__() 0 2 1
1
import attr
2
from green_magic.utils import GenericMediator, BaseComponent
3
from enum import Enum
4
5
6
class MediatorEvent(Enum):
7
    A = 'A'
8
    B = 'B'
9
    C = 'C'
10
11
12
class DataMediator(GenericMediator):
13
    def __init__(self, *args, **kwargs):
14
        self.events = kwargs.get('events', {})
15
16
    def notify(self, sender: object, event: str) -> None:
17
        pass
18
19
20
@attr.s
21
class DataManager:
22
    commands_manager = attr.ib(init=True)
23
    backend = attr.ib(init=True)
24
    mediator = attr.ib(init=False, default=None)
25
26
    def __attrs_post_init__(self):
27
        self.mediator = DataMediator(self.commands_manager, self.backend)
28
29
    @property
30
    def commands(self):
31
        return self.commands_manager.commands_dict
32
33
    @property
34
    def command(self):
35
        return self.commands_manager.command