Replace get_family_handles with iter_family_handles

svn: r12776
This commit is contained in:
Gerald Britton 2009-07-08 16:11:20 +00:00
parent f680992d04
commit b601f4bdf2
21 changed files with 53 additions and 29 deletions

View File

@ -238,7 +238,7 @@ class FilterEditor(ManagedWindow.ManagedWindow):
if self.namespace == 'Person':
return self.db.iter_person_handles()
elif self.namespace == 'Family':
return self.db.get_family_handles()
return self.db.iter_family_handles()
elif self.namespace == 'Event':
return self.db.get_event_handles()
elif self.namespace == 'Source':

View File

@ -168,7 +168,7 @@ class MergePlaces(ManagedWindow.ManagedWindow):
self.old_handle,self.new_handle)
self.db.commit_person(person,trans)
# families
for handle in self.db.get_family_handles():
for handle in self.db.iter_family_handles():
family = self.db.get_family_from_handle(handle)
if family.has_handle_reference('Place',self.old_handle):
family.replace_handle_reference('Place',

View File

@ -173,7 +173,7 @@ class MergeSources(ManagedWindow.ManagedWindow):
self.db.commit_person(person,trans)
# family
for handle in self.db.get_family_handles():
for handle in self.db.iter_family_handles():
family = self.db.get_family_from_handle(handle)
if family.has_source_reference(self.old_handle):
family.replace_source_references(self.old_handle,

View File

@ -551,10 +551,8 @@ class GuiFamilyOption(gtk.HBox):
if not family_list:
# Finally, take any family you can find.
family_list = self.__db.get_family_handles()
if family_list:
family = self.__db.get_family_from_handle(family_list[0])
for family in self.__db.iter_family_handles():
break
self.__update_family(family)
def __get_family_clicked(self, obj): # IGNORE:W0613 - obj is unused

View File

@ -93,7 +93,8 @@ def _validate_options(options, dbase):
if family_list:
family_handle = family_list[0]
else:
family_handle = dbase.get_family_handles()[0]
for family_handle in dbase.iter_family_handles():
break
family = dbase.get_family_from_handle(family_handle)
option.set_value(family.get_gramps_id())
@ -224,7 +225,7 @@ class CommandLineReport(object):
self.options_help[name].append(id_list)
elif isinstance(option, gen.plug.menu.FamilyOption):
id_list = []
for fhandle in self.database.get_family_handles():
for fhandle in self.database.iter_family_handles():
family = self.database.get_family_from_handle(fhandle)
mname = ""
fname = ""

View File

@ -230,7 +230,7 @@ class LivingProxyDb(ProxyDbBase):
def iter_person_handles(self):
"""
Return an iterator over database handles, one handle for each Person in
the database. If sort_handles is True, the list is sorted by surnames
the database.
"""
if self.mode == self.MODE_EXCLUDE_ALL:
for handle in self.db.iter_person_handles():
@ -238,7 +238,7 @@ class LivingProxyDb(ProxyDbBase):
if not self.__is_living(person):
yield handle
else:
handles = self.db.iter_person_handles()
return self.db.iter_person_handles()
def get_place_handles(self, sort_handles=True):
"""
@ -277,6 +277,13 @@ class LivingProxyDb(ProxyDbBase):
"""
return self.db.get_family_handles()
def iter_family_handles(self):
"""
Return an iterator over database handles, one handle for each Family in
the database..
"""
return self.db.iter_family_handles()
def get_repository_handles(self):
"""
Return a list of database handles, one handle for each Repository in

View File

@ -284,12 +284,22 @@ class PrivateProxyDb(ProxyDbBase):
the database.
"""
handles = []
for handle in self.db.get_family_handles():
for handle in self.db.iter_family_handles():
family = self.db.get_family_from_handle(handle)
if not family.get_privacy():
handles.append(handle)
return handles
def iter_family_handles(self):
"""
Return an iterator over database handles, one handle for each Family in
the database.
"""
for handle in self.db.iter_family_handles():
family = self.db.get_family_from_handle(handle)
if not family.get_privacy():
yield handle
def get_repository_handles(self):
"""
Return a list of database handles, one handle for each Repository in

View File

@ -221,6 +221,13 @@ class ReferencedProxyDb(ProxyDbBase):
"""
return self.db.get_family_handles()
def iter_family_handles(self):
"""
Return an iterator over database handles, one handle for each Family in
the database..
"""
return self.db.iter_family_handles()
def get_repository_handles(self):
"""
Return a list of database handles, one handle for each Repository still
@ -254,7 +261,7 @@ class ReferencedProxyDb(ProxyDbBase):
"""
returns True if the handle exists in the current Person database.
"""
return handle in self.get_person_handles()
return handle in self.iter_person_handles()
def has_event_handle(self, handle):
"""
@ -278,7 +285,7 @@ class ReferencedProxyDb(ProxyDbBase):
"""
returns True if the handle exists in the current Family database.
"""
return handle in self.get_family_handles()
return handle in self.iter_family_handles()
def has_object_handle(self, handle):
"""

View File

@ -123,7 +123,8 @@ def _initialize_options(options, dbstate):
if family_list:
family_handle = family_list[0]
else:
family_handle = dbase.get_family_handles()[0]
for family_handle in dbase.iter_family_handles():
break
family = dbase.get_family_from_handle(family_handle)
option.set_value(family.get_gramps_id())

View File

@ -196,7 +196,7 @@ def _find_records(db, filter, callname):
family_shortest = []
family_longest = []
for family_handle in db.get_family_handles():
for family_handle in db.iter_family_handles():
family = db.get_family_from_handle(family_handle)
father_handle = family.get_father_handle()

View File

@ -176,7 +176,7 @@ class PackageWriter(object):
#--------------------------------------------------------
def remove_clicked():
# File is lost => remove all references and the object itself
for p_id in self.db.get_family_handles():
for p_id in self.db.iter_family_handles():
p = self.db.get_family_from_handle(p_id)
nl = p.get_media_list()
for o in nl:

View File

@ -263,7 +263,7 @@ class CSVWriter(object):
for family_handle in p.get_family_handle_list():
self.flist[family_handle] = 1
# now add the families for which these people are a child:
family_handles = self.db.get_family_handles()
family_handles = self.db.iter_family_handles()
for family_handle in family_handles:
family = self.db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list():

View File

@ -918,7 +918,7 @@ class GedcomWriter(BasicUtils.UpdateCallback):
# generate a list of (GRAMPS_ID, HANDLE) pairs. This list
# can then be sorted by the sort routine, which will use the
# first value of the tuple as the sort key.
sorted_list = sort_handles_by_id(self.dbase.get_family_handles(),
sorted_list = sort_handles_by_id(self.dbase.iter_family_handles(),
self.dbase.get_family_from_handle)
# loop through the sorted list, pulling of the handle. This list

View File

@ -114,7 +114,7 @@ class PackageWriter(object):
#--------------------------------------------------------------
def remove_clicked():
# File is lost => remove all references and the object itself
for p_id in self.db.get_family_handles():
for p_id in self.db.iter_family_handles():
p = self.db.get_family_from_handle(p_id)
nl = p.get_media_list()
for o in nl:

View File

@ -251,7 +251,7 @@ class GrampsDbXmlWriter(UpdateCallback):
if family_len > 0:
self.g.write(" <families>\n")
for handle in self.db.get_family_handles():
for handle in self.db.iter_family_handles():
family = self.db.get_family_from_handle(handle)
self.write_family(family,2)
self.update()

View File

@ -67,7 +67,7 @@ class StatsGramplet(Gramplet):
self.set_text(_("Processing..."))
database = self.dbstate.db
personList = database.iter_person_handles()
familyList = database.get_family_handles()
familyList = database.iter_family_handles()
with_photos = 0
total_photos = 0
@ -160,7 +160,7 @@ class StatsGramplet(Gramplet):
self.append_text("----------------------------\n")
self.link("%s:" % _("Number of families"),
'Filter', 'all families')
self.append_text(" %s" % len(familyList))
self.append_text(" %s" % database.get_number_of_families())
self.append_text("\n")
self.link("%s:" % _("Unique surnames"),
'Filter', 'unique surnames')

View File

@ -130,7 +130,7 @@ def run(database, document, filter_name, *args, **kwargs):
str(person.get_primary_name().get_type()))
matches += 1
elif (filter_name == 'all families'):
familyList = database.get_family_handles()
familyList = database.iter_family_handles()
stab.columns(_("Family"))
for family_handle in familyList:
family = database.get_family_from_handle(family_handle)

View File

@ -178,7 +178,7 @@ class MarkerReport(Report):
self.doc.end_table()
def write_families(self):
flist = self.database.get_family_handles()
flist = self.database.iter_family_handles()
FilterClass = GenericFilterFactory('Family')
filter = FilterClass()
filter.add_rule(Rules.Family.HasMarkerOf([self.marker]))

View File

@ -189,9 +189,9 @@ class SummaryReport(Report):
self.doc.write_text(_("Family Information"))
self.doc.end_paragraph()
family_list = self.__db.get_family_handles()
family_list = self.__db.iter_family_handles()
self.doc.start_paragraph("SR-Normal")
self.doc.write_text(_("Number of families: %d") % len(family_list))
self.doc.write_text(_("Number of families: %d") % self.__db.get_number_of_families())
self.doc.end_paragraph()
def summarize_media(self):

View File

@ -95,7 +95,7 @@ class EventNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
self.change = True
counter += 1
for handle in self.db.get_family_handles():
for handle in self.db.iter_family_handles():
family = self.db.get_family_from_handle(handle)
for event_ref in family.get_event_ref_list():
if event_ref.get_role() == gen.lib.EventRoleType.FAMILY:

View File

@ -357,7 +357,7 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback):
self.update()
# Family-based rules
for family_handle in self.db.get_family_handles():
for family_handle in self.db.iter_family_handles():
family = find_family(self.db,family_handle)
rule_list = [