From 2769b58a44acf7923e94ca62b9a52442e74e17fa Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Tue, 7 Jul 2009 18:58:47 +0000 Subject: [PATCH] Implement iter_people_handles methods and begin to use them - second batch of updates svn: r12774 --- src/FilterEditor/_FilterEditor.py | 2 +- .../Rules/Person/_HasCommonAncestorWithFilterMatch.py | 2 +- src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py | 2 +- src/Filters/Rules/Person/_IsChildOfFilterMatch.py | 2 +- src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py | 2 +- src/Filters/Rules/Person/_IsParentOfFilterMatch.py | 2 +- src/Filters/Rules/Person/_IsSiblingOfFilterMatch.py | 2 +- src/Filters/_GenericFilter.py | 7 ++----- src/Merge/_MergePlace.py | 2 +- src/Merge/_MergeSource.py | 2 +- 10 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/FilterEditor/_FilterEditor.py b/src/FilterEditor/_FilterEditor.py index 0ba9962db..0cb55c1fb 100644 --- a/src/FilterEditor/_FilterEditor.py +++ b/src/FilterEditor/_FilterEditor.py @@ -236,7 +236,7 @@ class FilterEditor(ManagedWindow.ManagedWindow): def get_all_handles(self): if self.namespace == 'Person': - return self.db.get_person_handles(sort_handles=False) + return self.db.iter_person_handles() elif self.namespace == 'Family': return self.db.get_family_handles() elif self.namespace == 'Event': diff --git a/src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py b/src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py index 1bd4117b2..0786434a4 100644 --- a/src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py +++ b/src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py @@ -59,7 +59,7 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith,MatchesFilter): filt = MatchesFilter(self.list) filt.prepare(db) def init(self, h): self.ancestor_cache[h] = 1 - for handle in db.get_person_handles(sort_handles=False): + for handle in db.iter_person_handles(sort_handles=False): if (handle not in self.ancestor_cache and filt.apply (db, db.get_person_from_handle(handle))): for_each_ancestor(db,[handle],init,self) diff --git a/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py b/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py index 0688f9a7d..6bf3e00d2 100644 --- a/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py @@ -67,7 +67,7 @@ class IsAncestorOfFilterMatch(IsAncestorOf,MatchesFilter): filt = MatchesFilter(self.list[0:1]) filt.prepare(db) - for person_handle in db.get_person_handles(sort_handles=False): + for person_handle in db.iter_person_handles(sort_handles=False): person = db.get_person_from_handle( person_handle) if filt.apply (db, person): self.init_ancestor_list (db,person,first) diff --git a/src/Filters/Rules/Person/_IsChildOfFilterMatch.py b/src/Filters/Rules/Person/_IsChildOfFilterMatch.py index ec8a4eb9a..e443f1deb 100644 --- a/src/Filters/Rules/Person/_IsChildOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsChildOfFilterMatch.py @@ -53,7 +53,7 @@ class IsChildOfFilterMatch(MatchesFilter): self.map = {} filt = MatchesFilter(self.list) filt.prepare(db) - for person_handle in db.get_person_handles(sort_handles=False): + for person_handle in db.iter_person_handles(sort_handles=False): person = db.get_person_from_handle( person_handle) if filt.apply (db, person): self.init_list (person) diff --git a/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py b/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py index fcc2f330d..e14661582 100644 --- a/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py @@ -67,7 +67,7 @@ class IsDescendantOfFilterMatch(IsDescendantOf,MatchesFilter): filt = MatchesFilter(self.list[0:1]) filt.prepare(db) - for person_handle in db.get_person_handles(sort_handles=False): + for person_handle in db.iter_person_handles(sort_handles=False): person = db.get_person_from_handle( person_handle) if filt.apply (db, person): self.init_list (person,first) diff --git a/src/Filters/Rules/Person/_IsParentOfFilterMatch.py b/src/Filters/Rules/Person/_IsParentOfFilterMatch.py index 5b71ddb72..113512fa1 100644 --- a/src/Filters/Rules/Person/_IsParentOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsParentOfFilterMatch.py @@ -53,7 +53,7 @@ class IsParentOfFilterMatch(MatchesFilter): self.map = {} filt = MatchesFilter(self.list) filt.prepare(db) - for person_handle in db.get_person_handles(sort_handles=False): + for person_handle in db.iter_person_handles(sort_handles=False): person = db.get_person_from_handle(person_handle) if filt.apply (db, person): self.init_list (person) diff --git a/src/Filters/Rules/Person/_IsSiblingOfFilterMatch.py b/src/Filters/Rules/Person/_IsSiblingOfFilterMatch.py index aacbf1858..690097587 100644 --- a/src/Filters/Rules/Person/_IsSiblingOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsSiblingOfFilterMatch.py @@ -52,7 +52,7 @@ class IsSiblingOfFilterMatch(MatchesFilter): self.map = {} filt = MatchesFilter(self.list) filt.prepare(db) - for person_handle in db.get_person_handles(sort_handles=False): + for person_handle in db.iter_person_handles(): person = db.get_person_from_handle( person_handle) if filt.apply (db, person): self.init_list (person) diff --git a/src/Filters/_GenericFilter.py b/src/Filters/_GenericFilter.py index bc22e4af7..b045ce46c 100644 --- a/src/Filters/_GenericFilter.py +++ b/src/Filters/_GenericFilter.py @@ -193,11 +193,8 @@ class GenericFilter(object): return count == 1 def or_test(self, db, person): - for rule in self.flist: - if rule.apply(db, person): - return True - return False - + return any(rule.apply(db, person) for rule in self.flist) + def get_check_func(self): try: m = getattr(self, 'check_' + self.logical_op) diff --git a/src/Merge/_MergePlace.py b/src/Merge/_MergePlace.py index e32d5b72d..73f3009f6 100644 --- a/src/Merge/_MergePlace.py +++ b/src/Merge/_MergePlace.py @@ -161,7 +161,7 @@ class MergePlaces(ManagedWindow.ManagedWindow): # replace references in other objetcs # people - for handle in self.db.get_person_handles(sort_handles=False): + for handle in self.db.iter_person_handles(): person = self.db.get_person_from_handle(handle) if person.has_handle_reference('Place',self.old_handle): person.replace_handle_reference('Place', diff --git a/src/Merge/_MergeSource.py b/src/Merge/_MergeSource.py index 07a3598d0..b979b80b3 100644 --- a/src/Merge/_MergeSource.py +++ b/src/Merge/_MergeSource.py @@ -165,7 +165,7 @@ class MergeSources(ManagedWindow.ManagedWindow): # replace handles # people - for handle in self.db.get_person_handles(sort_handles=False): + for handle in self.db.iter_person_handles(): person = self.db.get_person_from_handle(handle) if person.has_source_reference(self.old_handle): person.replace_source_references(self.old_handle,