mirror of
1
0
Fork 0

Remove code duplication in executors

This commit is contained in:
Anish Athalye 2014-04-24 15:41:34 -04:00
parent 564c1f13bf
commit e85dbfb7dd
2 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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)