bootstrap-vz/base/tasklist.py

26 lines
648 B
Python
Raw Normal View History

2013-05-02 19:13:35 +02:00
class TaskList(list):
2013-05-16 08:00:28 +02:00
def plugins(self, manifest):
for plugin in manifest.loaded_plugins:
plugin.modify_tasklist(self, manifest)
def run(self, bootstrap_info):
2013-05-02 19:13:35 +02:00
for task in self:
2013-06-09 18:25:35 +02:00
print('Running {taskname}'.format(taskname=task))
2013-05-16 08:00:28 +02:00
task.run(bootstrap_info)
2013-05-02 19:13:35 +02:00
2013-05-16 08:00:28 +02:00
def before(self, ref, task):
i = next(i for i, task in enumerate(self) if type(task) is ref)
self.insert(i, task)
2013-05-02 19:13:35 +02:00
2013-05-16 08:00:28 +02:00
def replace(self, ref, task):
i = next(i for i, task in enumerate(self) if type(task) is ref)
self.pop(i)
self.insert(i, task)
2013-05-02 19:13:35 +02:00
2013-05-16 08:00:28 +02:00
def after(self, ref, task):
i = next(i for i, task in enumerate(self) if type(task) is ref)
self.insert(i+1, task)