Geography : trying to solve possible gramps.gen.errors.HandleError: Handle is None
This commit is contained in:
parent
2aca380484
commit
60f4c76fa2
@ -781,10 +781,13 @@ class GeoGraphyView(OsmGps, NavigationView):
|
||||
fnam = mnam = _("Unknown")
|
||||
if family_list:
|
||||
for family in family_list:
|
||||
father = mother = None
|
||||
handle = family.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
handle = family.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
fnam = _nd.display(father) if father else _("Unknown")
|
||||
mnam = _nd.display(mother) if mother else _("Unknown")
|
||||
return ( fnam, mnam )
|
||||
|
@ -198,10 +198,13 @@ class GeoFamClose(GeoGraphyView):
|
||||
def family_label(self,family):
|
||||
if family is None:
|
||||
return "Unknown"
|
||||
f = self.dbstate.db.get_person_from_handle(
|
||||
family.get_father_handle())
|
||||
m = self.dbstate.db.get_person_from_handle(
|
||||
family.get_mother_handle())
|
||||
f = m = None
|
||||
hdl = family.get_father_handle()
|
||||
if hdl:
|
||||
f = self.dbstate.db.get_person_from_handle(hdl)
|
||||
hdl = family.get_mother_handle()
|
||||
if hdl:
|
||||
m = self.dbstate.db.get_person_from_handle(hdl)
|
||||
if f and m:
|
||||
label = _("%(gramps_id)s : %(father)s and %(mother)s") % {
|
||||
'father' : _nd.display(f),
|
||||
@ -377,12 +380,15 @@ class GeoFamClose(GeoGraphyView):
|
||||
if len(family_list) > 0:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
self.possible_meeting(father, ref_person)
|
||||
handle = fam.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
self.possible_meeting(mother, ref_person)
|
||||
child_ref_list = fam.get_child_ref_list()
|
||||
@ -400,25 +406,33 @@ class GeoFamClose(GeoGraphyView):
|
||||
try to expose each person of the reference family to the second family
|
||||
"""
|
||||
dbstate = self.dbstate
|
||||
person = None
|
||||
try:
|
||||
person = dbstate.db.get_person_from_handle(reference.get_father_handle())
|
||||
except:
|
||||
return
|
||||
if person is None: # family without father ?
|
||||
person = dbstate.db.get_person_from_handle(reference.get_mother_handle())
|
||||
handle = reference.get_mother_handle()
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
if person is None:
|
||||
person = dbstate.db.get_person_from_handle(self.uistate.get_active('Person'))
|
||||
handle = self.uistate.get_active('Person')
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
if person is not None:
|
||||
family_list = person.get_family_handle_list()
|
||||
if len(family_list) > 0:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
self._expose_persone_to_family(father, family)
|
||||
handle = fam.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
self._expose_persone_to_family(mother, family)
|
||||
child_ref_list = fam.get_child_ref_list()
|
||||
@ -488,13 +502,16 @@ class GeoFamClose(GeoGraphyView):
|
||||
family = self.dbstate.db.get_family_from_handle(family_hdl)
|
||||
if family is not None:
|
||||
fhandle = family_list[0] # first is primary
|
||||
father = mother = None
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
handle = fam.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
descr1 = "%s - " % _nd.display(father)
|
||||
handle = fam.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
descr1 = "%s%s" % ( descr1, _nd.display(mother))
|
||||
for event_ref in family.get_event_ref_list():
|
||||
@ -544,28 +561,36 @@ class GeoFamClose(GeoGraphyView):
|
||||
Create all markers for one family : all event's places with a lat/lon.
|
||||
"""
|
||||
dbstate = self.dbstate
|
||||
person = None
|
||||
try:
|
||||
person = dbstate.db.get_person_from_handle(family.get_father_handle())
|
||||
except:
|
||||
return
|
||||
family_id = family.gramps_id
|
||||
if person is None: # family without father ?
|
||||
person = dbstate.db.get_person_from_handle(family.get_mother_handle())
|
||||
handle = family.get_mother_handle()
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
if person is None:
|
||||
person = dbstate.db.get_person_from_handle(self.uistate.get_active('Person'))
|
||||
handle = self.uistate.get_active('Person')
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
if person is not None:
|
||||
family_list = person.get_family_handle_list()
|
||||
if len(family_list) > 0:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
comment = _("Father : %(id)s : %(name)s") % {'id': father.gramps_id,
|
||||
'name': _nd.display(father)}
|
||||
self._createmap_for_one_person(father, color, place_list, reference)
|
||||
handle = fam.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
comment = _("Mother : %(id)s : %(name)s") % {'id': mother.gramps_id,
|
||||
'name': _nd.display(mother)}
|
||||
@ -611,7 +636,10 @@ class GeoFamClose(GeoGraphyView):
|
||||
#family = self.dbstate.db.get_family_from_handle(family_x)
|
||||
family = family_x
|
||||
if family is None:
|
||||
person = self.dbstate.db.get_family_from_handle(self.uistate.get_active('Person'))
|
||||
handle = self.uistate.get_active('Person')
|
||||
person = None
|
||||
if handle:
|
||||
person = self.dbstate.db.get_family_from_handle(handle)
|
||||
if not person:
|
||||
return
|
||||
family_list = person.get_family_handle_list()
|
||||
|
@ -271,10 +271,13 @@ class GeoFamily(GeoGraphyView):
|
||||
def family_label(self,family):
|
||||
if family is None:
|
||||
return "Unknown"
|
||||
f = self.dbstate.db.get_person_from_handle(
|
||||
family.get_father_handle())
|
||||
m = self.dbstate.db.get_person_from_handle(
|
||||
family.get_mother_handle())
|
||||
f = m = None
|
||||
hdl = family.get_father_handle()
|
||||
if hdl:
|
||||
f = self.dbstate.db.get_person_from_handle(hdl)
|
||||
hdl = family.get_mother_handle()
|
||||
if hdl:
|
||||
m = self.dbstate.db.get_person_from_handle(hdl)
|
||||
if f and m:
|
||||
label = _("%(gramps_id)s : %(father)s and %(mother)s") % {
|
||||
'father' : _nd.display(f),
|
||||
@ -304,29 +307,37 @@ class GeoFamily(GeoGraphyView):
|
||||
"""
|
||||
dbstate = self.dbstate
|
||||
self.message_layer.add_message(_("Family places for %s") % self.family_label(family))
|
||||
try:
|
||||
person = None
|
||||
if family:
|
||||
person = dbstate.db.get_person_from_handle(family.get_father_handle())
|
||||
except:
|
||||
else:
|
||||
return
|
||||
family_id = family.gramps_id
|
||||
if person is None: # family without father ?
|
||||
person = dbstate.db.get_person_from_handle(family.get_mother_handle())
|
||||
handle = family.get_mother_handle()
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
if person is None:
|
||||
person = dbstate.db.get_person_from_handle(self.uistate.get_active('Person'))
|
||||
handle = self.uistate.get_active('Person')
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
if person is not None:
|
||||
family_list = person.get_family_handle_list()
|
||||
if len(family_list) > 0:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
comment = _("Father : %(id)s : %(name)s") % {'id': father.gramps_id,
|
||||
'name': _nd.display(father) }
|
||||
self._createpersonmarkers(dbstate, father,
|
||||
comment, family_id)
|
||||
handle = fam.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
comment = _("Mother : %(id)s : %(name)s") % {'id': mother.gramps_id,
|
||||
'name': _nd.display(mother) }
|
||||
|
@ -315,12 +315,15 @@ class GeoMoves(GeoGraphyView):
|
||||
if family is not None:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
mother = father = None
|
||||
handle = fam.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
descr1 = "%s - " % _nd.display(father)
|
||||
handle = fam.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
descr1 = "%s%s" % ( descr1, _nd.display(mother))
|
||||
for event_ref in family.get_event_ref_list():
|
||||
@ -383,27 +386,35 @@ class GeoMoves(GeoGraphyView):
|
||||
Create all markers for one family : all event's places with a lat/lon.
|
||||
"""
|
||||
dbstate = self.dbstate
|
||||
person = None
|
||||
try:
|
||||
person = dbstate.db.get_person_from_handle(family.get_father_handle())
|
||||
except:
|
||||
return
|
||||
family_id = family.gramps_id
|
||||
if person is None: # family without father ?
|
||||
person = dbstate.db.get_person_from_handle(family.get_mother_handle())
|
||||
handle = family.get_mother_handle()
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
if person is None:
|
||||
person = dbstate.db.get_person_from_handle(self.uistate.get_active('Person'))
|
||||
handle = self.uistate.get_active('Person')
|
||||
if handle:
|
||||
person = dbstate.db.get_person_from_handle(handle)
|
||||
if person is not None:
|
||||
self._add_person_to_list(person.gramps_id, curlevel-1)
|
||||
family_list = person.get_family_handle_list()
|
||||
for fhandle in family_list:
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if father:
|
||||
self._createmap_for_next_level(father, level-1, level)
|
||||
self._add_person_to_list(father.gramps_id, curlevel-1)
|
||||
handle = fam.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
self._createmap_for_next_level(father, level-1, level)
|
||||
self._add_person_to_list(mother.gramps_id, curlevel-1)
|
||||
@ -464,7 +475,9 @@ class GeoMoves(GeoGraphyView):
|
||||
self.place_without_coordinates = []
|
||||
self.minlat = self.maxlat = self.minlon = self.maxlon = 0.0
|
||||
if person is None:
|
||||
person = self.dbstate.db.get_person_from_handle(self.uistate.get_active('Person'))
|
||||
handle = self.uistate.get_active('Person')
|
||||
if handle:
|
||||
person = self.dbstate.db.get_person_from_handle(handle)
|
||||
if not person:
|
||||
return
|
||||
self.message_layer.add_message(_("All descendance for %s") % _nd.display(person))
|
||||
|
@ -202,11 +202,12 @@ class GeoPerson(GeoGraphyView):
|
||||
Rebuild the tree with the given person handle as the root.
|
||||
"""
|
||||
active = self.get_active()
|
||||
if handle:
|
||||
self._createmap(handle)
|
||||
elif active:
|
||||
p1 = self.dbstate.db.get_person_from_handle(active)
|
||||
self._createmap(p1)
|
||||
#if handle:
|
||||
# self._createmap(handle)
|
||||
#elif active:
|
||||
# p1 = self.dbstate.db.get_person_from_handle(active)
|
||||
# self._createmap(p1)
|
||||
self._createmap()
|
||||
self.uistate.modify_statusbar(self.dbstate)
|
||||
|
||||
def build_tree(self):
|
||||
@ -216,7 +217,9 @@ class GeoPerson(GeoGraphyView):
|
||||
information.
|
||||
"""
|
||||
active = self.get_active()
|
||||
self._createmap(active)
|
||||
#self._createmap(active)
|
||||
self._createmap()
|
||||
self.uistate.modify_statusbar(self.dbstate)
|
||||
|
||||
def animate(self, menu, marks, index, stepyear):
|
||||
"""
|
||||
@ -286,7 +289,8 @@ class GeoPerson(GeoGraphyView):
|
||||
menu, marks, i, stepyear)
|
||||
return False
|
||||
|
||||
def _createmap(self,obj):
|
||||
#def _createmap(self,obj):
|
||||
def _createmap(self):
|
||||
"""
|
||||
Create all markers for each people's event in the database which has
|
||||
a lat/lon.
|
||||
@ -306,7 +310,9 @@ class GeoPerson(GeoGraphyView):
|
||||
self.message_layer.clear_messages()
|
||||
self.kml_layer.clear()
|
||||
person_handle = self.uistate.get_active('Person')
|
||||
person = dbstate.db.get_person_from_handle(person_handle) if person_handle else None
|
||||
person = None
|
||||
if person_handle:
|
||||
person = dbstate.db.get_person_from_handle(person_handle)
|
||||
if person is not None:
|
||||
# For each event, if we have a place, set a marker.
|
||||
self.load_kml_files(person)
|
||||
@ -357,13 +363,16 @@ class GeoPerson(GeoGraphyView):
|
||||
if family is not None:
|
||||
fhandle = family_list[0] # first is primary
|
||||
fam = dbstate.db.get_family_from_handle(fhandle)
|
||||
father = mother = None
|
||||
handle = fam.get_father_handle()
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
father = dbstate.db.get_person_from_handle(handle)
|
||||
descr1 = " - "
|
||||
if father:
|
||||
descr1 = "%s - " % _nd.display(father)
|
||||
handle = fam.get_mother_handle()
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if handle:
|
||||
mother = dbstate.db.get_person_from_handle(handle)
|
||||
if mother:
|
||||
descr1 = "%s%s" % ( descr1, _nd.display(mother))
|
||||
for event_ref in family.get_event_ref_list():
|
||||
|
Loading…
Reference in New Issue
Block a user