Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Docstings on manager helper methods.

  • Loading branch information...
commit 85c292b4dd069ce68e35b12d58f67b4861f43bea 1 parent dc69b89
ironfroggy authored July 01, 2012

Showing 1 changed file with 17 additions and 0 deletions. Show diff stats Hide diff stats

  1. 17  straight/plugin/manager.py
17  straight/plugin/manager.py
@@ -24,6 +24,10 @@ def __getitem__(self, index):
24 24
         return self._plugins[index]
25 25
 
26 26
     def produce(self, *args, **kwargs):
  27
+        """Produce a new set of plugins, treating the current set as plugin
  28
+        factories.
  29
+        """
  30
+
27 31
         new_plugin_set = PluginManager()
28 32
         for p in self._plugins:
29 33
             r = p(*args, **kwargs)
@@ -31,6 +35,8 @@ def produce(self, *args, **kwargs):
31 35
         return new_plugin_set
32 36
 
33 37
     def call(self, method, *args, **kwargs):
  38
+        """Call a common method on all the plugins, if it exists."""
  39
+
34 40
         for plugin in self._plugins:
35 41
             method = getattr(plugin, method, None)
36 42
             if method is None:
@@ -38,6 +44,10 @@ def call(self, method, *args, **kwargs):
38 44
             yield method(*args, **kwargs)
39 45
 
40 46
     def first(self, method, *args, **kwargs):
  47
+        """Call a common method on all the plugins, if it exists. Return the
  48
+        first result (the first non-None)
  49
+        """
  50
+
41 51
         for r in self.call(method, *args, **kwargs):
42 52
             if r is not None:
43 53
                 return r
@@ -45,6 +55,13 @@ def first(self, method, *args, **kwargs):
45 55
         raise ValueError("No plugins returned a non-None value")
46 56
 
47 57
     def pipe(self, methodname, first_arg, *args, **kwargs):
  58
+        """Call a common method on all the plugins, if it exists. The return
  59
+        value of each call becomes the replaces the first argument in the given
  60
+        argument list to pass to the next.
  61
+
  62
+        Useful to utilize plugins as sets of filters.
  63
+        """
  64
+
48 65
         for plugin in self._plugins:
49 66
             method = getattr(plugin, methodname, None)
50 67
             if method is None:

0 notes on commit 85c292b

Please sign in to comment.
Something went wrong with that request. Please try again.