]> scripts.mit.edu Git - wizard.git/blob - wizard/plugin.py
Fix bug where php.ini not being rewritten for MediaWiki.
[wizard.git] / wizard / plugin.py
1 """
2 Convenience methods for managing plugins.
3 """
4
5 import pkg_resources
6
7 def hook(name, args):
8     """
9     Runs plugins named ``name`` for this function.  Returns ``None`` if
10     all plugins return ``None``, otherwise returns the result of the
11     first plugin to result that is not ``None``. Assumes that plugins
12     are simple functions that take the arguments ``args``.
13     """
14     for entry in pkg_resources.iter_entry_points(name):
15         func = entry.load()
16         r = func(*args)
17         if r is not None:
18             return r
19     return None