def delegates(task_that_delegates):
 if (not hasattr(task_that_delegates, 'subtasks')):
  raise AttributeError(('%s needs to implement the method "subtasks"' % task_that_delegates))
 @task._task_wraps(task_that_delegates)
 class Wrapped(task_that_delegates, ):
  def deps(self):
   return (task.flatten(self.requires()) + task.flatten([t.deps() for t in task.flatten(self.subtasks())]))
  def run(self):
   for t in task.flatten(self.subtasks()):
    t.run()
   task_that_delegates.run(self)
 return Wrapped

def delegates ( task_that_delegates ) : if ( not hasattr ( task_that_delegates , 'subtasks' ) ) : raise AttributeError ( ( '%s needs to implement the method "subtasks"' % task_that_delegates ) ) @ task . _task_wraps ( task_that_delegates ) class Wrapped ( task_that_delegates , ) : def deps ( self ) : return ( task . flatten ( self . requires ( ) ) + task . flatten ( [ t . deps ( ) for t in task . flatten ( self . subtasks ( ) ) ] ) ) def run ( self ) : for t in task . flatten ( self . subtasks ( ) ) : t . run ( ) task_that_delegates . run ( self ) return Wrapped
lets a task call methods on subtask(s) .