Exploit new iter_<objects> methods
svn: r13209
This commit is contained in:
parent
eb8ef2152b
commit
4b77831f0f
@ -1178,9 +1178,8 @@ class GeoView(HtmlView):
|
||||
latitude = ""
|
||||
longitude = ""
|
||||
self.center = True
|
||||
for place_handle in dbstate.db.iter_place_handles():
|
||||
place = dbstate.db.get_place_from_handle( place_handle)
|
||||
if place:
|
||||
|
||||
for place in dbstate.db.iter_places():
|
||||
descr = place.get_title()
|
||||
descr1 = _("Id : %s") % place.gramps_id
|
||||
longitude = place.get_longitude()
|
||||
@ -1221,9 +1220,8 @@ class GeoView(HtmlView):
|
||||
latitude = ""
|
||||
longitude = ""
|
||||
self.center = True
|
||||
for event_handle in dbstate.db.get_event_handles():
|
||||
event = dbstate.db.get_event_from_handle( event_handle)
|
||||
if event:
|
||||
|
||||
for event in dbstate.db.iter_events():
|
||||
place_handle = event.get_place_handle()
|
||||
eventdate = event.get_date_object()
|
||||
eventyear = eventdate.get_year()
|
||||
@ -1246,9 +1244,8 @@ class GeoView(HtmlView):
|
||||
if ( longitude and latitude ):
|
||||
person_list = [
|
||||
dbstate.db.get_person_from_handle(ref_handle)
|
||||
for (ref_type, ref_handle) in \
|
||||
dbstate.db.find_backlink_handles(
|
||||
event_handle)
|
||||
for (ref_type, ref_handle) in
|
||||
dbstate.db.find_backlink_handles(event.handle)
|
||||
if ref_type == 'Person'
|
||||
]
|
||||
if person_list:
|
||||
|
@ -160,15 +160,13 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
|
||||
def cache_repos(self):
|
||||
# search all matching repositories
|
||||
for repo_handle in self.db.get_repository_handles():
|
||||
repo = self.db.get_repository_from_handle(repo_handle)
|
||||
for repo in self.db.iter_repositories():
|
||||
if( self.match_object(repo)):
|
||||
self.repo_map[repo_handle] = 1
|
||||
self.repo_map[repo.handle] = 1
|
||||
|
||||
def cache_sources(self):
|
||||
# search all sources and match all referents of a matching source
|
||||
for source_handle in self.db.get_source_handles():
|
||||
source = self.db.get_source_from_handle(source_handle)
|
||||
for source in self.db.iter_sources():
|
||||
match = self.match_object(source)
|
||||
if not match:
|
||||
for reporef in source.get_reporef_list():
|
||||
@ -177,7 +175,7 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
if match:
|
||||
(person_list,family_list,event_list,place_list,source_list,
|
||||
media_list,repo_list
|
||||
) = get_source_referents(source_handle,self.db)
|
||||
) = get_source_referents(source.handle,self.db)
|
||||
for handle in person_list:
|
||||
self.person_map[handle] = 1
|
||||
for handle in family_list:
|
||||
|
@ -196,8 +196,8 @@ class CommandLineTool(object):
|
||||
person_id = self.options_dict['id']
|
||||
self.person = self.database.get_person_from_gramps_id(person_id)
|
||||
id_list = []
|
||||
for person_handle in self.database.get_person_handles():
|
||||
person = self.database.get_person_from_handle(person_handle)
|
||||
|
||||
for person in self.database.iter_people():
|
||||
id_list.append("%s\t%s" % (
|
||||
person.get_gramps_id(),
|
||||
name_displayer.display(person)))
|
||||
|
@ -81,12 +81,11 @@ class StatsGramplet(Gramplet):
|
||||
notfound = []
|
||||
|
||||
pobjects = database.get_number_of_media_objects()
|
||||
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)
|
||||
except:
|
||||
except OSError:
|
||||
notfound.append(photo.get_path())
|
||||
|
||||
for cnt, person in enumerate(personList):
|
||||
@ -97,7 +96,7 @@ class StatsGramplet(Gramplet):
|
||||
|
||||
names = [person.get_primary_name()] + person.get_alternate_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 += 1
|
||||
if name.get_group_name() not in namelist:
|
||||
namelist.append(name.get_group_name())
|
||||
|
@ -81,15 +81,14 @@ def run(database, document, main_event):
|
||||
yeartab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
|
||||
histab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
|
||||
|
||||
for event_handle in database.get_event_handles():
|
||||
event = database.get_event_from_handle(event_handle)
|
||||
for event in database.iter_events():
|
||||
date = event.get_date_object()
|
||||
if date.get_year() == 0:
|
||||
continue
|
||||
if (date.get_year() == main_date.get_year() and
|
||||
date.get_month() == main_date.get_month() and
|
||||
date.get_day() == main_date.get_day()):
|
||||
for (objclass, handle) in database.find_backlink_handles(event_handle):
|
||||
for (objclass, handle) in database.find_backlink_handles(event.handle):
|
||||
ref = get_ref(database, objclass, handle)
|
||||
stab.row(date,
|
||||
sdb.event_type(event),
|
||||
@ -97,13 +96,13 @@ def run(database, document, main_event):
|
||||
elif (date.get_month() == main_date.get_month() and
|
||||
date.get_day() == main_date.get_day() and
|
||||
date.get_month() != 0):
|
||||
for (objclass, handle) in database.find_backlink_handles(event_handle):
|
||||
for (objclass, handle) in database.find_backlink_handles(event.handle):
|
||||
ref = get_ref(database, objclass, handle)
|
||||
histab.row(date,
|
||||
sdb.event_type(event),
|
||||
sdb.event_place(event), ref)
|
||||
elif (date.get_year() == main_date.get_year()):
|
||||
for (objclass, handle) in database.find_backlink_handles(event_handle):
|
||||
for (objclass, handle) in database.find_backlink_handles(event.handle):
|
||||
ref = get_ref(database, objclass, handle)
|
||||
yeartab.row(date,
|
||||
sdb.event_type(event),
|
||||
|
Loading…
Reference in New Issue
Block a user