Remove code duplication in executors
This commit is contained in:
parent
564c1f13bf
commit
e85dbfb7dd
2 changed files with 8 additions and 4 deletions
|
@ -6,11 +6,13 @@ class CommandRunner(Executor):
|
||||||
Run arbitrary shell commands.
|
Run arbitrary shell commands.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
_directive = 'shell'
|
||||||
|
|
||||||
def can_handle(self, directive):
|
def can_handle(self, directive):
|
||||||
return directive == 'shell'
|
return directive == self._directive
|
||||||
|
|
||||||
def handle(self, directive, data):
|
def handle(self, directive, data):
|
||||||
if directive != 'shell':
|
if directive != self._directive:
|
||||||
raise ValueError('CommandRunner cannot handle directive %s' %
|
raise ValueError('CommandRunner cannot handle directive %s' %
|
||||||
directive)
|
directive)
|
||||||
return self._process_commands(data)
|
return self._process_commands(data)
|
||||||
|
|
|
@ -6,11 +6,13 @@ class Linker(Executor):
|
||||||
Symbolically links dotfiles.
|
Symbolically links dotfiles.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
_directive = 'link'
|
||||||
|
|
||||||
def can_handle(self, directive):
|
def can_handle(self, directive):
|
||||||
return directive == 'link'
|
return directive == self._directive
|
||||||
|
|
||||||
def handle(self, directive, data):
|
def handle(self, directive, data):
|
||||||
if directive != 'link':
|
if directive != self._directive:
|
||||||
raise ValueError('Linker cannot handle directive %s' % directive)
|
raise ValueError('Linker cannot handle directive %s' % directive)
|
||||||
return self._process_links(data)
|
return self._process_links(data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue