bootstrap-vz/base/tasklist.py

31 lines
734 B
Python
Raw Normal View History

2013-06-09 20:29:54 +02:00
import logging
log = logging.getLogger(__name__)
2013-05-02 19:13:35 +02:00
class TaskList(object):
2013-05-16 08:00:28 +02:00
def __init__(self):
self.tasks = set()
def add(self, *args):
self.tasks.update(args)
def remove(self, task):
self.tasks.discard(self.get(task))
def replace(self, task, replacement):
self.remove(task)
self.add(replacement)
def get(self, task):
return next(task for task in self.tasks if type(task) is ref)
2013-05-16 08:00:28 +02:00
def run(self, bootstrap_info):
log.debug('Tasklist before:\n{list}'.format(list=',\n'.join(str(task) for task in self.tasks) ))
task_list = sorted(self.tasks)
log.debug('Tasklist:\n{list}'.format(list=',\n'.join(str(task) for task in task_list) ))
return
for task in tasks:
2013-06-09 20:29:54 +02:00
log.info(task)
2013-05-16 08:00:28 +02:00
task.run(bootstrap_info)