From 966d2bcd4215f01032a67d3454120b3cc9a1fcf6 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 14 Sep 2009 20:50:25 +0000 Subject: [PATCH] Use new iter_objects methods svn: r13203 --- .../Rules/Person/_IsAncestorOfFilterMatch.py | 7 +- .../Rules/Person/_IsChildOfFilterMatch.py | 7 +- .../Person/_IsDescendantOfFilterMatch.py | 7 +- .../Rules/Person/_IsParentOfFilterMatch.py | 9 +- src/Merge/_MergePlace.py | 11 +- src/Merge/_MergeSource.py | 18 +-- src/PluginUtils/_GuiOptions.py | 3 +- src/ReportBase/_CommandLineReport.py | 8 +- src/gen/db/bsddbtxn.py | 12 +- src/plugins/BookReport.py | 3 +- src/plugins/gramplet/AgeStats.py | 7 +- src/plugins/gramplet/DataEntryGramplet.py | 3 +- src/plugins/gramplet/SurnameCloudGramplet.py | 22 ++-- src/plugins/gramplet/TopSurnamesGramplet.py | 21 ++-- src/plugins/quickview/AllNames.py | 4 +- src/plugins/quickview/FilterByName.py | 106 ++++++------------ src/plugins/textreport/Summary.py | 7 +- src/plugins/tool/EventNames.py | 6 +- src/plugins/tool/PatchNames.py | 5 +- src/plugins/tool/SoundGen.py | 3 +- 20 files changed, 98 insertions(+), 171 deletions(-) diff --git a/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py b/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py index 86c657dd5..7ce86efd8 100644 --- a/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py @@ -67,10 +67,9 @@ class IsAncestorOfFilterMatch(IsAncestorOf,MatchesFilter): filt = MatchesFilter(self.list[0:1]) filt.prepare(db) - for person_handle in db.iter_person_handles(): - person = db.get_person_from_handle( person_handle) - if filt.apply (db, person): - self.init_ancestor_list (db,person,first) + for person in db.iter_people(): + if filt.apply(db, person): + self.init_ancestor_list(db, person, first) filt.reset() def reset(self): diff --git a/src/Filters/Rules/Person/_IsChildOfFilterMatch.py b/src/Filters/Rules/Person/_IsChildOfFilterMatch.py index 60ce67ef0..3e3fcfb0b 100644 --- a/src/Filters/Rules/Person/_IsChildOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsChildOfFilterMatch.py @@ -53,10 +53,9 @@ class IsChildOfFilterMatch(MatchesFilter): self.map = {} filt = MatchesFilter(self.list) filt.prepare(db) - 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) + for person in db.iter_people(): + if filt.apply(db, person): + self.init_list(person) filt.reset() def reset(self): diff --git a/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py b/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py index a03833b1d..26beef83b 100644 --- a/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py @@ -67,10 +67,9 @@ class IsDescendantOfFilterMatch(IsDescendantOf,MatchesFilter): filt = MatchesFilter(self.list[0:1]) filt.prepare(db) - 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,first) + for person in db.iter_people(): + if filt.apply(db, person): + self.init_list(person, first) filt.reset() def reset(self): diff --git a/src/Filters/Rules/Person/_IsParentOfFilterMatch.py b/src/Filters/Rules/Person/_IsParentOfFilterMatch.py index 23e88a5fa..bf4b8c493 100644 --- a/src/Filters/Rules/Person/_IsParentOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsParentOfFilterMatch.py @@ -53,10 +53,9 @@ class IsParentOfFilterMatch(MatchesFilter): self.map = {} filt = MatchesFilter(self.list) filt.prepare(db) - 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) + for person in db.iter_people(): + if filt.apply(db, person): + self.init_list(person) filt.reset() def reset(self): @@ -68,6 +67,6 @@ class IsParentOfFilterMatch(MatchesFilter): def init_list(self,person): for fam_id in person.get_parent_family_handle_list(): fam = self.db.get_family_from_handle(fam_id) - for parent_id in [fam.get_father_handle (), fam.get_mother_handle ()]: + for parent_id in [fam.get_father_handle(), fam.get_mother_handle()]: if parent_id: self.map[parent_id] = 1 diff --git a/src/Merge/_MergePlace.py b/src/Merge/_MergePlace.py index 78b778965..8e539ea50 100644 --- a/src/Merge/_MergePlace.py +++ b/src/Merge/_MergePlace.py @@ -161,22 +161,21 @@ class MergePlaces(ManagedWindow.ManagedWindow): # replace references in other objetcs # people - for handle in self.db.iter_person_handles(): - person = self.db.get_person_from_handle(handle) + for person in self.db.iter_people(): if person.has_handle_reference('Place',self.old_handle): person.replace_handle_reference('Place', self.old_handle,self.new_handle) self.db.commit_person(person,trans) + # families - for handle in self.db.iter_family_handles(): - family = self.db.get_family_from_handle(handle) + for family in self.db.iter_families(): if family.has_handle_reference('Place',self.old_handle): family.replace_handle_reference('Place', self.old_handle,self.new_handle) self.db.commit_family(family,trans) + # events - for handle in self.db.get_event_handles(): - event = self.db.get_event_from_handle(handle) + for event in self.db.iter_events(): if event.has_handle_reference('Place',self.old_handle): event.replace_handle_reference('Place', self.old_handle,self.new_handle) diff --git a/src/Merge/_MergeSource.py b/src/Merge/_MergeSource.py index 9ba65e81d..f45ff4dbc 100644 --- a/src/Merge/_MergeSource.py +++ b/src/Merge/_MergeSource.py @@ -165,48 +165,42 @@ class MergeSources(ManagedWindow.ManagedWindow): # replace handles # people - for handle in self.db.iter_person_handles(): - person = self.db.get_person_from_handle(handle) + for person in self.db.iter_people(): if person.has_source_reference(self.old_handle): person.replace_source_references(self.old_handle, self.new_handle) self.db.commit_person(person,trans) # family - for handle in self.db.iter_family_handles(): - family = self.db.get_family_from_handle(handle) + for family in self.db.iter_families(): if family.has_source_reference(self.old_handle): family.replace_source_references(self.old_handle, self.new_handle) self.db.commit_family(family,trans) # events - for handle in self.db.get_event_handles(): - event = self.db.get_event_from_handle(handle) + for event in self.db.iter_events(): if event.has_source_reference(self.old_handle): event.replace_source_references(self.old_handle, self.new_handle) self.db.commit_event(event,trans) # sources - for handle in self.db.get_source_handles(): - source = self.db.get_source_from_handle(handle) + for source in self.db.iter_sources(): if source.has_source_reference(self.old_handle): source.replace_source_references(self.old_handle, self.new_handle) self.db.commit_source(source,trans) # places - for handle in self.iter.get_place_handles(): - place = self.db.get_place_from_handle(handle) + for place in self.db.iter_places(): if place.has_source_reference(self.old_handle): place.replace_source_references(self.old_handle, self.new_handle) self.db.commit_place(place,trans) # media - for handle in self.db.get_media_object_handles(): - obj = self.db.get_object_from_handle(handle) + for obj in self.db.iter_media_objects(): if obj.has_source_reference(self.old_handle): obj.replace_source_references(self.old_handle, self.new_handle) diff --git a/src/PluginUtils/_GuiOptions.py b/src/PluginUtils/_GuiOptions.py index 948ff3cac..5ec667f1a 100644 --- a/src/PluginUtils/_GuiOptions.py +++ b/src/PluginUtils/_GuiOptions.py @@ -111,9 +111,8 @@ class LastNameDialog(ManagedWindow.ManagedWindow): progress = ProgressMeter(_('Finding Surnames')) progress.set_pass(_('Finding surnames'), database.get_number_of_people()) - for person_handle in database.iter_person_handles(): + for person in database.iter_people(): progress.step() - person = database.get_person_from_handle(person_handle) key = person.get_primary_name().get_surname() count = 0 if key in surnames: diff --git a/src/ReportBase/_CommandLineReport.py b/src/ReportBase/_CommandLineReport.py index 2585c63e8..91462ef10 100644 --- a/src/ReportBase/_CommandLineReport.py +++ b/src/ReportBase/_CommandLineReport.py @@ -82,7 +82,7 @@ def _validate_options(options, dbase): if not person: person = dbase.get_default_person() if not person: - phandle = dbase.get_person_handles()[0] + phandle = dbase.iter_person_handles().next() person = dbase.get_person_from_handle(phandle) if not person: print "ERROR: Please specify a person" @@ -101,8 +101,7 @@ def _validate_options(options, dbase): if family_list: family_handle = family_list[0] else: - for family_handle in dbase.iter_family_handles(): - break + family_handle = dbase.iter_family_handles().next() if family_handle: family = dbase.get_family_from_handle(family_handle) option.set_value(family.get_gramps_id()) @@ -237,8 +236,7 @@ class CommandLineReport(object): self.options_help[name].append(id_list) elif isinstance(option, FamilyOption): id_list = [] - for fhandle in self.database.iter_family_handles(): - family = self.database.get_family_from_handle(fhandle) + for family in self.database.iter_families(): mname = "" fname = "" mhandle = family.get_mother_handle() diff --git a/src/gen/db/bsddbtxn.py b/src/gen/db/bsddbtxn.py index 884c580f4..f94e83f2b 100644 --- a/src/gen/db/bsddbtxn.py +++ b/src/gen/db/bsddbtxn.py @@ -165,29 +165,25 @@ class BSDDBTxn(object): """ Returns the data object associated with key """ - if txn == None: txn = self.txn - return self.db.get(key, default, txn, **kwargs) + return self.db.get(key, default, txn or self.txn, **kwargs) def pget(self, key, default=None, txn=None, **kwargs): """ Returns the primary key, given the secondary one, and associated data """ - if txn == None: txn = self.txn - return self.db.pget(key, default, txn, **kwargs) + return self.db.pget(key, default, txn or self.txn, **kwargs) def put(self, key, data, txn=None, **kwargs): """ Stores the key/data pair in the database """ - if txn == None: txn = self.txn - return self.db.put(key, data, txn, **kwargs) + return self.db.put(key, data, txn or self.txn, **kwargs) def delete(self, key, txn=None, **kwargs): """ Removes a key/data pair from the database """ - if txn == None: txn = self.txn - self.db.delete(key, txn, **kwargs) + self.db.delete(key, txn or self.txn, **kwargs) # test code if __name__ == "__main__": diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index c4a11c29a..f61d2f602 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -126,8 +126,7 @@ def _initialize_options(options, dbstate): if family_list: family_handle = family_list[0] else: - for family_handle in dbase.iter_family_handles(): - break + family_handle = dbase.iter_family_handles().next() family = dbase.get_family_from_handle(family_handle) option.set_value(family.get_gramps_id()) diff --git a/src/plugins/gramplet/AgeStats.py b/src/plugins/gramplet/AgeStats.py index 2bccf1eb5..1b63b6745 100644 --- a/src/plugins/gramplet/AgeStats.py +++ b/src/plugins/gramplet/AgeStats.py @@ -84,10 +84,9 @@ class AgeStatsGramplet(Gramplet): mother_handles = [[] for age in range(self.max_mother_diff)] father_handles = [[] for age in range(self.max_father_diff)] text = "" - handles = self.dbstate.db.iter_person_handles() - for h in handles: + + for p in self.dbstate.db.iter_people(): yield True - p = self.dbstate.db.get_person_from_handle(h) # if birth_date and death_date, compute age birth_ref = p.get_birth_ref() birth_date = None @@ -103,7 +102,7 @@ class AgeStatsGramplet(Gramplet): age = death_date.get_year() - birth_date.get_year() if age >= 0 and age < self.max_age: age_dict[age] = age_dict.get(age, 0) + 1 - age_handles[age].append(h) + age_handles[age].append(p.handle) #else: # print "Age out of range: %d for %s" % (age, # p.get_primary_name().get_first_name() diff --git a/src/plugins/gramplet/DataEntryGramplet.py b/src/plugins/gramplet/DataEntryGramplet.py index 2da311c28..c121eacba 100644 --- a/src/plugins/gramplet/DataEntryGramplet.py +++ b/src/plugins/gramplet/DataEntryGramplet.py @@ -283,8 +283,7 @@ class DataEntryGramplet(Gramplet): def get_or_create_place(self, place_name): if place_name == "": return (-1, None) - for place_handle in self.dbstate.db.iter_place_handles(): - place = self.dbstate.db.get_place_from_handle(place_handle) + for place in self.dbstate.db.iter_places(): if place.get_title().strip() == place_name: return (0, place) # (old, object) place = gen.lib.Place() diff --git a/src/plugins/gramplet/SurnameCloudGramplet.py b/src/plugins/gramplet/SurnameCloudGramplet.py index ab8f67c89..a573f18d7 100644 --- a/src/plugins/gramplet/SurnameCloudGramplet.py +++ b/src/plugins/gramplet/SurnameCloudGramplet.py @@ -78,22 +78,19 @@ class SurnameCloudGramplet(Gramplet): def main(self): self.set_text(_("Processing...") + "\n") yield True - people = self.dbstate.db.iter_person_handles() surnames = {} representative_handle = {} cnt = 0 - for person_handle in people: - person = self.dbstate.db.get_person_from_handle(person_handle) - if person: - allnames = [person.get_primary_name()] + person.get_alternate_names() - allnames = set([name.get_group_name().strip() for name in allnames]) - for surname in allnames: - surnames[surname] = surnames.get(surname, 0) + 1 - representative_handle[surname] = person_handle + for person in self.dbstate.db.iter_people(): + allnames = [person.get_primary_name()] + person.get_alternate_names() + allnames = set([name.get_group_name().strip() for name in allnames]) + for surname in allnames: + surnames[surname] = surnames.get(surname, 0) + 1 + representative_handle[surname] = person.handle + cnt += 1 if not cnt % _YIELD_INTERVAL: yield True - cnt += 1 total_people = cnt surname_sort = [] @@ -101,9 +98,9 @@ class SurnameCloudGramplet(Gramplet): for surname in surnames: surname_sort.append( (surnames[surname], surname) ) total += surnames[surname] + cnt += 1 if not cnt % _YIELD_INTERVAL: yield True - cnt += 1 total_surnames = cnt surname_sort.sort(reverse=True) @@ -114,8 +111,7 @@ class SurnameCloudGramplet(Gramplet): cloud_values.append( count ) cloud_names.sort(key=lambda k:k[1]) - counts = list(set(cloud_values)) - counts.sort(reverse=True) + counts = reversed(set(cloud_values)) line = 0 ### All done! # Now, find out how many we can display without going over top_size: diff --git a/src/plugins/gramplet/TopSurnamesGramplet.py b/src/plugins/gramplet/TopSurnamesGramplet.py index c37466944..30160a389 100644 --- a/src/plugins/gramplet/TopSurnamesGramplet.py +++ b/src/plugins/gramplet/TopSurnamesGramplet.py @@ -62,20 +62,17 @@ class TopSurnamesGramplet(Gramplet): def main(self): self.set_text(_("Processing...") + "\n") - people = self.dbstate.db.iter_person_handles() surnames = {} representative_handle = {} cnt = 0 - for person_handle in people: - person = self.dbstate.db.get_person_from_handle(person_handle) - if person: - cnt += 1 - allnames = [person.get_primary_name()] + person.get_alternate_names() - allnames = set([name.get_group_name().strip() for name in allnames]) - for surname in allnames: - surnames[surname] = surnames.get(surname, 0) + 1 - representative_handle[surname] = person_handle + for person in self.dbstate.db.iter_people(): + allnames = [person.get_primary_name()] + person.get_alternate_names() + allnames = set([name.get_group_name().strip() for name in allnames]) + for surname in allnames: + surnames[surname] = surnames.get(surname, 0) + 1 + representative_handle[surname] = person.handle + cnt += 1 if not cnt % _YIELD_INTERVAL: yield True @@ -83,9 +80,11 @@ class TopSurnamesGramplet(Gramplet): surname_sort = [] total = 0 - for cnt, surname in enumerate(surnames): + cnt = 0 + for surname in surnames: surname_sort.append( (surnames[surname], surname) ) total += surnames[surname] + cnt += 1 if not cnt % _YIELD_INTERVAL: yield True diff --git a/src/plugins/quickview/AllNames.py b/src/plugins/quickview/AllNames.py index 90dd15688..04c2e97d4 100644 --- a/src/plugins/quickview/AllNames.py +++ b/src/plugins/quickview/AllNames.py @@ -53,10 +53,8 @@ def run(database, document, *args, **kwargs): sdoc.paragraph("") matches = 0 stab.columns(_("Name"), _("Primary Name"), _("Name Type")) - people = database.iter_person_handles() names = [] # name, person - for person_handle in people: - person = database.get_person_from_handle(person_handle) + for person in database.iter_people(): primary_name = person.get_primary_name() if primary_name: names += [(nd.display_name(primary_name), diff --git a/src/plugins/quickview/FilterByName.py b/src/plugins/quickview/FilterByName.py index f7f55f44d..4ec710d8c 100644 --- a/src/plugins/quickview/FilterByName.py +++ b/src/plugins/quickview/FilterByName.py @@ -60,16 +60,13 @@ def run(database, document, filter_name, *args, **kwargs): matches = 0 if (filter_name == 'all people'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) + for person in database.iter_people(): stab.row(person, sdb.birth_date_obj(person), str(person.get_primary_name().get_type())) matches += 1 elif (filter_name == 'males'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) - people = database.iter_person_handles() - for person_handle in people: + for person in database.iter_people(): person = database.get_person_from_handle(person_handle) if person.gender == Person.MALE: stab.row(person, sdb.birth_date_obj(person), @@ -77,27 +74,21 @@ def run(database, document, filter_name, *args, **kwargs): matches += 1 elif (filter_name == 'females'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) + for person in database.iter_people(): if person.gender == Person.FEMALE: stab.row(person, sdb.birth_date_obj(person), str(person.get_primary_name().get_type())) matches += 1 elif (filter_name == 'people with unknown gender'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) + for person in database.iter_people(): if person.gender not in [Person.FEMALE, Person.MALE]: stab.row(person, sdb.birth_date_obj(person), str(person.get_primary_name().get_type())) matches += 1 elif (filter_name == 'people with incomplete names'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) + for person in database.iter_people(): for name in [person.get_primary_name()] + person.get_alternate_names(): if name.get_group_name() == "" or name.get_first_name() == "": stab.row(person, sdb.birth_date_obj(person), @@ -105,48 +96,36 @@ def run(database, document, filter_name, *args, **kwargs): matches += 1 elif (filter_name == 'people with missing birth dates'): stab.columns(_("Person"), _("Type")) - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) - if person: - birth_ref = person.get_birth_ref() - if birth_ref: - birth = database.get_event_from_handle(birth_ref.ref) - if not DateHandler.get_date(birth): - stab.row(person, _("birth event but no date")) - matches += 1 - else: - stab.row(person, _("missing birth event")) + for person in database.iter_people(): + birth_ref = person.get_birth_ref() + if birth_ref: + birth = database.get_event_from_handle(birth_ref.ref) + if not DateHandler.get_date(birth): + stab.row(person, _("birth event but no date")) matches += 1 + else: + stab.row(person, _("missing birth event")) + matches += 1 elif (filter_name == 'disconnected people'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) - if person: - if ((not person.get_main_parents_family_handle()) and - (not len(person.get_family_handle_list()))): - stab.row(person, sdb.birth_date_obj(person), - str(person.get_primary_name().get_type())) - matches += 1 - elif (filter_name == 'all families'): - familyList = database.iter_family_handles() - stab.columns(_("Family")) - for family_handle in familyList: - family = database.get_family_from_handle(family_handle) - if family: - stab.row(family) + for person in database.iter_people(): + if ((not person.get_main_parents_family_handle()) and + (not len(person.get_family_handle_list()))): + stab.row(person, sdb.birth_date_obj(person), + str(person.get_primary_name().get_type())) matches += 1 + elif (filter_name == 'all families'): + stab.columns(_("Family")) + for family in database.iter_families(): + stab.row(family) + matches += 1 elif (filter_name == 'unique surnames'): namelist = {} - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) - if person: - names = [person.get_primary_name()] + person.get_alternate_names() - surnames = list(set([name.get_group_name() for name in names])) - for surname in surnames: - namelist[surname] = namelist.get(surname, 0) + 1 + for person in database.iter_people(): + names = [person.get_primary_name()] + person.get_alternate_names() + surnames = list(set([name.get_group_name() for name in names])) + for surname in surnames: + namelist[surname] = namelist.get(surname, 0) + 1 stab.columns(_("Surname"), _("Count")) for name in sorted(namelist): stab.row(name, namelist[name]) @@ -158,39 +137,27 @@ def run(database, document, filter_name, *args, **kwargs): name)) elif (filter_name == 'people with media'): stab.columns(_("Person"), _("Media count")) - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) - if not person: - continue + for person in database.iter_people(): length = len(person.get_media_list()) if length > 0: stab.row(person, length) matches += 1 elif (filter_name == 'media references'): stab.columns(_("Person"), _("Reference")) - people = database.iter_person_handles() - for person_handle in people: - person = database.get_person_from_handle(person_handle) - if not person: - continue + for person in database.iter_people(): medialist = person.get_media_list() for item in medialist: stab.row(person, _("media")) matches += 1 elif (filter_name == 'unique media'): stab.columns(_("Unique Media")) - pobjects = database.get_media_object_handles() - for photo_id in database.get_media_object_handles(): - photo = database.get_object_from_handle(photo_id) + for photo in database.iter_media_objects(): fullname = media_path_full(database, photo.get_path()) stab.row(fullname) matches += 1 elif (filter_name == 'missing media'): stab.columns(_("Missing Media")) - pobjects = database.get_media_object_handles() - for photo_id in database.get_media_object_handles(): - photo = database.get_object_from_handle(photo_id) + for photo in database.iter_media_objects(): fullname = media_path_full(database, photo.get_path()) try: posixpath.getsize(fullname) @@ -199,9 +166,7 @@ def run(database, document, filter_name, *args, **kwargs): matches += 1 elif (filter_name == 'media by size'): stab.columns(_("Media"), _("Size in bytes")) - pobjects = database.get_media_object_handles() - for photo_id in database.get_media_object_handles(): - photo = database.get_object_from_handle(photo_id) + for photo in database.iter_media_objects(): fullname = media_path_full(database, photo.get_path()) try: bytes = posixpath.getsize(fullname) @@ -212,8 +177,7 @@ def run(database, document, filter_name, *args, **kwargs): elif (filter_name == 'list of people'): stab.columns(_("Person"), _("Birth Date"), _("Name type")) people = kwargs["handles"] - for person_handle in people: - person = database.get_person_from_handle(person_handle) + for person in database.iter_people(): stab.row(person, sdb.birth_date_obj(person), str(person.get_primary_name().get_type())) matches += 1 diff --git a/src/plugins/textreport/Summary.py b/src/plugins/textreport/Summary.py index d3ad3355f..7041db89e 100644 --- a/src/plugins/textreport/Summary.py +++ b/src/plugins/textreport/Summary.py @@ -100,12 +100,8 @@ class SummaryReport(Report): self.doc.write_text(_("Individuals")) self.doc.end_paragraph() - person_list = self.__db.iter_person_handles() num_people = 0 - for person_handle in person_list: - person = self.__db.get_person_from_handle(person_handle) - if not person: - continue + for person in self.__db.iter_people(): num_people += 1 # Count people with media. @@ -191,7 +187,6 @@ class SummaryReport(Report): self.doc.write_text(_("Family Information")) self.doc.end_paragraph() - family_list = self.__db.iter_family_handles() self.doc.start_paragraph("SR-Normal") self.doc.write_text(_("Number of families: %d") % self.__db.get_number_of_families()) self.doc.end_paragraph() diff --git a/src/plugins/tool/EventNames.py b/src/plugins/tool/EventNames.py index 234c8e66b..8afaeb825 100644 --- a/src/plugins/tool/EventNames.py +++ b/src/plugins/tool/EventNames.py @@ -83,8 +83,7 @@ class EventNames(Tool.BatchTool, ManagedWindow.ManagedWindow): self.change = False counter = 0 - for handle in self.db.iter_person_handles(): - person = self.db.get_person_from_handle(handle) + for person in self.db.iter_people(): for event_ref in person.get_event_ref_list(): if event_ref.get_role() == gen.lib.EventRoleType.PRIMARY: event_handle = event_ref.ref @@ -95,8 +94,7 @@ class EventNames(Tool.BatchTool, ManagedWindow.ManagedWindow): self.change = True counter += 1 - for handle in self.db.iter_family_handles(): - family = self.db.get_family_from_handle(handle) + for family in self.db.iter_families(): for event_ref in family.get_event_ref_list(): if event_ref.get_role() == gen.lib.EventRoleType.FAMILY: event_handle = event_ref.ref diff --git a/src/plugins/tool/PatchNames.py b/src/plugins/tool/PatchNames.py index b83a02ac3..0d989b757 100644 --- a/src/plugins/tool/PatchNames.py +++ b/src/plugins/tool/PatchNames.py @@ -122,9 +122,8 @@ class PatchNames(Tool.BatchTool, ManagedWindow.ManagedWindow): self.progress.set_pass(_('Analyzing names'), self.db.get_number_of_people()) - for key in self.db.iter_person_handles(): - - person = self.db.get_person_from_handle(key) + for person in self.db.iter_people(): + key = person.handle name = person.get_primary_name() first = name.get_first_name() sname = name.get_surname() diff --git a/src/plugins/tool/SoundGen.py b/src/plugins/tool/SoundGen.py index 73cd3147a..93ac285c1 100644 --- a/src/plugins/tool/SoundGen.py +++ b/src/plugins/tool/SoundGen.py @@ -76,8 +76,7 @@ class SoundGen(Tool.Tool, ManagedWindow.ManagedWindow): names = [] person = None - for person_handle in self.db.iter_person_handles(): - person = self.db.get_person_from_handle(person_handle) + for person in self.db.iter_people(): lastname = person.get_primary_name().get_surname() if lastname not in names: names.append(lastname)