diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-27 11:07:26 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-27 11:22:40 +0100 |
commit | a1391bf06a839746bd902dd7cba2c63d1e738d37 (patch) | |
tree | eb2b4913633127d939ee17908218b4c4097367e0 /lib/git/objects | |
parent | f28a2041f707986b65dbcdb4bb363bb39e4b3f77 (diff) | |
download | gitpython-a1391bf06a839746bd902dd7cba2c63d1e738d37.tar.gz |
ItemTraversal: Predicate and prune functions now provide depth information, allowing the callee to know more about its environment
Diffstat (limited to 'lib/git/objects')
-rw-r--r-- | lib/git/objects/utils.py | 12 |
1 files changed, 6 insertions, 6 deletions
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 ! |