UndoableCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 4
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A undo() 0 3 1
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