qtutils: simplify the BlockSignals implementation
[git-cola.git] / cola / cmd.py
blobb854f9e799410bde9b8e842c71282db801eb4920
1 """Base Command class"""
2 from __future__ import division, absolute_import, unicode_literals
5 class Command(object):
6 """Mixin interface for commands"""
8 UNDOABLE = False
10 @staticmethod
11 def name():
12 """Return the command's name"""
13 return '(undefined)'
15 @classmethod
16 def is_undoable(cls):
17 """Can this be undone?"""
18 return cls.UNDOABLE
20 # pylint: disable=no-self-use
21 def do(self):
22 """Execute the command"""
23 return
25 # pylint: disable=no-self-use
26 def undo(self):
27 """Undo the command"""
28 return
31 class ContextCommand(Command):
32 """Base class for commands that operate on a context"""
34 def __init__(self, context):
35 self.context = context
36 self.model = context.model
37 self.cfg = context.cfg
38 self.git = context.git
39 self.selection = context.selection
40 self.fsmonitor = context.fsmonitor