1
0
Fork 0
mirror of synced 2024-11-22 08:15:34 -05:00

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

View file

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