Fix bugs in some modules caused by using enumerate instead of conventional for-loop syntax
svn: r12795
This commit is contained in:
parent
b75f97ef01
commit
302a4358fd
@ -62,9 +62,11 @@ class GivenNameCloudGramplet(Gramplet):
|
||||
givensubnames = {}
|
||||
representative_handle = {}
|
||||
|
||||
for cnt, person_handle in enumerate(people):
|
||||
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_first_name().strip() for name in allnames])
|
||||
for givenname in allnames:
|
||||
@ -76,13 +78,14 @@ class GivenNameCloudGramplet(Gramplet):
|
||||
|
||||
total_people = cnt
|
||||
givensubname_sort = []
|
||||
total = 0
|
||||
|
||||
for cnt, givensubname in enumerate(givensubnames):
|
||||
|
||||
total = cnt = 0
|
||||
for givensubname in givensubnames:
|
||||
givensubname_sort.append( (givensubnames[givensubname], givensubname) )
|
||||
total += givensubnames[givensubname]
|
||||
if not cnt % _YIELD_INTERVAL:
|
||||
yield True
|
||||
cnt += 1
|
||||
|
||||
total_givensubnames = cnt
|
||||
givensubname_sort.sort(reverse=True)
|
||||
@ -114,7 +117,8 @@ class GivenNameCloudGramplet(Gramplet):
|
||||
# Ok, now we can show those counts > include_greater_than:
|
||||
|
||||
self.set_text("")
|
||||
for showing, (count, givensubname) in enumerate(cloud_names): # givensubname_sort:
|
||||
showing = 0
|
||||
for (count, givensubname) in cloud_names: # givensubname_sort:
|
||||
if count > include_greater_than:
|
||||
if len(givensubname) == 0:
|
||||
text = Config.get(Config.NO_SURNAME_TEXT)
|
||||
@ -127,6 +131,7 @@ class GivenNameCloudGramplet(Gramplet):
|
||||
(float(count)/total_people) * 100,
|
||||
count))
|
||||
self.append_text(" ")
|
||||
showing += 1
|
||||
|
||||
self.append_text(("\n\n" + _("Total unique given names") + ": %d\n") %
|
||||
total_givensubnames)
|
||||
|
@ -81,7 +81,9 @@ class SurnameCloudGramplet(Gramplet):
|
||||
people = self.dbstate.db.iter_person_handles()
|
||||
surnames = {}
|
||||
representative_handle = {}
|
||||
for cnt, person_handle in enumerate(people):
|
||||
|
||||
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()
|
||||
@ -91,21 +93,23 @@ class SurnameCloudGramplet(Gramplet):
|
||||
representative_handle[surname] = person_handle
|
||||
if not cnt % _YIELD_INTERVAL:
|
||||
yield True
|
||||
cnt += 1
|
||||
|
||||
total_people = cnt
|
||||
surname_sort = []
|
||||
total = 0
|
||||
for cnt, surname in enumerate(surnames):
|
||||
total = cnt = 0
|
||||
for surname in surnames:
|
||||
surname_sort.append( (surnames[surname], surname) )
|
||||
total += surnames[surname]
|
||||
if not cnt % _YIELD_INTERVAL:
|
||||
yield True
|
||||
cnt += 1
|
||||
|
||||
total_surnames = cnt
|
||||
surname_sort.sort(reverse=True)
|
||||
cloud_names = []
|
||||
cloud_values = []
|
||||
for cnt, (count, surname) in enumerate(surname_sort):
|
||||
for (count, surname) in surname_sort:
|
||||
cloud_names.append( (count, surname) )
|
||||
cloud_values.append( count )
|
||||
|
||||
|
@ -66,9 +66,11 @@ class TopSurnamesGramplet(Gramplet):
|
||||
surnames = {}
|
||||
representative_handle = {}
|
||||
|
||||
for cnt, person_handle in enumerate(people):
|
||||
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:
|
||||
|
@ -117,10 +117,12 @@ def run(database, document, person):
|
||||
people = filter.apply(database,
|
||||
database.iter_person_handles())
|
||||
|
||||
for matches, person_handle in enumerate(people):
|
||||
matches = 0
|
||||
for person_handle in people:
|
||||
person = database.get_person_from_handle(person_handle)
|
||||
stab.row(person, sdb.birth_date_obj(person),
|
||||
str(person.get_primary_name().get_type()))
|
||||
matches += 1
|
||||
|
||||
sdoc.paragraph(ngettext("There is %d person with a matching name, or alternate name.\n"
|
||||
,
|
||||
@ -155,10 +157,13 @@ def run_given(database, document, person):
|
||||
filter.add_rule(rule)
|
||||
people = filter.apply(database,
|
||||
database.iter_person_handles())
|
||||
for matches, person_handle in enumerate(people):
|
||||
|
||||
matches = 0
|
||||
for person_handle in people:
|
||||
person = database.get_person_from_handle(person_handle)
|
||||
stab.row(person, sdb.birth_date_obj(person),
|
||||
str(person.get_primary_name().get_type()))
|
||||
matches += 1
|
||||
|
||||
sdoc.paragraph(ngettext("There is %d person with a matching name, or alternate name.\n"
|
||||
,
|
||||
|
@ -100,7 +100,8 @@ class SummaryReport(Report):
|
||||
self.doc.end_paragraph()
|
||||
|
||||
person_list = self.__db.iter_person_handles()
|
||||
for num_people, person_handle in enumerate(person_list):
|
||||
num_people = 0
|
||||
for person_handle in person_list:
|
||||
person = self.__db.get_person_from_handle(person_handle)
|
||||
if not person:
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user