Details
-
Task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Gump3-alpha-4
-
None
Description
We need a convention between plugins that enables them to communicate about the state of the tree, and make somewhat intelligent decisions about what to build and what not to build. Ideally that is extracted nearly completely into a few "policy" or "algorithm" plugins.
Perhaps
{{{
class DependencyStateVerifierPlugin(AbstractPlugin):
def visit_project(p):
for rel in p.dependencies:
if p.rel.dependency.state == FAILED:
p.state == PREREQ_FAILURE
class AbstractBuilderPlugin(AbstractPlugin):
def visit_project(p):
if not p.rel.dependency.state == PREREQ_FAILURE and getattr(self, "do_build", None):
self.do_build(p)
- NB: MkdirPlugin doesn't need to know about project states, but it still depends on the policy in
- AbstractBuilderPlugin
class MkdirPlugin(AbstractBuilderPlugin):
def do_filter(p):
for c in p.commands:
if isinstance(c,gump.model.Mkdir)
yield c
def do_build(p):
for c in do_filter(p):
raise NotImplementedError, "TODO: actually create a directory here"
}}}
Or maybe we'd like
{{{
class DependencyStateVerifierPlugin(AbstractPlugin):
def visit_project(p):
for rel in p.dependencies:
if p.rel.dependency.state <= FAILED:
p.state == PREREQ_FAILURE
class StateAwareWalker(Walker):
def filter_walk(visitor,project):
if project.state <= FAILED and not has_attribute(visitor.visit_project, "visit_failed"):
return
yield y
- NB: the builder plugins are now cleaner again but the mkdir plugin knows that
- it only wants to visit successful projects...
class MkdirPlugin(AbstractPlugin):
@visit_failed
visit_project(p):
raise NotImplementedError, "TODO: actually create a directory here"
}}}
hmm. It might make sense to have a FilteringWalker that supports a different kind of plugin, where that plugin can tell the walker to not walk some projects. Ugh!
I have a hunch that the real thing to do here is get up to speed on all python's fancy list comprehensions, generators and generator expressions. There's probably a real elegant way to do this...