diff options
author | Anish Athalye <aathalye@me.com> | 2014-04-24 15:41:34 -0400 |
---|---|---|
committer | Anish Athalye <aathalye@me.com> | 2014-04-24 15:41:34 -0400 |
commit | e85dbfb7dd3d04a20e4d5990f7f0c01456e7b6d9 (patch) | |
tree | 570c7d6ec249c2d1216268b770371624c4abd438 /dotbot | |
parent | 564c1f13bf5baa452f2072153509ac291794f8b4 (diff) |
Remove code duplication in executors
Diffstat (limited to 'dotbot')
-rw-r--r-- | dotbot/executor/commandrunner.py | 6 | ||||
-rw-r--r-- | dotbot/executor/linker.py | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/dotbot/executor/commandrunner.py b/dotbot/executor/commandrunner.py index 3051ace..4ca6c83 100644 --- a/dotbot/executor/commandrunner.py +++ b/dotbot/executor/commandrunner.py @@ -6,11 +6,13 @@ class CommandRunner(Executor): Run arbitrary shell commands. ''' + _directive = 'shell' + def can_handle(self, directive): - return directive == 'shell' + return directive == self._directive def handle(self, directive, data): - if directive != 'shell': + if directive != self._directive: raise ValueError('CommandRunner cannot handle directive %s' % directive) return self._process_commands(data) diff --git a/dotbot/executor/linker.py b/dotbot/executor/linker.py index 9890ed5..662683f 100644 --- a/dotbot/executor/linker.py +++ b/dotbot/executor/linker.py @@ -6,11 +6,13 @@ class Linker(Executor): Symbolically links dotfiles. ''' + _directive = 'link' + def can_handle(self, directive): - return directive == 'link' + return directive == self._directive def handle(self, directive, data): - if directive != 'link': + if directive != self._directive: raise ValueError('Linker cannot handle directive %s' % directive) return self._process_links(data) |