--- a/pyscovery.py Sun Apr 14 02:59:18 2013 -0500
+++ b/pyscovery.py Sun Apr 14 02:59:31 2013 -0500
@@ -23,35 +23,8 @@
I wrote this because none of the existing solutions fit my need of being able
to logically group similar plugins in the filesystem.
-Say you have the following structure in your project:
-With pyscovery, the following code will find plugins 1, 2, and 3 for you:
- from plugin import Plugin
- pyscovery.add_module('plugins')
- for plugin in pyscovery.find(Plugin, recurse=True):
-Recursion in the filesystem is off by default, since that's the way people are
-used to. If there is enough demand, I will make it the default.
@@ -62,11 +35,13 @@
- Adds a module to search for plugins under
+ """Adds a module to search for plugins under + :param module: The module to add to the search paths global MODULES # pylint:disable-msg=W0602
@@ -76,8 +51,10 @@
def remove_module(module):
- Removes a module to search for plugins under
+ """Removes a module to search for plugins under + :param module: The module to remove global MODULES # pylint:disable-msg=W0602
@@ -87,31 +64,37 @@
- Returns the list of all module to search under
+ """Returns the list of all module to search under + :returns: A list of the current modules used for searching
- Clears all search modules
+ """Clears all search modules def find(cls, recurse, create, *args, **kwargs):
- Find all plugins that are subclasses of cls in the current search paths
+ """Find all plugins that are subclasses of cls in the current search paths - If recurse is set to true, all files under a package will be inspected as
- If create is set to true, instances of the classes will be returned instead
- of the class itself. Note that *args and **kwargs will passed directly to
- the classes __init__ method.
+ :param cls: The class whose subclasses to find. + :param recurse: Whether or not to recurse into packages. + :param create: return instances rather than just return their class. + :param args: Additional arguments to pass to each constructor. Ignored if + :param kwargs: Additional keyword arguements to pass to each constructor. + Ignored if create is False. + :returns: Generator of subclasses of cls if not inspect.isclass(cls):
@@ -182,5 +165,5 @@
add_module(make_module(base))
-__all__ = [add_module, remove_module, get_modules, clear_modules, find]
+#__all__ = [add_module, remove_module, get_modules, clear_modules, find]