From a1391bf06a839746bd902dd7cba2c63d1e738d37 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 27 Nov 2009 11:07:26 +0100 Subject: ItemTraversal: Predicate and prune functions now provide depth information, allowing the callee to know more about its environment --- lib/git/objects/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/git/objects/utils.py') diff --git a/lib/git/objects/utils.py b/lib/git/objects/utils.py index 18968c0f..a3c6edc7 100644 --- a/lib/git/objects/utils.py +++ b/lib/git/objects/utils.py @@ -90,18 +90,18 @@ class Traversable(object): raise NotImplementedError("To be implemented in subclass") - def traverse( self, predicate = lambda i: True, - prune = lambda i: False, depth = -1, branch_first=True, + def traverse( self, predicate = lambda i,d: True, + prune = lambda i,d: False, depth = -1, branch_first=True, visit_once = True, ignore_self=1 ): """ ``Returns`` iterator yieling of items found when traversing self ``predicate`` - f(i) returns False if item i should not be included in the result + f(i,d) returns False if item i at depth d should not be included in the result ``prune`` - f(i) return True if the search should stop at item i. + f(i,d) return True if the search should stop at item i at depth d. Item i will not be returned. ``depth`` @@ -132,11 +132,11 @@ class Traversable(object): while stack: d, item = stack.pop() # depth of item, item - if prune( item ): + if prune( item, d ): continue skipStartItem = ignore_self and ( item == self ) - if not skipStartItem and predicate( item ): + if not skipStartItem and predicate( item, d ): yield item # only continue to next level if this is appropriate ! -- cgit v1.2.1