summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2013-11-14 17:45:27 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2013-11-14 17:45:27 +0000
commit6fac8e7fe0749c9825412234c9f6d910d9a7d762 (patch)
tree5ccc8bd72cabd15d0143bcbf3ac6961b80170196
parent0b3ec68ce46f638e79e52f9f97f26727d9c4daa1 (diff)
downloadmorph-richardipsum/fix_traverse_morphs.tar.gz
Replace lambda with conditionalrichardipsum/fix_traverse_morphs
A visit function can optionally be given to traverse_morphs to be called on each morph traverse_morph visits. The current lambda definition has the wrong number of args. Using a lambda as the default arg means that the number of args the lambda takes has to be updated whenever the visit function requires more args. Getting rid of the lambda rids us of this extra maintenance.
-rw-r--r--morphlib/app.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index aecee42b..87dcb6dd 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -315,8 +315,7 @@ class Morph(cliapp.Application):
absref, tree = repo.resolve_ref(ref)
return absref, tree
- def traverse_morphs(self, triplets, lrc, rrc, update=True,
- visit=lambda rn, rf, fn, arf, m: None):
+ def traverse_morphs(self, triplets, lrc, rrc, update=True, visit):
morph_factory = morphlib.morphologyfactory.MorphologyFactory(lrc, rrc,
self)
queue = collections.deque(triplets)
@@ -344,7 +343,9 @@ class Morph(cliapp.Application):
morph_factory.get_morphology(reponame, absref, filename)
morphology = resolved_morphologies[reference]
- visit(reponame, ref, filename, absref, tree, morphology)
+ if visit:
+ visit(reponame, ref, filename, absref, tree, morphology)
+
if morphology['kind'] == 'system':
queue.extend((s['repo'] or reponame,
s['ref'] or ref,