Implement iter_people_handles methods and begin to use them

svn: r12760
This commit is contained in:
Gerald Britton 2009-07-03 20:23:41 +00:00
parent 40d0605a63
commit f7454de7fd
44 changed files with 217 additions and 160 deletions

View File

@ -111,7 +111,7 @@ class LastNameDialog(ManagedWindow.ManagedWindow):
progress = ProgressMeter(_('Finding Surnames')) progress = ProgressMeter(_('Finding Surnames'))
progress.set_pass(_('Finding surnames'), progress.set_pass(_('Finding surnames'),
database.get_number_of_people()) database.get_number_of_people())
for person_handle in database.get_person_handles(False): for person_handle in database.iter_person_handles():
progress.step() progress.step()
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
key = person.get_primary_name().get_surname() key = person.get_primary_name().get_surname()

View File

@ -608,6 +608,13 @@ class DbBase(object):
""" """
raise NotImplementedError raise NotImplementedError
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
"""
raise NotImplementedError
def get_place_handles(self, sort_handles=True): def get_place_handles(self, sort_handles=True):
""" """
Return a list of database handles, one handle for each Place in Return a list of database handles, one handle for each Place in
@ -1267,7 +1274,7 @@ class DbBase(object):
Note that this is a generator function, it returns a iterator for Note that this is a generator function, it returns a iterator for
use in loops. If you want a list of the results use: use in loops. If you want a list of the results use:
> result_list = [i for i in find_backlink_handles(handle)] > result_list = list(find_backlink_handles(handle))
""" """
raise NotImplementedError raise NotImplementedError

View File

@ -281,6 +281,14 @@ class FilterProxyDb(ProxyDbBase):
# FIXME: plist is not a sorted list of handles # FIXME: plist is not a sorted list of handles
return list(self.plist) return list(self.plist)
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
"""
# FIXME: plist is not a sorted list of handles
return (h for h in self.plist)
def get_place_handles(self, sort_handles=True): def get_place_handles(self, sort_handles=True):
""" """
Return a list of database handles, one handle for each Place in Return a list of database handles, one handle for each Place in
@ -420,7 +428,7 @@ class FilterProxyDb(ProxyDbBase):
Note that this is a generator function, it returns a iterator for Note that this is a generator function, it returns a iterator for
use in loops. If you want a list of the results use: use in loops. If you want a list of the results use:
> result_list = [i for i in find_backlink_handles(handle)] > result_list = list(find_backlink_handles(handle))
""" """
#FIXME: add a filter for returned handles (see private.py as an example) #FIXME: add a filter for returned handles (see private.py as an example)
return self.db.find_backlink_handles(handle, include_classes) return self.db.find_backlink_handles(handle, include_classes)

View File

@ -227,6 +227,19 @@ class LivingProxyDb(ProxyDbBase):
handles = self.db.get_person_handles(sort_handles) handles = self.db.get_person_handles(sort_handles)
return handles return handles
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
"""
if self.mode == self.MODE_EXCLUDE_ALL:
for handle in self.db.iter_person_handles():
person = self.db.get_person_from_handle(handle)
if not self.__is_living(person):
yield handle
else:
handles = self.db.iter_person_handles()
def get_place_handles(self, sort_handles=True): def get_place_handles(self, sort_handles=True):
""" """
Return a list of database handles, one handle for each Place in Return a list of database handles, one handle for each Place in
@ -364,7 +377,7 @@ class LivingProxyDb(ProxyDbBase):
Note that this is a generator function, it returns a iterator for Note that this is a generator function, it returns a iterator for
use in loops. If you want a list of the results use: use in loops. If you want a list of the results use:
> result_list = [i for i in find_backlink_handles(handle)] > result_list = list(find_backlink_handles(handle))
""" """
handle_itr = self.db.find_backlink_handles(handle, include_classes) handle_itr = self.db.find_backlink_handles(handle, include_classes)
for (class_name, handle) in handle_itr: for (class_name, handle) in handle_itr:

View File

@ -218,6 +218,16 @@ class PrivateProxyDb(ProxyDbBase):
handles.append(handle) handles.append(handle)
return handles return handles
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
"""
for handle in self.db.iter_person_handles():
person = self.db.get_person_from_handle(handle)
if not person.get_privacy():
yield handle
def get_place_handles(self, sort_handles=True): def get_place_handles(self, sort_handles=True):
""" """
Return a list of database handles, one handle for each Place in Return a list of database handles, one handle for each Place in

View File

@ -445,7 +445,7 @@ class ProxyDbBase(DbBase):
Note that this is a generator function, it returns a iterator for Note that this is a generator function, it returns a iterator for
use in loops. If you want a list of the results use: use in loops. If you want a list of the results use:
> result_list = [i for i in find_backlink_handles(handle)] > result_list = list(find_backlink_handles(handle))
""" """
raise NotImplementedError raise NotImplementedError

View File

@ -172,6 +172,13 @@ class ReferencedProxyDb(ProxyDbBase):
""" """
return self.db.get_person_handles(sort_handles) return self.db.get_person_handles(sort_handles)
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
"""
return self.db.iter_person_handles()
def get_place_handles(self, sort_handles=True): def get_place_handles(self, sort_handles=True):
""" """
Return a list of database handles, one handle for each Place still Return a list of database handles, one handle for each Place still
@ -310,7 +317,7 @@ class ReferencedProxyDb(ProxyDbBase):
Note that this is a generator function, it returns a iterator for Note that this is a generator function, it returns a iterator for
use in loops. If you want a list of the results use: use in loops. If you want a list of the results use:
> result_list = [i for i in find_backlink_handles(handle)] > result_list = list(find_backlink_handles(handle))
""" """
handle_itr = self.db.find_backlink_handles(handle, include_classes) handle_itr = self.db.find_backlink_handles(handle, include_classes)
for (class_name, handle) in handle_itr: for (class_name, handle) in handle_itr:
@ -366,22 +373,17 @@ class ReferencedProxyDb(ProxyDbBase):
'handle_list': self.get_note_handles} 'handle_list': self.get_note_handles}
} }
has_unreferenced_handles = True
last_count = 0 last_count = 0
while has_unreferenced_handles: while True:
current_count = 0 current_count = 0
for object_type, object_dict in object_types.iteritems(): for object_type, object_dict in object_types.iteritems():
unref_list = object_dict['unref_list'] unref_list = object_dict['unref_list']
handle_list = object_dict['handle_list']() handle_list = object_dict['handle_list']()
for handle in handle_list: for handle in handle_list:
ref_handles = [i for i in \ if not any(self.find_backlink_handles(handle)):
self.find_backlink_handles(handle)]
if len(ref_handles) == 0:
unref_list.append(handle) unref_list.append(handle)
current_count += len(unref_list) current_count += len(unref_list)
if current_count == last_count: if current_count == last_count:
has_unreferenced_handles = False break
else: last_count = current_count
last_count = current_count

View File

@ -100,7 +100,7 @@ def _find_records(db, filter, callname):
person_oldestfather = [] person_oldestfather = []
person_oldestmother = [] person_oldestmother = []
person_handle_list = db.get_person_handles(sort_handles=False) person_handle_list = db.iter_person_handles()
if filter: if filter:
person_handle_list = filter.apply(db, person_handle_list) person_handle_list = filter.apply(db, person_handle_list)

View File

@ -245,8 +245,8 @@ class Calendar(Report):
This method runs through the data, and collects the relevant dates This method runs through the data, and collects the relevant dates
and text. and text.
""" """
people = self.database.get_person_handles(sort_handles=False) people = self.database.iter_person_handles()
self.progress.set_pass(_('Applying Filter...'), len(people)) self.progress.set_pass(_('Applying Filter...'), self.database.get_number_of_people())
people = self.filter.apply(self.database, people, self.progress) people = self.filter.apply(self.database, people, self.progress)
pmgr = PluginManager.get_instance() pmgr = PluginManager.get_instance()
rel_calc = pmgr.get_relationship_calculator() rel_calc = pmgr.get_relationship_calculator()

View File

@ -417,7 +417,7 @@ class Extract(object):
data.append((ext[name][1], {}, ext[name][2], ext[name][3])) data.append((ext[name][1], {}, ext[name][2], ext[name][3]))
# go through the people and collect data # go through the people and collect data
for person_handle in filter_func.apply(db, db.get_person_handles(sort_handles=False)): for person_handle in filter_func.apply(db, db.iter_person_handles()):
person = db.get_person_from_handle(person_handle) person = db.get_person_from_handle(person_handle)
# check whether person has suitable gender # check whether person has suitable gender

View File

@ -239,7 +239,7 @@ class TimeLine(Report):
high = -999999 high = -999999
self.plist = self.filter.apply(self.database, self.plist = self.filter.apply(self.database,
self.database.get_person_handles(sort_handles=False)) self.database.iter_person_handles())
for p_id in self.plist: for p_id in self.plist:
p = self.database.get_person_from_handle(p_id) p = self.database.get_person_from_handle(p_id)
@ -280,7 +280,7 @@ class TimeLine(Report):
def name_size(self): def name_size(self):
self.plist = self.filter.apply(self.database, self.plist = self.filter.apply(self.database,
self.database.get_person_handles(sort_handles=False)) self.database.iter_person_handles())
style_sheet = self.doc.get_style_sheet() style_sheet = self.doc.get_style_sheet()
gstyle = style_sheet.get_draw_style('TLG-text') gstyle = style_sheet.get_draw_style('TLG-text')

View File

@ -185,7 +185,7 @@ class PackageWriter(object):
p.set_media_list(nl) p.set_media_list(nl)
self.db.commit_family(p, None) self.db.commit_family(p, None)
for key in self.db.get_person_handles(sort_handles=False): for key in self.db.iter_person_handles():
p = self.db.get_person_from_handle(key) p = self.db.get_person_from_handle(key)
nl = p.get_media_list() nl = p.get_media_list()
for o in nl: for o in nl:

View File

@ -254,7 +254,7 @@ class CSVWriter(object):
if not option_box.cfilter.is_empty(): if not option_box.cfilter.is_empty():
self.db = gen.proxy.FilterProxyDb(self.db, option_box.cfilter) self.db = gen.proxy.FilterProxyDb(self.db, option_box.cfilter)
for p in self.db.get_person_handles(sort_handles=False): for p in self.db.iter_person_handles():
self.plist[p] = 1 self.plist[p] = 1
# get the families for which these people are spouses: # get the families for which these people are spouses:
self.flist = {} self.flist = {}

View File

@ -144,14 +144,15 @@ class FtreeWriter(object):
self.restrict = self.option_box.restrict self.restrict = self.option_box.restrict
if self.option_box.cfilter is None: if self.option_box.cfilter is None:
for p in self.db.get_person_handles(sort_handles=False): self.plist.update((p,1)
self.plist[p] = 1 for p in self.db.iter_person_handles())
else: else:
try: try:
for p in self.option_box.cfilter.apply( self.plist.update((p,1)
self.db, self.db.get_person_handles(sort_handles=False) for p in self.option_box.cfilter.apply(
): self.db, self.db.iter_person_handles()))
self.plist[p] = 1
except Errors.FilterError, msg: except Errors.FilterError, msg:
(m1, m2) = msg.messages() (m1, m2) = msg.messages()
ErrorDialog(m1, m2) ErrorDialog(m1, m2)
@ -169,8 +170,8 @@ class FtreeWriter(object):
def cl_setup(self): def cl_setup(self):
self.restrict = True self.restrict = True
for p in self.db.get_person_handles(sort_handles=False): self.plist.update((p,1)
self.plist[p] = 1 for p in self.db.iter_person_handles())
def export_data(self): def export_data(self):
name_map = {} name_map = {}

View File

@ -413,7 +413,6 @@ class GedcomWriter(BasicUtils.UpdateCallback):
self.dirname = os.path.dirname (filename) self.dirname = os.path.dirname (filename)
self.gedcom_file = open(filename, "w") self.gedcom_file = open(filename, "w")
self.__header(filename) self.__header(filename)
self.__submitter() self.__submitter()
self.__individuals() self.__individuals()
@ -574,8 +573,8 @@ class GedcomWriter(BasicUtils.UpdateCallback):
self.reset(_("Writing individuals")) self.reset(_("Writing individuals"))
self.progress_cnt += 1 self.progress_cnt += 1
self.update(self.progress_cnt) self.update(self.progress_cnt)
phandles = self.dbase.get_person_handles() phandles = self.dbase.iter_person_handles()
sorted_list = [] sorted_list = []
for handle in phandles: for handle in phandles:
person = self.dbase.get_person_from_handle(handle) person = self.dbase.get_person_from_handle(handle)

View File

@ -174,7 +174,7 @@ class GeneWebWriter(object):
if not option_box.cfilter.is_empty(): if not option_box.cfilter.is_empty():
self.db = gen.proxy.FilterProxyDb(self.db, option_box.cfilter) self.db = gen.proxy.FilterProxyDb(self.db, option_box.cfilter)
for p in self.db.get_person_handles(sort_handles=False): for p in self.db.iter_person_handles():
self.plist[p] = 1 self.plist[p] = 1
self.flist = {} self.flist = {}

View File

@ -122,7 +122,7 @@ class PackageWriter(object):
nl.remove(o) nl.remove(o)
p.set_media_list(nl) p.set_media_list(nl)
self.db.commit_family(p,None) self.db.commit_family(p,None)
for key in self.db.get_person_handles(sort_handles=False): for key in self.db.iter_person_handles():
p = self.db.get_person_from_handle(key) p = self.db.get_person_from_handle(key)
nl = p.get_media_list() nl = p.get_media_list()
for o in nl: for o in nl:

View File

@ -145,12 +145,12 @@ class CalendarWriter(object):
self.option_box.parse_options() self.option_box.parse_options()
if self.option_box.cfilter is None: if self.option_box.cfilter is None:
for p in self.db.get_person_handles(sort_handles=False): for p in self.db.iter_person_handles():
self.plist[p] = 1 self.plist[p] = 1
else: else:
try: try:
for p in self.option_box.cfilter.apply(self.db, for p in self.option_box.cfilter.apply(self.db,
self.db.get_person_handles(sort_handles=False)): self.db.iter_person_handles()):
self.plist[p] = 1 self.plist[p] = 1
except Errors.FilterError, msg: except Errors.FilterError, msg:
(m1, m2) = msg.messages() (m1, m2) = msg.messages()
@ -174,7 +174,7 @@ class CalendarWriter(object):
self.oldval = newval self.oldval = newval
def cl_setup(self): def cl_setup(self):
for p in self.db.get_person_handles(sort_handles=False): for p in self.db.iter_person_handles():
self.plist[p] = 1 self.plist[p] = 1
self.flist = {} self.flist = {}

View File

@ -136,12 +136,12 @@ class CardWriter(object):
self.option_box.parse_options() self.option_box.parse_options()
if self.option_box.cfilter is None: if self.option_box.cfilter is None:
for p in self.db.get_person_handles(sort_handles=False): for p in self.db.iter_person_handles():
self.plist[p] = 1 self.plist[p] = 1
else: else:
try: try:
for p in self.option_box.cfilter.apply(self.db, for p in self.option_box.cfilter.apply(self.db,
self.db.get_person_handles(sort_handles=False)): self.db.iter_person_handles()):
self.plist[p] = 1 self.plist[p] = 1
except Errors.FilterError, msg: except Errors.FilterError, msg:
(m1, m2) = msg.messages() (m1, m2) = msg.messages()
@ -159,7 +159,7 @@ class CardWriter(object):
self.oldval = newval self.oldval = newval
def cl_setup(self): def cl_setup(self):
for p in self.db.get_person_handles(sort_handles=False): for p in self.db.iter_person_handles():
self.plist[p] = 1 self.plist[p] = 1
def writeln(self, text): def writeln(self, text):

View File

@ -83,7 +83,7 @@ class AgeStatsGramplet(Gramplet):
mother_handles = [[] for age in range(self.max_mother_diff)] mother_handles = [[] for age in range(self.max_mother_diff)]
father_handles = [[] for age in range(self.max_father_diff)] father_handles = [[] for age in range(self.max_father_diff)]
text = "" text = ""
handles = self.dbstate.db.get_person_handles(sort_handles=False) handles = self.dbstate.db.iter_person_handles()
for h in handles: for h in handles:
yield True yield True
p = self.dbstate.db.get_person_from_handle(h) p = self.dbstate.db.get_person_from_handle(h)
@ -203,7 +203,7 @@ class AgeStatsGramplet(Gramplet):
print "compute_stats", hash print "compute_stats", hash
hashkeys = sorted(hash) hashkeys = sorted(hash)
count = sum(hash.itervalues()) count = sum(hash.itervalues())
sumval = sum([k * hash[k] for k in hash]) sumval = sum(k * hash[k] for k in hash)
minval = min(hashkeys) minval = min(hashkeys)
maxval = max(hashkeys) maxval = max(hashkeys)
median = 0 median = 0

View File

@ -25,6 +25,8 @@ from gettext import gettext as _
from DataViews import Gramplet, register from DataViews import Gramplet, register
import Config import Config
_YIELD_INTERVAL = 350
def make_tag_size(n, counts, mins=8, maxs=20): def make_tag_size(n, counts, mins=8, maxs=20):
# return font sizes mins to maxs # return font sizes mins to maxs
diff = maxs - mins diff = maxs - mins
@ -56,11 +58,11 @@ class GivenNameCloudGramplet(Gramplet):
def main(self): def main(self):
self.set_text(_("Processing...") + "\n") self.set_text(_("Processing...") + "\n")
yield True yield True
people = self.dbstate.db.get_person_handles(sort_handles=False) people = self.dbstate.db.iter_person_handles()
givensubnames = {} givensubnames = {}
representative_handle = {} representative_handle = {}
cnt = 0
for person_handle in people: for cnt, person_handle in enumerate(people):
person = self.dbstate.db.get_person_from_handle(person_handle) person = self.dbstate.db.get_person_from_handle(person_handle)
if person: if person:
allnames = [person.get_primary_name()] + person.get_alternate_names() allnames = [person.get_primary_name()] + person.get_alternate_names()
@ -69,32 +71,31 @@ class GivenNameCloudGramplet(Gramplet):
for givensubname in givenname.split(): for givensubname in givenname.split():
givensubnames[givensubname] = givensubnames.get(givensubname, 0) + 1 givensubnames[givensubname] = givensubnames.get(givensubname, 0) + 1
representative_handle[givensubname] = person_handle representative_handle[givensubname] = person_handle
if cnt % 350 == 0: if not cnt % _YIELD_INTERVAL:
yield True yield True
cnt += 1
total_people = cnt total_people = cnt
givensubname_sort = [] givensubname_sort = []
total = 0 total = 0
cnt = 0
for givensubname in givensubnames: for cnt, givensubname in enumerate(givensubnames):
givensubname_sort.append( (givensubnames[givensubname], givensubname) ) givensubname_sort.append( (givensubnames[givensubname], givensubname) )
total += givensubnames[givensubname] total += givensubnames[givensubname]
if cnt % 100 == 0: if not cnt % _YIELD_INTERVAL:
yield True yield True
cnt += 1
total_givensubnames = cnt total_givensubnames = cnt
givensubname_sort.sort(lambda a,b: -cmp(a,b)) givensubname_sort.sort(reverse=True)
cloud_names = [] cloud_names = []
cloud_values = [] cloud_values = []
cnt = 0
for (count, givensubname) in givensubname_sort: for cnt, (count, givensubname) in enumerate(givensubname_sort):
cloud_names.append( (count, givensubname) ) cloud_names.append( (count, givensubname) )
cloud_values.append( count ) cloud_values.append( count )
cnt += 1
cloud_names.sort(lambda a,b: cmp(a[1], b[1])) cloud_names.sort(key=lambda k: k[1])
counts = list(set(cloud_values)) counts = list(set(cloud_values))
counts.sort() counts.sort(reverse=True)
counts.reverse()
line = 0 line = 0
### All done! ### All done!
# Now, find out how many we can display without going over top_size: # Now, find out how many we can display without going over top_size:
@ -111,9 +112,9 @@ class GivenNameCloudGramplet(Gramplet):
include_greater_than = s include_greater_than = s
break break
# Ok, now we can show those counts > include_greater_than: # Ok, now we can show those counts > include_greater_than:
showing = 0
self.set_text("") self.set_text("")
for (count, givensubname) in cloud_names: # givensubname_sort: for showing, (count, givensubname) in enumerate(cloud_names): # givensubname_sort:
if count > include_greater_than: if count > include_greater_than:
if len(givensubname) == 0: if len(givensubname) == 0:
text = Config.get(Config.NO_SURNAME_TEXT) text = Config.get(Config.NO_SURNAME_TEXT)
@ -126,7 +127,7 @@ class GivenNameCloudGramplet(Gramplet):
(float(count)/total_people) * 100, (float(count)/total_people) * 100,
count)) count))
self.append_text(" ") self.append_text(" ")
showing += 1
self.append_text(("\n\n" + _("Total unique given names") + ": %d\n") % self.append_text(("\n\n" + _("Total unique given names") + ": %d\n") %
total_givensubnames) total_givensubnames)
self.append_text((_("Total given names showing") + ": %d\n") % showing) self.append_text((_("Total given names showing") + ": %d\n") % showing)

View File

@ -36,6 +36,14 @@ from Utils import media_path_full
import DateHandler import DateHandler
import gen import gen
#------------------------------------------------------------------------
#
# Constants
#
#------------------------------------------------------------------------
_YIELD_INTERVAL = 200
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Gramplet class # Gramplet class
@ -58,7 +66,7 @@ class StatsGramplet(Gramplet):
def main(self): def main(self):
self.set_text(_("Processing...")) self.set_text(_("Processing..."))
database = self.dbstate.db database = self.dbstate.db
personList = database.get_person_handles(sort_handles=False) personList = database.iter_person_handles()
familyList = database.get_family_handles() familyList = database.get_family_handles()
with_photos = 0 with_photos = 0
@ -73,7 +81,7 @@ class StatsGramplet(Gramplet):
namelist = [] namelist = []
notfound = [] notfound = []
pobjects = len(database.get_media_object_handles()) pobjects = database.get_number_of_media_objects()
for photo_id in database.get_media_object_handles(): for photo_id in database.get_media_object_handles():
photo = database.get_object_from_handle(photo_id) photo = database.get_object_from_handle(photo_id)
fullname = media_path_full(database, photo.get_path()) fullname = media_path_full(database, photo.get_path())
@ -82,8 +90,7 @@ class StatsGramplet(Gramplet):
except: except:
notfound.append(photo.get_path()) notfound.append(photo.get_path())
cnt = 0 for cnt, person_handle in enumerate(personList):
for person_handle in personList:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if not person: if not person:
continue continue
@ -92,16 +99,17 @@ class StatsGramplet(Gramplet):
with_photos = with_photos + 1 with_photos = with_photos + 1
total_photos = total_photos + length total_photos = total_photos + length
person = database.get_person_from_handle(person_handle)
names = [person.get_primary_name()] + person.get_alternate_names() names = [person.get_primary_name()] + person.get_alternate_names()
for name in names: for name in names:
if name.get_first_name() == "" or name.get_group_name() == "": if name.get_first_name() == "" or name.get_group_name() == "":
incomp_names = incomp_names + 1 incomp_names = incomp_names + 1
if name.get_group_name() not in namelist: if name.get_group_name() not in namelist:
namelist.append(name.get_group_name()) namelist.append(name.get_group_name())
if ((not person.get_main_parents_family_handle()) and if ((not person.get_main_parents_family_handle()) and
(not len(person.get_family_handle_list()))): (not len(person.get_family_handle_list()))):
disconnected = disconnected + 1 disconnected = disconnected + 1
birth_ref = person.get_birth_ref() birth_ref = person.get_birth_ref()
if birth_ref: if birth_ref:
birth = database.get_event_from_handle(birth_ref.ref) birth = database.get_event_from_handle(birth_ref.ref)
@ -109,22 +117,22 @@ class StatsGramplet(Gramplet):
missing_bday = missing_bday + 1 missing_bday = missing_bday + 1
else: else:
missing_bday = missing_bday + 1 missing_bday = missing_bday + 1
if person.get_gender() == gen.lib.Person.FEMALE: if person.get_gender() == gen.lib.Person.FEMALE:
females = females + 1 females = females + 1
elif person.get_gender() == gen.lib.Person.MALE: elif person.get_gender() == gen.lib.Person.MALE:
males = males + 1 males = males + 1
else: else:
unknowns += 1 unknowns += 1
if cnt % 200 == 0: if not cnt % _YIELD_INTERVAL:
yield True yield True
cnt += 1
self.clear_text() self.clear_text()
self.append_text(_("Individuals") + "\n") self.append_text(_("Individuals") + "\n")
self.append_text("----------------------------\n") self.append_text("----------------------------\n")
self.link(_("Number of individuals") + ":", self.link(_("Number of individuals") + ":",
'Filter', 'all people') 'Filter', 'all people')
self.append_text(" %s" % len(personList)) self.append_text(" %s" % database.get_number_of_people())
self.append_text("\n") self.append_text("\n")
self.link("%s:" % _("Males"), 'Filter', 'males') self.link("%s:" % _("Males"), 'Filter', 'males')
self.append_text(" %s" % males) self.append_text(" %s" % males)

View File

@ -27,6 +27,14 @@ from DataViews import register, Gramplet
from TransUtils import sgettext as _ from TransUtils import sgettext as _
import Config import Config
#------------------------------------------------------------------------
#
# Constants
#
#------------------------------------------------------------------------
_YIELD_INTERVAL = 350
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Local functions # Local functions
@ -70,11 +78,10 @@ class SurnameCloudGramplet(Gramplet):
def main(self): def main(self):
self.set_text(_("Processing...") + "\n") self.set_text(_("Processing...") + "\n")
yield True yield True
people = self.dbstate.db.get_person_handles(sort_handles=False) people = self.dbstate.db.iter_person_handles()
surnames = {} surnames = {}
representative_handle = {} representative_handle = {}
cnt = 0 for cnt, person_handle in enumerate(people):
for person_handle in people:
person = self.dbstate.db.get_person_from_handle(person_handle) person = self.dbstate.db.get_person_from_handle(person_handle)
if person: if person:
allnames = [person.get_primary_name()] + person.get_alternate_names() allnames = [person.get_primary_name()] + person.get_alternate_names()
@ -82,32 +89,29 @@ class SurnameCloudGramplet(Gramplet):
for surname in allnames: for surname in allnames:
surnames[surname] = surnames.get(surname, 0) + 1 surnames[surname] = surnames.get(surname, 0) + 1
representative_handle[surname] = person_handle representative_handle[surname] = person_handle
if cnt % 350 == 0: if not cnt % _YIELD_INTERVAL:
yield True yield True
cnt += 1
total_people = cnt total_people = cnt
surname_sort = [] surname_sort = []
total = 0 total = 0
cnt = 0 for cnt, surname in enumerate(surnames):
for surname in surnames:
surname_sort.append( (surnames[surname], surname) ) surname_sort.append( (surnames[surname], surname) )
total += surnames[surname] total += surnames[surname]
if cnt % 350 == 0: if not cnt % _YIELD_INTERVAL:
yield True yield True
cnt += 1
total_surnames = cnt total_surnames = cnt
surname_sort.sort(lambda a,b: -cmp(a,b)) surname_sort.sort(reverse=True)
cloud_names = [] cloud_names = []
cloud_values = [] cloud_values = []
cnt = 0 for cnt, (count, surname) in enumerate(surname_sort):
for (count, surname) in surname_sort:
cloud_names.append( (count, surname) ) cloud_names.append( (count, surname) )
cloud_values.append( count ) cloud_values.append( count )
cnt += 1
cloud_names.sort(lambda a,b: cmp(a[1], b[1])) cloud_names.sort(key=lambda k:k[1])
counts = list(set(cloud_values)) counts = list(set(cloud_values))
counts.sort() counts.sort(reverse=True)
counts.reverse()
line = 0 line = 0
### All done! ### All done!
# Now, find out how many we can display without going over top_size: # Now, find out how many we can display without going over top_size:

View File

@ -27,6 +27,14 @@ from DataViews import register, Gramplet
from TransUtils import sgettext as _ from TransUtils import sgettext as _
import Config import Config
#------------------------------------------------------------------------
#
# Constants
#
#------------------------------------------------------------------------
_YIELD_INTERVAL = 350
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Gramplet class # Gramplet class
@ -54,11 +62,11 @@ class TopSurnamesGramplet(Gramplet):
def main(self): def main(self):
self.set_text(_("Processing...") + "\n") self.set_text(_("Processing...") + "\n")
people = self.dbstate.db.get_person_handles(sort_handles=False) people = self.dbstate.db.iter_person_handles()
surnames = {} surnames = {}
representative_handle = {} representative_handle = {}
cnt = 0
for person_handle in people: for cnt, person_handle in enumerate(people):
person = self.dbstate.db.get_person_from_handle(person_handle) person = self.dbstate.db.get_person_from_handle(person_handle)
if person: if person:
allnames = [person.get_primary_name()] + person.get_alternate_names() allnames = [person.get_primary_name()] + person.get_alternate_names()
@ -66,32 +74,28 @@ class TopSurnamesGramplet(Gramplet):
for surname in allnames: for surname in allnames:
surnames[surname] = surnames.get(surname, 0) + 1 surnames[surname] = surnames.get(surname, 0) + 1
representative_handle[surname] = person_handle representative_handle[surname] = person_handle
if cnt % 350 == 0: if not cnt % _YIELD_INTERVAL:
yield True yield True
cnt += 1
total_people = cnt total_people = cnt
surname_sort = [] surname_sort = []
total = 0 total = 0
cnt = 0
for surname in surnames: for cnt, surname in enumerate(surnames):
surname_sort.append( (surnames[surname], surname) ) surname_sort.append( (surnames[surname], surname) )
total += surnames[surname] total += surnames[surname]
if cnt % 350 == 0: if not cnt % _YIELD_INTERVAL:
yield True yield True
cnt += 1
total_surnames = cnt total_surnames = cnt
surname_sort.sort(lambda a,b: -cmp(a,b)) surname_sort.sort(reverse=True)
line = 0 line = 0
### All done! ### All done!
self.set_text("") self.set_text("")
nosurname = Config.get(Config.NO_SURNAME_TEXT)
for (count, surname) in surname_sort: for (count, surname) in surname_sort:
if len(surname) == 0: text = "%s, " % (surname if surname else nosurname)
text = "%s, %d%% (%d)\n" % (Config.get(Config.NO_SURNAME_TEXT), text += "%d%% (%d)\n" % (int((float(count)/total) * 100), count)
int((float(count)/total) * 100),
count)
else:
text = "%s, %d%% (%d)\n" % (surname, int((float(count)/total) * 100),
count)
self.append_text(" %d. " % (line + 1)) self.append_text(" %d. " % (line + 1))
self.link(text, 'Surname', representative_handle[surname]) self.link(text, 'Surname', representative_handle[surname])
line += 1 line += 1

View File

@ -153,7 +153,7 @@ class RelGraphReport(Report):
def write_report(self): def write_report(self):
self.person_handles = self._filter.apply(self.database, self.person_handles = self._filter.apply(self.database,
self.database.get_person_handles(sort_handles=False)) self.database.iter_person_handles())
if len(self.person_handles) > 1: if len(self.person_handles) > 1:
self.add_persons_and_families() self.add_persons_and_families()
@ -164,9 +164,9 @@ class RelGraphReport(Report):
children" children"
person_dict = {} person_dict = {}
# Hash people in a dictionary for faster inclusion checking # Hash people in a dictionary for faster inclusion checking
for person_handle in self.person_handles: for person_handle in self.person_handles:
person_dict[person_handle] = 1 person_dict[person_handle] = 1
for person_handle in self.person_handles:
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
p_id = person.get_gramps_id() p_id = person.get_gramps_id()
for fam_handle in person.get_parent_family_handle_list(): for fam_handle in person.get_parent_family_handle_list():

View File

@ -34,7 +34,7 @@ def run(database, document, attribute, value=None):
sdoc.paragraph("") sdoc.paragraph("")
stab.columns(_("Person"), str(attribute)) stab.columns(_("Person"), str(attribute))
matches = 0 matches = 0
for person_handle in database.get_person_handles(sort_handles=False): for person_handle in database.iter_person_handles():
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
matched = False matched = False
for attr in person.attribute_list: for attr in person.attribute_list:

View File

@ -60,7 +60,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches = 0 matches = 0
if (filter_name == 'all people'): if (filter_name == 'all people'):
stab.columns(_("Person"), _("Birth Date"), _("Name type")) stab.columns(_("Person"), _("Birth Date"), _("Name type"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
stab.row(person, sdb.birth_date_obj(person), stab.row(person, sdb.birth_date_obj(person),
@ -68,7 +68,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches += 1 matches += 1
elif (filter_name == 'males'): elif (filter_name == 'males'):
stab.columns(_("Person"), _("Birth Date"), _("Name type")) stab.columns(_("Person"), _("Birth Date"), _("Name type"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if person.gender == Person.MALE: if person.gender == Person.MALE:
@ -77,7 +77,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches += 1 matches += 1
elif (filter_name == 'females'): elif (filter_name == 'females'):
stab.columns(_("Person"), _("Birth Date"), _("Name type")) stab.columns(_("Person"), _("Birth Date"), _("Name type"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if person.gender == Person.FEMALE: if person.gender == Person.FEMALE:
@ -86,7 +86,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches += 1 matches += 1
elif (filter_name == 'people with unknown gender'): elif (filter_name == 'people with unknown gender'):
stab.columns(_("Person"), _("Birth Date"), _("Name type")) stab.columns(_("Person"), _("Birth Date"), _("Name type"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if person.gender not in [Person.FEMALE, Person.MALE]: if person.gender not in [Person.FEMALE, Person.MALE]:
@ -95,7 +95,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches += 1 matches += 1
elif (filter_name == 'people with incomplete names'): elif (filter_name == 'people with incomplete names'):
stab.columns(_("Person"), _("Birth Date"), _("Name type")) stab.columns(_("Person"), _("Birth Date"), _("Name type"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
for name in [person.get_primary_name()] + person.get_alternate_names(): for name in [person.get_primary_name()] + person.get_alternate_names():
@ -105,7 +105,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches += 1 matches += 1
elif (filter_name == 'people with missing birth dates'): elif (filter_name == 'people with missing birth dates'):
stab.columns(_("Person"), _("Type")) stab.columns(_("Person"), _("Type"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if person: if person:
@ -120,7 +120,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches += 1 matches += 1
elif (filter_name == 'disconnected people'): elif (filter_name == 'disconnected people'):
stab.columns(_("Person"), _("Birth Date"), _("Name type")) stab.columns(_("Person"), _("Birth Date"), _("Name type"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if person: if person:
@ -139,7 +139,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches += 1 matches += 1
elif (filter_name == 'unique surnames'): elif (filter_name == 'unique surnames'):
namelist = {} namelist = {}
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if person: if person:
@ -158,7 +158,7 @@ def run(database, document, filter_name, *args, **kwargs):
name)) name))
elif (filter_name == 'people with media'): elif (filter_name == 'people with media'):
stab.columns(_("Person"), _("Media count")) stab.columns(_("Person"), _("Media count"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if not person: if not person:
@ -169,7 +169,7 @@ def run(database, document, filter_name, *args, **kwargs):
matches += 1 matches += 1
elif (filter_name == 'media references'): elif (filter_name == 'media references'):
stab.columns(_("Person"), _("Reference")) stab.columns(_("Person"), _("Reference"))
people = database.get_person_handles(sort_handles=False) people = database.iter_person_handles()
for person_handle in people: for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
if not person: if not person:

View File

@ -115,13 +115,13 @@ def run(database, document, person):
rule = IncompleteSurname([]) rule = IncompleteSurname([])
filter.add_rule(rule) filter.add_rule(rule)
people = filter.apply(database, people = filter.apply(database,
database.get_person_handles(sort_handles=False)) database.iter_person_handles())
matches = 0
for person_handle in people: for matches, person_handle in enumerate(people):
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
stab.row(person, sdb.birth_date_obj(person), stab.row(person, sdb.birth_date_obj(person),
str(person.get_primary_name().get_type())) str(person.get_primary_name().get_type()))
matches += 1
sdoc.paragraph(ngettext("There is %d person with a matching name, or alternate name.\n" sdoc.paragraph(ngettext("There is %d person with a matching name, or alternate name.\n"
, ,
"There are %d people with a matching name, or alternate name.\n" "There are %d people with a matching name, or alternate name.\n"
@ -154,13 +154,12 @@ def run_given(database, document, person):
rule = IncompleteGiven([]) rule = IncompleteGiven([])
filter.add_rule(rule) filter.add_rule(rule)
people = filter.apply(database, people = filter.apply(database,
database.get_person_handles(sort_handles=False)) database.iter_person_handles())
matches = 0 for matches, person_handle in enumerate(people):
for person_handle in people:
person = database.get_person_from_handle(person_handle) person = database.get_person_from_handle(person_handle)
stab.row(person, sdb.birth_date_obj(person), stab.row(person, sdb.birth_date_obj(person),
str(person.get_primary_name().get_type())) str(person.get_primary_name().get_type()))
matches += 1
sdoc.paragraph(ngettext("There is %d person with a matching name, or alternate name.\n" sdoc.paragraph(ngettext("There is %d person with a matching name, or alternate name.\n"
, ,
"There are %d people with a matching name, or alternate name.\n" "There are %d people with a matching name, or alternate name.\n"

View File

@ -193,8 +193,9 @@ class CalendarReport(Report):
This method runs through the data, and collects the relevant dates This method runs through the data, and collects the relevant dates
and text. and text.
""" """
people = self.database.get_person_handles(sort_handles=False) people = self.database.iter_person_handles()
self.progress.set_pass(_('Applying Filter...'), len(people)) self.progress.set_pass(_('Applying Filter...'),
self.database.get_number_of_people())
people = self.filter.apply(self.database, people, self.progress) people = self.filter.apply(self.database, people, self.progress)
pmgr = PluginManager.get_instance() pmgr = PluginManager.get_instance()
rel_calc = pmgr.get_relationship_calculator() rel_calc = pmgr.get_relationship_calculator()

View File

@ -379,18 +379,16 @@ class IndivCompleteReport(Report):
self.doc.end_cell() self.doc.end_cell()
def write_report(self): def write_report(self):
plist = self.database.get_person_handles(sort_handles=False) plist = self.database.iter_person_handles()
if self.filter: if self.filter:
ind_list = self.filter.apply(self.database,plist) ind_list = self.filter.apply(self.database,plist)
else: else:
ind_list = plist ind_list = plist
count = 0 for count, person_handle in enumerate(ind_list):
for person_handle in ind_list:
self.person = self.database.get_person_from_handle( self.person = self.database.get_person_from_handle(
person_handle) person_handle)
self.write_person(count) self.write_person(count)
count = count + 1
def write_person(self,count): def write_person(self,count):
if count != 0: if count != 0:

View File

@ -91,7 +91,7 @@ class MarkerReport(Report):
self.write_notes() self.write_notes()
def write_people(self): def write_people(self):
plist = self.database.get_person_handles(sort_handles=False) plist = self.database.iter_person_handles()
FilterClass = GenericFilterFactory('Person') FilterClass = GenericFilterFactory('Person')
filter = FilterClass() filter = FilterClass()
filter.add_rule(Rules.Person.HasMarkerOf([self.marker])) filter.add_rule(Rules.Person.HasMarkerOf([self.marker]))

View File

@ -99,11 +99,12 @@ class SummaryReport(Report):
self.doc.write_text(_("Individuals")) self.doc.write_text(_("Individuals"))
self.doc.end_paragraph() self.doc.end_paragraph()
person_list = self.__db.get_person_handles(sort_handles=False) person_list = self.__db.iter_person_handles()
for person_handle in person_list: for num_people, person_handle in enumerate(person_list):
person = self.__db.get_person_from_handle(person_handle) person = self.__db.get_person_from_handle(person_handle)
if not person: if not person:
continue continue
num_people += 1
# Count people with media. # Count people with media.
length = len(person.get_media_list()) length = len(person.get_media_list())
@ -142,7 +143,7 @@ class SummaryReport(Report):
namelist.append(name.get_surname()) namelist.append(name.get_surname())
self.doc.start_paragraph("SR-Normal") self.doc.start_paragraph("SR-Normal")
self.doc.write_text(_("Number of individuals: %d") % len(person_list)) self.doc.write_text(_("Number of individuals: %d") % num_people)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_paragraph("SR-Normal") self.doc.start_paragraph("SR-Normal")

View File

@ -160,7 +160,8 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
self.filter_option = self.options.menu.get_option_by_name('filter') self.filter_option = self.options.menu.get_option_by_name('filter')
self.filter = self.filter_option.get_filter() # the actual filter self.filter = self.filter_option.get_filter() # the actual filter
people = self.filter.apply(self.db, people = self.filter.apply(self.db,
self.db.get_person_handles(sort_handles=False)) self.db.iter_person_handles())
num_people = self.db.get_number_of_people()
source_text = self.options.handler.options_dict['source_text'] source_text = self.options.handler.options_dict['source_text']
add_birth = self.options.handler.options_dict['add_birth'] add_birth = self.options.handler.options_dict['add_birth']
add_death = self.options.handler.options_dict['add_death'] add_death = self.options.handler.options_dict['add_death']
@ -174,7 +175,7 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
if remove_old: if remove_old:
self.results_write(_("Replacing...\n")) self.results_write(_("Replacing...\n"))
self.progress.set_pass((_("Removing '%s'...") % source_text), self.progress.set_pass((_("Removing '%s'...") % source_text),
len(people)) num_people)
for person_handle in people: for person_handle in people:
self.progress.step() self.progress.step()
pupdate = 0 pupdate = 0
@ -216,7 +217,7 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
if add_birth or add_death: if add_birth or add_death:
self.results_write(_("Calculating...\n")) self.results_write(_("Calculating...\n"))
self.progress.set_pass(_('Calculating estimated dates...'), self.progress.set_pass(_('Calculating estimated dates...'),
len(people)) num_people)
source = self.get_or_create_source(source_text) source = self.get_or_create_source(source_text)
for person_handle in people: for person_handle in people:
self.progress.step() self.progress.step()

View File

@ -107,7 +107,7 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
s1 = 0 s1 = 0
if namesplitSP[0].lower() in prefix_list: if namesplitSP[0].lower() in prefix_list:
s1 = 1 s1 = 1
for x in range(len(namesplitSP)-s1): for x in xrange(len(namesplitSP)-s1):
# check if any subsurname is not cap # check if any subsurname is not cap
notcap = False notcap = False
if namesplitSP[s1+x] != namesplitSP[s1+x].capitalize(): if namesplitSP[s1+x] != namesplitSP[s1+x].capitalize():
@ -121,7 +121,7 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
# check if first string is in prefix_list, if so test for cap # check if first string is in prefix_list, if so test for cap
if namesplitSP[0].lower() in prefix_list: if namesplitSP[0].lower() in prefix_list:
namesplitHY[0] = namesplitHY[0].replace(namesplitSP[0],'').strip() namesplitHY[0] = namesplitHY[0].replace(namesplitSP[0],'').strip()
for x in range(len(namesplitHY)): for x in xrange(len(namesplitHY)):
# check if any subsurname is not cap # check if any subsurname is not cap
notcap = False notcap = False
if namesplitHY[x] != namesplitHY[x].capitalize(): if namesplitHY[x] != namesplitHY[x].capitalize():
@ -234,7 +234,7 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
for node in self.iter_list for node in self.iter_list
if self.model.get_value(node,0)] if self.model.get_value(node,0)]
for handle in self.db.get_person_handles(): for handle in self.db.iter_person_handles():
change = False change = False
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)
for name in [person.get_primary_name()] + person.get_alternate_names(): for name in [person.get_primary_name()] + person.get_alternate_names():

View File

@ -176,7 +176,7 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow):
progress_bar.set_pass(_('Selecting people'),1) progress_bar.set_pass(_('Selecting people'),1)
plist = cfilter.apply(self.db, plist = cfilter.apply(self.db,
self.db.get_person_handles(sort_handles=False)) self.db.iter_person_handles())
progress_bar.step() progress_bar.step()
progress_bar.close() progress_bar.close()

View File

@ -83,7 +83,7 @@ class EventNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
self.change = False self.change = False
counter = 0 counter = 0
for handle in self.db.get_person_handles(): for handle in self.db.iter_person_handles():
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)
for event_ref in person.get_event_ref_list(): for event_ref in person.get_event_ref_list():
if event_ref.get_role() == gen.lib.EventRoleType.PRIMARY: if event_ref.get_role() == gen.lib.EventRoleType.PRIMARY:

View File

@ -187,13 +187,12 @@ class Merge(Tool.Tool,ManagedWindow.ManagedWindow):
males = {} males = {}
females = {} females = {}
self.person_list = self.db.get_person_handles(sort_handles=False) length = self.db.get_number_of_people()
length = len(self.person_list)
self.progress.set_pass(_('Pass 1: Building preliminary lists'), self.progress.set_pass(_('Pass 1: Building preliminary lists'),
length) length)
for p1_id in self.person_list: for p1_id in self.db.iter_person_handles():
self.progress.step() self.progress.step()
p1 = self.db.get_person_from_handle(p1_id) p1 = self.db.get_person_from_handle(p1_id)
key = self.gen_key(p1.get_primary_name().get_surname()) key = self.gen_key(p1.get_primary_name().get_surname())
@ -211,7 +210,7 @@ class Merge(Tool.Tool,ManagedWindow.ManagedWindow):
self.progress.set_pass(_('Pass 2: Calculating potential matches'), self.progress.set_pass(_('Pass 2: Calculating potential matches'),
length) length)
for p1key in self.person_list: for p1key in self.db.iter_person_handles():
self.progress.step() self.progress.step()
p1 = self.db.get_person_from_handle(p1key) p1 = self.db.get_person_from_handle(p1key)
@ -221,9 +220,9 @@ class Merge(Tool.Tool,ManagedWindow.ManagedWindow):
else: else:
remaining = females[key] remaining = females[key]
index = 0 #index = 0
for p2key in remaining: for p2key in remaining:
index += 1 #index += 1
if p1key == p2key: if p1key == p2key:
continue continue
p2 = self.db.get_person_from_handle(p2key) p2 = self.db.get_person_from_handle(p2key)

View File

@ -333,7 +333,7 @@ class NotRelated(Tool.ActivePersonTool, ManagedWindow.ManagedWindow) :
self.numberOfUnrelatedPeople, self.numberOfPeopleInDatabase) self.numberOfUnrelatedPeople, self.numberOfPeopleInDatabase)
# loop through everyone in the database # loop through everyone in the database
for handle in self.db.get_person_handles(False): for handle in self.db.iter_person_handles():
self.progress.step() self.progress.step()

View File

@ -122,7 +122,7 @@ class PatchNames(Tool.BatchTool, ManagedWindow.ManagedWindow):
self.progress.set_pass(_('Analyzing names'), self.progress.set_pass(_('Analyzing names'),
self.db.get_number_of_people()) self.db.get_number_of_people())
for key in self.db.get_person_handles(sort_handles=False): for key in self.db.iter_person_handles():
person = self.db.get_person_from_handle(key) person = self.db.get_person_from_handle(key)
name = person.get_primary_name() name = person.get_primary_name()

View File

@ -110,9 +110,9 @@ class SortEvents(PluginWindows.ToolManagedWindowBatch):
Sort the personal events associated with the selected people. Sort the personal events associated with the selected people.
""" """
people_handles = self.filter.apply(self.db, people_handles = self.filter.apply(self.db,
self.db.get_person_handles(sort_handles=False)) self.db.iter_person_handles())
self.progress.set_pass(_("Sorting personal events..."), self.progress.set_pass(_("Sorting personal events..."),
len(people_handles)) self.db.get_number_of_people())
family_handles = [] family_handles = []
for handle in people_handles: for handle in people_handles:
person = self.db.get_person_from_handle(handle) person = self.db.get_person_from_handle(handle)

View File

@ -76,7 +76,7 @@ class SoundGen(Tool.Tool, ManagedWindow.ManagedWindow):
names = [] names = []
person = None person = None
for person_handle in self.db.get_person_handles(sort_handles=False): for person_handle in self.db.iter_person_handles():
person = self.db.get_person_from_handle(person_handle) person = self.db.get_person_from_handle(person_handle)
lastname = person.get_primary_name().get_surname() lastname = person.get_primary_name().get_surname()
if lastname not in names: if lastname not in names:

View File

@ -316,7 +316,7 @@ class Verify(Tool.Tool, ManagedWindow, UpdateCallback):
def run_tool(self,cli=False): def run_tool(self,cli=False):
person_handles = self.db.get_person_handles(sort_handles=False) person_handles = self.db.iter_person_handles()
for option, value in \ for option, value in \
self.options.handler.options_dict.iteritems(): self.options.handler.options_dict.iteritems():

View File

@ -1736,7 +1736,7 @@ class MediaPage(BasePage):
# TODO. Mixup url and path # TODO. Mixup url and path
# path = convert_disk_path_to_url(path) # path = convert_disk_path_to_url(path)
url = self.report.build_url_fname(path, None, self.up) url = self.report.build_url_fname(path, None, self.up)
hyper += Html('img', src=url, alt=html_escape(self.page_title) hyper += Html('img', src=url, alt=html_escape(self.page_title))
if target_exists: if target_exists:
mediadisplay += hyper mediadisplay += hyper
else: else:
@ -4186,8 +4186,9 @@ class NavWebReport(Report):
""" """
# gets the person list and applies the requested filter # gets the person list and applies the requested filter
ind_list = self.database.get_person_handles(sort_handles=False)
self.progress.set_pass(_('Applying Filter...'), len(ind_list)) ind_list = self.database.iter_person_handles()
self.progress.set_pass(_('Applying Filter...'), self.database.get_number_of_people())
ind_list = self.filter.apply(self.database, ind_list, self.progress) ind_list = self.filter.apply(self.database, ind_list, self.progress)
return ind_list return ind_list

View File

@ -1078,8 +1078,8 @@ class WebCalReport(Report):
This method runs through the data, and collects the relevant dates This method runs through the data, and collects the relevant dates
and text. and text.
""" """
people = self.database.get_person_handles(sort_handles=False) people = self.database.iter_person_handles()
self.progress.set_pass(_('Applying Filter...'), len(people)) self.progress.set_pass(_('Applying Filter...'), self.database.get_number_of_people())
people = self.filter.apply(self.database, people, self.progress) people = self.filter.apply(self.database, people, self.progress)
self.progress.set_pass(_("Reading database..."), len(people)) self.progress.set_pass(_("Reading database..."), len(people))