CommandManager.__init__()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
1
from abc import abstractmethod
2
3
4
class Command(object):
5
    @abstractmethod
6
    def do(self):
7
        pass
8
9
10
class UndoableCommand(object):
11
    @abstractmethod
12
    def undo(self):
13
        pass
14
15
16
class CommandManager(object):
17
    def __init__(self, stack):
18
        self.stack = stack
19
20
    def execute(self, command):
21
        self.stack.push(command)
22
        command.do()
23
24
    def undo(self):
25
        if self.stack.count > 0:
26
            self.stack.pop().undo()
27