1. Implement iter_<object> methods in proxybase.
2. Change include_object to include_media_object to avoid confusion 3. Make _validated_id_prefix method in read.py a staticmethod 4. Use new iter_<objects> methods in Records.py, StatsgGramplet.py, GivenNameGramplet.py, ExtractCity.py and _IsSiblingOfFilterMatch.py as examples svn: r13151
This commit is contained in:
@@ -196,8 +196,8 @@ def _find_records(db, filter, callname):
|
||||
family_shortest = []
|
||||
family_longest = []
|
||||
|
||||
for family_handle in db.iter_family_handles():
|
||||
family = db.get_family_from_handle(family_handle)
|
||||
for family in db.iter_families():
|
||||
#family = db.get_family_from_handle(family_handle)
|
||||
|
||||
father_handle = family.get_father_handle()
|
||||
if not father_handle:
|
||||
@@ -220,7 +220,7 @@ def _find_records(db, filter, callname):
|
||||
|
||||
_record(None, family_mostchildren,
|
||||
len(family.get_child_ref_list()),
|
||||
name, 'Family', family_handle)
|
||||
name, 'Family', family.handle)
|
||||
|
||||
marriage_date = None
|
||||
divorce_date = None
|
||||
@@ -243,7 +243,7 @@ def _find_records(db, filter, callname):
|
||||
if probably_alive(father, db) and probably_alive(mother, db):
|
||||
_record(family_youngestmarried, family_oldestmarried,
|
||||
today_date - marriage_date,
|
||||
name, 'Family', family_handle)
|
||||
name, 'Family', family.handle)
|
||||
elif (_good_date(divorce_date) or
|
||||
_good_date(father_death_date) or
|
||||
_good_date(mother_death_date)):
|
||||
@@ -262,7 +262,7 @@ def _find_records(db, filter, callname):
|
||||
duration = end - marriage_date
|
||||
|
||||
_record(family_shortest, family_longest,
|
||||
duration, name, 'Family', family_handle)
|
||||
duration, name, 'Family', family.handle)
|
||||
|
||||
return [(text, varname, locals()[varname]) for (text, varname, default) in RECORDS]
|
||||
|
||||
|
||||
@@ -58,21 +58,18 @@ class GivenNameCloudGramplet(Gramplet):
|
||||
def main(self):
|
||||
self.set_text(_("Processing...") + "\n")
|
||||
yield True
|
||||
people = self.dbstate.db.iter_person_handles()
|
||||
givensubnames = {}
|
||||
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_first_name().strip() for name in allnames])
|
||||
for givenname in allnames:
|
||||
for givensubname in givenname.split():
|
||||
givensubnames[givensubname] = givensubnames.get(givensubname, 0) + 1
|
||||
representative_handle[givensubname] = person_handle
|
||||
cnt = 0
|
||||
for person in self.dbstate.db.iter_people():
|
||||
allnames = [person.get_primary_name()] + person.get_alternate_names()
|
||||
allnames = set(name.get_first_name().strip() for name in allnames)
|
||||
for givenname in allnames:
|
||||
for givensubname in givenname.split():
|
||||
givensubnames[givensubname] = givensubnames.get(givensubname, 0) + 1
|
||||
representative_handle[givensubname] = person.handle
|
||||
cnt += 1
|
||||
if not cnt % _YIELD_INTERVAL:
|
||||
yield True
|
||||
|
||||
@@ -83,22 +80,21 @@ class GivenNameCloudGramplet(Gramplet):
|
||||
for givensubname in givensubnames:
|
||||
givensubname_sort.append( (givensubnames[givensubname], givensubname) )
|
||||
total += givensubnames[givensubname]
|
||||
cnt += 1
|
||||
if not cnt % _YIELD_INTERVAL:
|
||||
yield True
|
||||
cnt += 1
|
||||
|
||||
total_givensubnames = cnt
|
||||
givensubname_sort.sort(reverse=True)
|
||||
cloud_names = []
|
||||
cloud_values = []
|
||||
|
||||
for cnt, (count, givensubname) in enumerate(givensubname_sort):
|
||||
for count, givensubname in givensubname_sort:
|
||||
cloud_names.append( (count, givensubname) )
|
||||
cloud_values.append( count )
|
||||
|
||||
cloud_names.sort(key=lambda k: k[1])
|
||||
counts = list(set(cloud_values))
|
||||
counts.sort(reverse=True)
|
||||
counts = sorted(set(cloud_values), reverse=True)
|
||||
line = 0
|
||||
### All done!
|
||||
# Now, find out how many we can display without going over top_size:
|
||||
|
||||
@@ -66,8 +66,7 @@ class StatsGramplet(Gramplet):
|
||||
def main(self):
|
||||
self.set_text(_("Processing..."))
|
||||
database = self.dbstate.db
|
||||
personList = database.iter_person_handles()
|
||||
familyList = database.iter_family_handles()
|
||||
personList = database.iter_people()
|
||||
|
||||
with_photos = 0
|
||||
total_photos = 0
|
||||
@@ -90,38 +89,35 @@ class StatsGramplet(Gramplet):
|
||||
except:
|
||||
notfound.append(photo.get_path())
|
||||
|
||||
for cnt, person_handle in enumerate(personList):
|
||||
person = database.get_person_from_handle(person_handle)
|
||||
if not person:
|
||||
continue
|
||||
for cnt, person in enumerate(personList):
|
||||
length = len(person.get_media_list())
|
||||
if length > 0:
|
||||
with_photos = with_photos + 1
|
||||
total_photos = total_photos + length
|
||||
with_photos += 1
|
||||
total_photos += length
|
||||
|
||||
names = [person.get_primary_name()] + person.get_alternate_names()
|
||||
for name in names:
|
||||
if name.get_first_name() == "" or name.get_group_name() == "":
|
||||
incomp_names = incomp_names + 1
|
||||
incomp_names += 1
|
||||
if name.get_group_name() not in namelist:
|
||||
namelist.append(name.get_group_name())
|
||||
|
||||
if ((not person.get_main_parents_family_handle()) and
|
||||
(not len(person.get_family_handle_list()))):
|
||||
disconnected = disconnected + 1
|
||||
if (not person.get_main_parents_family_handle() and
|
||||
not len(person.get_family_handle_list())):
|
||||
disconnected += 1
|
||||
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref:
|
||||
birth = database.get_event_from_handle(birth_ref.ref)
|
||||
if not DateHandler.get_date(birth):
|
||||
missing_bday = missing_bday + 1
|
||||
missing_bday += 1
|
||||
else:
|
||||
missing_bday = missing_bday + 1
|
||||
missing_bday += 1
|
||||
|
||||
if person.get_gender() == gen.lib.Person.FEMALE:
|
||||
females = females + 1
|
||||
females += 1
|
||||
elif person.get_gender() == gen.lib.Person.MALE:
|
||||
males = males + 1
|
||||
males += 1
|
||||
else:
|
||||
unknowns += 1
|
||||
if not cnt % _YIELD_INTERVAL:
|
||||
|
||||
@@ -434,8 +434,7 @@ class ExtractCity(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
|
||||
self.name_list = []
|
||||
|
||||
for handle in db.iter_place_handles():
|
||||
place = db.get_place_from_handle(handle)
|
||||
for place in db.iter_places():
|
||||
descr = place.get_title()
|
||||
loc = place.get_main_location()
|
||||
self.progress.step()
|
||||
@@ -455,7 +454,7 @@ class ExtractCity(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
new_state = STATE_MAP.get(val.upper())
|
||||
if new_state:
|
||||
self.name_list.append(
|
||||
(handle, (city, new_state[0], postal,
|
||||
(place.handle, (city, new_state[0], postal,
|
||||
COUNTRY[new_state[1]])))
|
||||
continue
|
||||
|
||||
@@ -471,7 +470,7 @@ class ExtractCity(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
new_state = STATE_MAP.get(val.upper())
|
||||
if new_state:
|
||||
self.name_list.append(
|
||||
(handle, (city, new_state[0], postal,
|
||||
(place.handle, (city, new_state[0], postal,
|
||||
COUNTRY[new_state[1]])))
|
||||
continue
|
||||
match = CITY_STATE.match(descr.strip())
|
||||
@@ -490,7 +489,7 @@ class ExtractCity(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
new_state = STATE_MAP.get(val.upper())
|
||||
if new_state:
|
||||
self.name_list.append(
|
||||
(handle, (city, new_state[0], postal,
|
||||
(place.handle, (city, new_state[0], postal,
|
||||
COUNTRY[new_state[1]])))
|
||||
continue
|
||||
|
||||
@@ -498,7 +497,7 @@ class ExtractCity(Tool.BatchTool, ManagedWindow.ManagedWindow):
|
||||
new_state = STATE_MAP.get(val)
|
||||
if new_state:
|
||||
self.name_list.append(
|
||||
(handle, (None, new_state[0], None,
|
||||
(place.handle, (None, new_state[0], None,
|
||||
COUNTRY[new_state[1]])))
|
||||
self.progress.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user