Given a list of classes inheriting from this base:
class Plugin(object):
run_after_plugins = ()
run_before_plugins = ()
...and the following rules:
- Plugins can provide a list of plugins that they must run after.
- Plugins can provide a list of plugins that they must run before.
- The list of plugins may or may not contain all plugins that have been specified in ordering constraints.
Can anyone provide a nice clean algorithm for ordering a list of plugins? It will need to detect circular dependencies as well....
def order_plugins(plugins):
pass
I've come up with a few versions but nothing particuarlly neat: I'm sure some of you Art of Computer Programming types will relish the challenge :)
[note: question given in Python but it's clearly not only a Python question: pseudocode in any language would do]