From e85dbfb7dd3d04a20e4d5990f7f0c01456e7b6d9 Mon Sep 17 00:00:00 2001 From: Anish Athalye Date: Thu, 24 Apr 2014 15:41:34 -0400 Subject: [PATCH] Remove code duplication in executors --- dotbot/executor/commandrunner.py | 6 ++++-- 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)