* src/AutoComp.py: remove double display of data
* src/FamilyView.py: remove unused check * src/GrampsBSDDB.py: search by gramps_id * src/GrampsDbBase.py: search by gramps_id, unicode/str conversions * src/Marriage.py: handle gramps_id editing * src/ReadXML.py: fix handle/gramps_id on import * src/plugins/RelCalc.py: display date instead of event handle * src/Relationship.py: family handles working * src/PeopleModel.py: comment out unused functions * src/PeopleModel.py: simplify model interface * src/AddSpouse.py: get_family_from_handle fixes * src/EditPerson.py: get_family_from_handle fixes * src/EditSource.py: get_family_from_handle fixes * src/GraphLayout.py: get_family_from_handle fixes * src/ImageSelect.py: get_family_from_handle fixes * src/MediaView.py: get_family_from_handle fixes * src/MergeData.py: get_family_from_handle fixes * src/PlaceView.py: get_family_from_handle fixes * src/ReadXML.py: get_family_from_handle fixes * src/RelLib.py: get_family_from_handle fixes * src/Relationship.py: get_family_from_handle fixes * src/SelectChild.py: get_family_from_handle fixes * src/SourceView.py: get_family_from_handle fixes * src/SubstKeywords.py: get_family_from_handle fixes * src/WriteXML.py: get_family_from_handle fixes * src/gramps_main.py: get_family_from_handle fixes svn: r3446
This commit is contained in:
parent
9b427a6f64
commit
e50e33cba6
@ -1,21 +1,30 @@
|
||||
2004-08-19 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* PeopleModel.py: simplify model interface
|
||||
* AddSpouse.py: get_family_from_handle fixes
|
||||
* EditPerson.py: get_family_from_handle fixes
|
||||
* EditSource.py: get_family_from_handle fixes
|
||||
* GraphLayout.py: get_family_from_handle fixes
|
||||
* ImageSelect.py: get_family_from_handle fixes
|
||||
* MediaView.py: get_family_from_handle fixes
|
||||
* MergeData.py: get_family_from_handle fixes
|
||||
* PlaceView.py: get_family_from_handle fixes
|
||||
* ReadXML.py: get_family_from_handle fixes
|
||||
* RelLib.py: get_family_from_handle fixes
|
||||
* Relationship.py: get_family_from_handle fixes
|
||||
* SelectChild.py: get_family_from_handle fixes
|
||||
* SourceView.py: get_family_from_handle fixes
|
||||
* SubstKeywords.py: get_family_from_handle fixes
|
||||
* WriteXML.py: get_family_from_handle fixes
|
||||
* gramps_main.py: get_family_from_handle fixes
|
||||
* src/AutoComp.py: remove double display of data
|
||||
* src/FamilyView.py: remove unused check
|
||||
* src/GrampsBSDDB.py: search by gramps_id
|
||||
* src/GrampsDbBase.py: search by gramps_id, unicode/str conversions
|
||||
* src/Marriage.py: handle gramps_id editing
|
||||
* src/ReadXML.py: fix handle/gramps_id on import
|
||||
* src/plugins/RelCalc.py: display date instead of event handle
|
||||
* src/Relationship.py: family handles working
|
||||
* src/PeopleModel.py: comment out unused functions
|
||||
* src/PeopleModel.py: simplify model interface
|
||||
* src/AddSpouse.py: get_family_from_handle fixes
|
||||
* src/EditPerson.py: get_family_from_handle fixes
|
||||
* src/EditSource.py: get_family_from_handle fixes
|
||||
* src/GraphLayout.py: get_family_from_handle fixes
|
||||
* src/ImageSelect.py: get_family_from_handle fixes
|
||||
* src/MediaView.py: get_family_from_handle fixes
|
||||
* src/MergeData.py: get_family_from_handle fixes
|
||||
* src/PlaceView.py: get_family_from_handle fixes
|
||||
* src/ReadXML.py: get_family_from_handle fixes
|
||||
* src/RelLib.py: get_family_from_handle fixes
|
||||
* src/Relationship.py: get_family_from_handle fixes
|
||||
* src/SelectChild.py: get_family_from_handle fixes
|
||||
* src/SourceView.py: get_family_from_handle fixes
|
||||
* src/SubstKeywords.py: get_family_from_handle fixes
|
||||
* src/WriteXML.py: get_family_from_handle fixes
|
||||
* src/gramps_main.py: get_family_from_handle fixes
|
||||
* plugins/AncestorChart.py: get_family_from_handle fixes
|
||||
* plugins/AncestorChart2.py: get_family_from_handle fixes
|
||||
* plugins/AncestorReport.py: get_family_from_handle fixes
|
||||
|
@ -44,7 +44,6 @@ def fill_combo(combo,data_list):
|
||||
|
||||
def fill_entry(entry,data_list):
|
||||
store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
|
||||
for data in data_list:
|
||||
store.append(row=[data])
|
||||
|
||||
@ -57,8 +56,6 @@ def fill_entry(entry,data_list):
|
||||
def fill_option_text(combobox,data):
|
||||
store = gtk.ListStore(gobject.TYPE_STRING)
|
||||
cell = gtk.CellRendererText()
|
||||
combobox.pack_start(cell,gtk.TRUE)
|
||||
combobox.add_attribute(cell,'text',0)
|
||||
for item in data:
|
||||
store.append(row=[item])
|
||||
combobox.set_model(store)
|
||||
|
@ -907,8 +907,6 @@ class FamilyView:
|
||||
flist = {}
|
||||
|
||||
for f in splist:
|
||||
if not f:
|
||||
continue
|
||||
fm = self.parent.db.get_family_from_handle(f)
|
||||
|
||||
if fm.get_father_handle() == self.person.get_handle():
|
||||
|
@ -32,6 +32,9 @@ def find_surname(key,data):
|
||||
def find_idmap(key,data):
|
||||
return str(data[1])
|
||||
|
||||
def find_fidmap(key,data):
|
||||
return str(data[1])
|
||||
|
||||
def find_eventname(key,data):
|
||||
return str(data[1])
|
||||
|
||||
@ -76,11 +79,16 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.id_trans.set_flags(db.DB_DUP)
|
||||
self.id_trans.open(name, "idtrans", db.DB_HASH, flags=db.DB_CREATE)
|
||||
|
||||
self.fid_trans = db.DB(self.env)
|
||||
self.fid_trans.set_flags(db.DB_DUP)
|
||||
self.fid_trans.open(name, "fidtrans", db.DB_HASH, flags=db.DB_CREATE)
|
||||
|
||||
self.eventnames = db.DB(self.env)
|
||||
self.eventnames.set_flags(db.DB_DUP)
|
||||
self.eventnames.open(name, "eventnames", db.DB_HASH, flags=db.DB_CREATE)
|
||||
self.person_map.associate(self.surnames, find_surname, db.DB_CREATE)
|
||||
self.person_map.associate(self.id_trans, find_idmap, db.DB_CREATE)
|
||||
self.person_map.associate(self.fid_trans, find_fidmap, db.DB_CREATE)
|
||||
self.event_map.associate(self.eventnames, find_eventname, db.DB_CREATE)
|
||||
|
||||
self.undodb = db.DB()
|
||||
@ -106,6 +114,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.surnames.close()
|
||||
self.eventnames.close()
|
||||
self.id_trans.close()
|
||||
self.fid_trans.close()
|
||||
self.env.close()
|
||||
self.undodb.close()
|
||||
|
||||
@ -167,3 +176,26 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
transaction.add(EVENT_KEY,handle,old_data)
|
||||
self.event_map.delete(str(handle))
|
||||
|
||||
def get_person_from_gramps_id(self,val):
|
||||
"""finds a Person in the database from the passed gramps' ID.
|
||||
If no such Person exists, a new Person is added to the database."""
|
||||
|
||||
data = self.id_trans.get(str(val))
|
||||
if data:
|
||||
person = Person()
|
||||
person.unserialize(cPickle.loads(data))
|
||||
return person
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_family_from_gramps_id(self,val):
|
||||
"""finds a Person in the database from the passed gramps' ID.
|
||||
If no such Person exists, a new Person is added to the database."""
|
||||
|
||||
data = self.fid_trans.get(str(val))
|
||||
if data:
|
||||
family = Family()
|
||||
family.unserialize(cPickle.loads(data))
|
||||
return family
|
||||
else:
|
||||
return None
|
||||
|
@ -106,14 +106,14 @@ class GrampsDbBase:
|
||||
Opens the specified database. The method needs to be overridden
|
||||
in the derived class.
|
||||
"""
|
||||
assert(0,"Needs to be overridden in the derived class")
|
||||
assert(False,"Needs to be overridden in the derived class")
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Closes the specified database. The method needs to be overridden
|
||||
in the derived class.
|
||||
"""
|
||||
assert(0,"Needs to be overridden in the derived class")
|
||||
assert(False,"Needs to be overridden in the derived class")
|
||||
|
||||
def is_open(self):
|
||||
"""
|
||||
@ -126,7 +126,7 @@ class GrampsDbBase:
|
||||
Commits the specified Person to the database, storing the changes
|
||||
as part of the transaction.
|
||||
"""
|
||||
handle = person.get_handle()
|
||||
handle = str(person.get_handle())
|
||||
if transaction != None:
|
||||
old_data = self.person_map.get(handle)
|
||||
transaction.add(PERSON_KEY,handle,old_data)
|
||||
@ -141,7 +141,7 @@ class GrampsDbBase:
|
||||
if transaction != None:
|
||||
old_data = self.media_map.get(handle)
|
||||
transaction.add(MEDIA_KEY,handle,old_data)
|
||||
self.media_map[str(obj.get_handle())] = obj.serialize()
|
||||
self.media_map[handle] = obj.serialize()
|
||||
|
||||
def commit_source(self,source,transaction):
|
||||
"""
|
||||
@ -152,7 +152,7 @@ class GrampsDbBase:
|
||||
if transaction != None:
|
||||
old_data = self.source_map.get(handle)
|
||||
transaction.add(SOURCE_KEY,handle,old_data)
|
||||
self.source_map[str(source.get_handle())] = source.serialize()
|
||||
self.source_map[handle] = source.serialize()
|
||||
|
||||
def commit_place(self,place,transaction):
|
||||
"""
|
||||
@ -163,7 +163,7 @@ class GrampsDbBase:
|
||||
if transaction != None:
|
||||
old_data = self.place_map.get(handle)
|
||||
transaction.add(PLACE_KEY,handle,old_data)
|
||||
self.place_map[str(place.get_handle())] = place.serialize()
|
||||
self.place_map[handle] = place.serialize()
|
||||
|
||||
def commit_event(self,event,transaction):
|
||||
"""
|
||||
@ -174,7 +174,7 @@ class GrampsDbBase:
|
||||
if transaction != None:
|
||||
old_data = self.event_map.get(handle)
|
||||
transaction.add(EVENT_KEY,handle,old_data)
|
||||
self.event_map[str(event.get_handle())] = event.serialize()
|
||||
self.event_map[handle] = event.serialize()
|
||||
|
||||
def commit_family(self,family,transaction):
|
||||
"""
|
||||
@ -185,7 +185,7 @@ class GrampsDbBase:
|
||||
if transaction != None:
|
||||
old_data = self.family_map.get(handle)
|
||||
transaction.add(FAMILY_KEY,handle,old_data)
|
||||
self.family_map[str(family.get_handle())] = family.serialize()
|
||||
self.family_map[handle] = family.serialize()
|
||||
|
||||
def find_next_person_gramps_id(self):
|
||||
"""
|
||||
@ -263,7 +263,7 @@ class GrampsDbBase:
|
||||
"""finds a Person in the database from the passed gramps' ID.
|
||||
If no such Person exists, a new Person is added to the database."""
|
||||
|
||||
data = self.person_map.get(val)
|
||||
data = self.person_map.get(str(val))
|
||||
if data:
|
||||
person = Person()
|
||||
person.unserialize(data)
|
||||
@ -336,7 +336,7 @@ class GrampsDbBase:
|
||||
person.set_handle(val)
|
||||
if transaction != None:
|
||||
transaction.add(PERSON_KEY, val, None)
|
||||
self.person_map[val] = person.serialize()
|
||||
self.person_map[str(val)] = person.serialize()
|
||||
self.genderStats.count_person (person, self)
|
||||
return person
|
||||
|
||||
@ -390,7 +390,7 @@ class GrampsDbBase:
|
||||
data = self.place_map.get(str(handle))
|
||||
place = Place()
|
||||
if not data:
|
||||
place.handle = handle
|
||||
place.set_handle(handle)
|
||||
if transaction != None:
|
||||
transaction.add(PLACE_KEY,handle,None)
|
||||
self.place_map[str(handle)] = place.serialize()
|
||||
@ -408,13 +408,37 @@ class GrampsDbBase:
|
||||
if data:
|
||||
family.unserialize(data)
|
||||
else:
|
||||
family.handle = val
|
||||
family.set_handle(val)
|
||||
if transaction:
|
||||
transaction.add(FAMILY_KEY,val,None)
|
||||
self.family_map[str(val)] = family.serialize()
|
||||
self.fmap_index = self.fmap_index + 1
|
||||
return family
|
||||
|
||||
def get_person_from_gramps_id(self,val):
|
||||
"""
|
||||
Finds a Person in the database from the passed GRAMPS ID.
|
||||
If no such Person exists, None is returned.
|
||||
|
||||
Needs to be overridden by the derrived class.
|
||||
"""
|
||||
data = self.id_trans.get(str(val))
|
||||
if data:
|
||||
person = Person()
|
||||
person.unserialize(cPickle.loads(data))
|
||||
return person
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_family_from_gramps_id(self,val):
|
||||
"""
|
||||
Finds a Family in the database from the passed GRAMPS ID.
|
||||
If no such Family exists, None is returned.
|
||||
|
||||
Needs to be overridden by the derrived class.
|
||||
"""
|
||||
assert(False,"Needs to be overridden in the derived class")
|
||||
|
||||
def add_person(self,person,transaction):
|
||||
"""
|
||||
Adds a Person to the database, assigning internal IDs if they have
|
||||
@ -906,49 +930,23 @@ class GrampsDbBase:
|
||||
"""
|
||||
return self.media_map.has_key(str(handle)) != None
|
||||
|
||||
def get_person_from_gramps_id(self,val):
|
||||
"""finds a Person in the database from the passed gramps' ID.
|
||||
If no such Person exists, a new Person is added to the database."""
|
||||
|
||||
data = self.id_trans.get(str(val))
|
||||
if data:
|
||||
person = Person()
|
||||
person.unserialize(cPickle.loads(data))
|
||||
return person
|
||||
else:
|
||||
return None
|
||||
|
||||
def find_person_from_gramps_id(self,val,transaction):
|
||||
"""finds a Person in the database from the passed gramps' ID.
|
||||
If no such Person exists, a new Person is added to the database."""
|
||||
|
||||
person = Person()
|
||||
data = self.id_trans.get(str(val))
|
||||
if data:
|
||||
person.unserialize(cPickle.loads(data))
|
||||
else:
|
||||
intid = Utils.create_id()
|
||||
person.set_handle(intid)
|
||||
person.set_gramps_id(val)
|
||||
self.add_person(person,transaction)
|
||||
return person
|
||||
|
||||
def _sortbyname(self,f,s):
|
||||
n1 = self.person_map.get(f)[2].sname
|
||||
n2 = self.person_map.get(s)[2].sname
|
||||
n1 = self.person_map.get(str(f))[2].sname
|
||||
n2 = self.person_map.get(str(s))[2].sname
|
||||
return cmp(n1,n2)
|
||||
|
||||
def _sortbyplace(self,f,s):
|
||||
return cmp(self.place_map.get(f)[2].upper(), self.place_map.get(s)[2].upper())
|
||||
return cmp(self.place_map.get(str(f))[2].upper(),
|
||||
self.place_map.get(str(s))[2].upper())
|
||||
|
||||
def _sortbysource(self,f,s):
|
||||
fp = self.source_map[f][2].upper()
|
||||
sp = self.source_map[s][2].upper()
|
||||
fp = self.source_map[str(f)][2].upper()
|
||||
sp = self.source_map[str(s)][2].upper()
|
||||
return cmp(fp,sp)
|
||||
|
||||
def _sortbymedia(self,f,s):
|
||||
fp = self.media_map[f][4].upper()
|
||||
sp = self.media_map[s][4].upper()
|
||||
fp = self.media_map[str(f)][4].upper()
|
||||
sp = self.media_map[str(s)][4].upper()
|
||||
return cmp(fp,sp)
|
||||
|
||||
def set_person_column_order(self,list):
|
||||
|
@ -199,7 +199,7 @@ class Marriage:
|
||||
|
||||
frel = family.get_relationship()
|
||||
self.type_field.set_active(frel)
|
||||
self.gid.set_text(family.get_handle())
|
||||
self.gid.set_text(family.get_gramps_id())
|
||||
self.gid.set_editable(1)
|
||||
|
||||
AutoComp.fill_combo(self.lds_temple,_temple_names)
|
||||
@ -556,6 +556,9 @@ class Marriage:
|
||||
else:
|
||||
self.close(0)
|
||||
|
||||
def save(self):
|
||||
self.on_close_marriage_editor(None)
|
||||
|
||||
def on_delete_event(self,obj,b):
|
||||
self.on_cancel_edit(obj)
|
||||
|
||||
@ -565,11 +568,9 @@ class Marriage:
|
||||
|
||||
idval = unicode(self.gid.get_text())
|
||||
family = self.family
|
||||
if idval != family.get_handle():
|
||||
if not self.db.has_family_handle(idval):
|
||||
if self.db.has_family_handle(family.get_handle()):
|
||||
self.db.remove_family_handle(family.get_handle(),trans)
|
||||
family.set_handle(idval)
|
||||
if idval != family.get_gramps_id():
|
||||
if not self.db.get_family_from_gramps_id(idval):
|
||||
family.set_gramps_id(idval)
|
||||
else:
|
||||
WarningDialog(_("GRAMPS ID value was not changed."),
|
||||
_('The GRAMPS ID that you chose for this '
|
||||
|
@ -97,31 +97,8 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
else:
|
||||
self.rebuild_data()
|
||||
|
||||
self.connect('row-deleted',self.on_row_deleted)
|
||||
self.connect('row-inserted',self.on_row_inserted)
|
||||
|
||||
def on_row_inserted(self,model,path,iter):
|
||||
pass
|
||||
|
||||
def on_row_deleted(self,model,path):
|
||||
surname = self.top_path2iter[path[0]]
|
||||
pid = self.path2iter[(surname,path[1])]
|
||||
|
||||
for idval in self.sname_sub[surname]:
|
||||
key = self.iter2path[idval]
|
||||
del self.iter2path[idval]
|
||||
del self.path2iter[key]
|
||||
self.sname_sub[surname].remove(pid)
|
||||
|
||||
val = 0
|
||||
entries = self.sname_sub[surname]
|
||||
entries.sort(self.byname)
|
||||
for person_handle in entries:
|
||||
tpl = (surname,val)
|
||||
self.iter2path[person_handle] = tpl
|
||||
self.path2iter[tpl] = person_handle
|
||||
val += 1
|
||||
return 0
|
||||
# self.connect('row-deleted',self.on_row_deleted)
|
||||
# self.connect('row-inserted',self.on_row_inserted)
|
||||
|
||||
def rebuild_data(self):
|
||||
self.top_path2iter = []
|
||||
@ -165,44 +142,6 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
self.path2iter,
|
||||
self.sname_sub)
|
||||
|
||||
def add_person(self,person):
|
||||
pid = person.get_handle()
|
||||
need = 0
|
||||
surname = person.get_primary_name().get_surname()
|
||||
if self.sname_sub.has_key(surname):
|
||||
self.sname_sub[surname].append(pid)
|
||||
else:
|
||||
self.sname_sub[surname] = [pid]
|
||||
|
||||
inscol = 0
|
||||
sval = 0
|
||||
name_list = self.db.get_surname_list()
|
||||
for name in name_list:
|
||||
if self.sname_sub.has_key(name):
|
||||
self.top_path2iter[sval] = name
|
||||
if name == surname:
|
||||
inscol = (sval,)
|
||||
need = 1
|
||||
sval += 1
|
||||
|
||||
column = 0
|
||||
val = 0
|
||||
entries = self.sname_sub[surname]
|
||||
entries.sort(self.byname)
|
||||
for person_handle in entries:
|
||||
tpl = (surname,val)
|
||||
self.iter2path[person_handle] = tpl
|
||||
self.path2iter[tpl] = person_handle
|
||||
if person_handle == pid:
|
||||
column = val
|
||||
val += 1
|
||||
|
||||
col = self.top_path2iter.index(surname)
|
||||
mypath = (col[0],column)
|
||||
if need:
|
||||
self.row_inserted(inscol,self.get_iter(inscol))
|
||||
self.row_inserted(mypath,self.get_iter(mypath))
|
||||
|
||||
def byname(self,f,s):
|
||||
n1 = self.db.person_map.get(str(f))[_NAME_COL].get_sort_name()
|
||||
n2 = self.db.person_map.get(str(s))[_NAME_COL].get_sort_name()
|
||||
@ -384,4 +323,65 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return self.db.get_place_from_handle(place_handle).get_title()
|
||||
return u""
|
||||
|
||||
# def add_person(self,person):
|
||||
# pid = person.get_handle()
|
||||
# need = 0
|
||||
# surname = person.get_primary_name().get_surname()
|
||||
# if self.sname_sub.has_key(surname):
|
||||
# self.sname_sub[surname].append(pid)
|
||||
# else:
|
||||
# self.sname_sub[surname] = [pid]
|
||||
|
||||
# inscol = 0
|
||||
# sval = 0
|
||||
# name_list = self.db.get_surname_list()
|
||||
# for name in name_list:
|
||||
# if self.sname_sub.has_key(name):
|
||||
# self.top_path2iter[sval] = name
|
||||
# if name == surname:
|
||||
# inscol = (sval,)
|
||||
# need = 1
|
||||
# sval += 1
|
||||
|
||||
# column = 0
|
||||
# val = 0
|
||||
# entries = self.sname_sub[surname]
|
||||
# entries.sort(self.byname)
|
||||
# for person_handle in entries:
|
||||
# tpl = (surname,val)
|
||||
# self.iter2path[person_handle] = tpl
|
||||
# self.path2iter[tpl] = person_handle
|
||||
# if person_handle == pid:
|
||||
# column = val
|
||||
# val += 1
|
||||
|
||||
# col = self.top_path2iter.index(surname)
|
||||
# mypath = (col[0],column)
|
||||
# if need:
|
||||
# self.row_inserted(inscol,self.get_iter(inscol))
|
||||
# self.row_inserted(mypath,self.get_iter(mypath))
|
||||
|
||||
# def on_row_inserted(self,model,path,iter):
|
||||
# pass
|
||||
|
||||
# def on_row_deleted(self,model,path):
|
||||
# surname = self.top_path2iter[path[0]]
|
||||
# pid = self.path2iter[(surname,path[1])]
|
||||
|
||||
# for idval in self.sname_sub[surname]:
|
||||
# key = self.iter2path[idval]
|
||||
# del self.iter2path[idval]
|
||||
# del self.path2iter[key]
|
||||
# self.sname_sub[surname].remove(pid)
|
||||
|
||||
# val = 0
|
||||
# entries = self.sname_sub[surname]
|
||||
# entries.sort(self.byname)
|
||||
# for person_handle in entries:
|
||||
# tpl = (surname,val)
|
||||
# self.iter2path[person_handle] = tpl
|
||||
# self.path2iter[tpl] = person_handle
|
||||
# val += 1
|
||||
# return 0
|
||||
|
||||
_GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ]
|
||||
|
@ -278,6 +278,7 @@ class GrampsParser:
|
||||
self.tlist = []
|
||||
self.conf = 2
|
||||
self.gid2id = {}
|
||||
self.gid2fid = {}
|
||||
|
||||
self.ord = None
|
||||
self.objref = None
|
||||
@ -329,6 +330,7 @@ class GrampsParser:
|
||||
self.func = None
|
||||
self.witness_comment = ""
|
||||
self.idswap = {}
|
||||
self.fidswap = {}
|
||||
|
||||
self.func_map = {
|
||||
"address" : (self.start_address, self.stop_address),
|
||||
@ -414,26 +416,47 @@ class GrampsParser:
|
||||
}
|
||||
|
||||
def find_person_by_gramps_id(self,gramps_id):
|
||||
person = RelLib.Person()
|
||||
intid = self.gid2id.get(gramps_id)
|
||||
if intid:
|
||||
person.unserialize(self.db.person_map.get(intid))
|
||||
person = self.db.get_person_from_handle(intid)
|
||||
else:
|
||||
intid = Utils.create_id()
|
||||
person = RelLib.Person()
|
||||
person.set_handle(intid)
|
||||
person.set_gramps_id(gramps_id)
|
||||
self.db.add_person(person,self.trans)
|
||||
self.gid2id[gramps_id] = intid
|
||||
return person
|
||||
|
||||
def find_family_by_gramps_id(self,gramps_id):
|
||||
intid = self.gid2fid.get(gramps_id)
|
||||
if intid:
|
||||
family = self.db.get_family_from_handle(intid)
|
||||
else:
|
||||
intid = Utils.create_id()
|
||||
family = RelLib.Family()
|
||||
family.set_handle(intid)
|
||||
family.set_gramps_id(gramps_id)
|
||||
self.db.add_family(family,self.trans)
|
||||
self.gid2fid[gramps_id] = intid
|
||||
return family
|
||||
|
||||
def map_gid(self,id):
|
||||
if not self.idswap.get(id):
|
||||
if self.db.id_trans.get(str(id)):
|
||||
if self.db.get_person_from_gramps_id(id):
|
||||
self.idswap[id] = self.db.find_next_person_gramps_id()
|
||||
else:
|
||||
self.idswap[id] = id
|
||||
return self.idswap[id]
|
||||
|
||||
def map_fid(self,id):
|
||||
if not self.fidswap.get(id):
|
||||
if self.db.get_family_from_gramps_id(id):
|
||||
self.fidswap[id] = self.db.find_next_family_gramps_id()
|
||||
else:
|
||||
self.fidswap[id] = id
|
||||
return self.fidswap[id]
|
||||
|
||||
def parse(self,file):
|
||||
self.trans = self.db.transaction_begin()
|
||||
p = xml.parsers.expat.ParserCreate()
|
||||
@ -444,7 +467,7 @@ class GrampsParser:
|
||||
|
||||
self.db.set_researcher(self.owner)
|
||||
if self.tempDefault != None:
|
||||
id = self.tempDefault
|
||||
id = self.map_gid(self.tempDefault)
|
||||
person = self.find_person_by_gramps_id(id)
|
||||
if person:
|
||||
self.db.set_default_person_handle(person.get_handle())
|
||||
@ -477,8 +500,8 @@ class GrampsParser:
|
||||
self.ord.set_status(int(attrs['val']))
|
||||
|
||||
def start_sealed_to(self,attrs):
|
||||
id = self.map_gid(attrs['ref'])
|
||||
self.ord.set_family_handle(self.db.find_family_from_handle(id,self.trans))
|
||||
id = self.map_fid(attrs['ref'])
|
||||
self.ord.set_family_handle(self.find_family_by_gramps_id(id))
|
||||
|
||||
def start_place(self,attrs):
|
||||
self.placeobj = self.db.find_place_from_handle(attrs['ref'],self.trans)
|
||||
@ -578,7 +601,8 @@ class GrampsParser:
|
||||
self.address.private = int(attrs["priv"])
|
||||
|
||||
def start_bmark(self,attrs):
|
||||
person = self.find_person_by_gramps_id(self.map_gid(attrs["ref"]))
|
||||
id = self.map_gid(attrs["ref"])
|
||||
person = self.find_person_by_gramps_id(id)
|
||||
self.db.bookmarks.append(person.get_handle())
|
||||
|
||||
def start_person(self,attrs):
|
||||
@ -635,7 +659,7 @@ class GrampsParser:
|
||||
if self.callback != None and self.count % self.increment == 0:
|
||||
self.callback(float(self.count)/float(self.entries))
|
||||
self.count = self.count + 1
|
||||
self.family = self.db.find_family_from_handle(attrs["id"],self.trans)
|
||||
self.family = self.find_family_by_gramps_id(self.map_fid(attrs["id"]))
|
||||
|
||||
if attrs.has_key("type"):
|
||||
self.family.set_relationship(_FAMILY_TRANS.get(attrs["type"],
|
||||
@ -646,7 +670,7 @@ class GrampsParser:
|
||||
self.family.set_complete_flag(0)
|
||||
|
||||
def start_childof(self,attrs):
|
||||
family = self.db.find_family_from_handle(attrs["ref"],self.trans)
|
||||
family = self.find_family_by_gramps_id(self.map_fid(attrs["ref"]))
|
||||
if attrs.has_key("mrel"):
|
||||
mrel = attrs["mrel"]
|
||||
else:
|
||||
@ -658,7 +682,8 @@ class GrampsParser:
|
||||
self.person.add_parent_family_handle(family.get_handle(),mrel,frel)
|
||||
|
||||
def start_parentin(self,attrs):
|
||||
self.person.add_family_handle(attrs["ref"])
|
||||
family = self.find_family_by_gramps_id(self.map_fid(attrs["ref"]))
|
||||
self.person.add_family_handle(family.get_handle())
|
||||
|
||||
def start_name(self,attrs):
|
||||
if not self.in_witness:
|
||||
|
@ -502,14 +502,6 @@ class Person(PrimaryObject,SourceNote):
|
||||
else:
|
||||
return self.parent_family_list[0][0]
|
||||
|
||||
def get_main_parents_family_handle(self):
|
||||
"""returns the main Family of the Person, the Family in which the
|
||||
Person is a natural born child"""
|
||||
if len(self.parent_family_list) == 0:
|
||||
return (None,None,None)
|
||||
else:
|
||||
return self.parent_family_list[0]
|
||||
|
||||
def set_lds_baptism(self,ord):
|
||||
"""Sets the LDS Baptism ordinance"""
|
||||
self.lds_bapt = ord
|
||||
|
@ -170,8 +170,8 @@ class RelationshipCalculator:
|
||||
pmap[person.get_handle()] = index
|
||||
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
if family_handle != None:
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
if family != None:
|
||||
father = self.db.get_person_from_handle(family.get_father_handle())
|
||||
mother = self.db.get_person_from_handle(family.get_mother_handle())
|
||||
self.apply_filter(father,index+1,plist,pmap)
|
||||
|
@ -98,7 +98,8 @@ class RelCalc:
|
||||
if p == self.person:
|
||||
continue
|
||||
val = self.db.get_person_from_handle(key).get_display_info()
|
||||
self.clist.add([val[0],val[1],val[3],val[5],val[6]],p.get_handle())
|
||||
event = self.db.find_event_from_handle(val[3])
|
||||
self.clist.add([val[0],val[1],event.get_date(),val[5],val[6]],p.get_handle())
|
||||
|
||||
self.clist.connect_model()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user