ASSO tag support

svn: r6339
This commit is contained in:
Don Allingham 2006-04-13 20:24:19 +00:00
parent d03c217524
commit efd56461dd
4 changed files with 49 additions and 24 deletions

View File

@ -1,4 +1,7 @@
2006-04-13 Don Allingham <don@gramps-project.org> 2006-04-13 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_ReadGedcom.py: handle ASSO tag
* src/GrampsDb/_GedTokens.py: handle ASSO tag
* example/gedcom/sample.ged: add ASSO tag
* src/GrampsDb/_WriteXML.py: write old style XML. * src/GrampsDb/_WriteXML.py: write old style XML.
* src/Editors/_EditPersonRef.py: display person correctly in label * src/Editors/_EditPersonRef.py: display person correctly in label
* src/Editors/_EditFamily.py: comment out unused tab * src/Editors/_EditFamily.py: comment out unused tab

View File

@ -58,6 +58,10 @@
1 NAME Edwin Michael /Smith/ 1 NAME Edwin Michael /Smith/
2 NOTE This is a note attached to a name 2 NOTE This is a note attached to a name
2 SOUR @S1600@ 2 SOUR @S1600@
1 ASSO @I07@
2 RELA SomeRelationship
2 NOTE This is a note for the ASSOC import
2 SOUR @S1600@
1 SEX M 1 SEX M
1 TITL Grand Poobah 1 TITL Grand Poobah
1 OBJE 1 OBJE
@ -516,6 +520,7 @@
2 DATE 26 JUN 34 B.C. 2 DATE 26 JUN 34 B.C.
2 PLAC Hayward, Alameda Co., CA 2 PLAC Hayward, Alameda Co., CA
0 @F01@ FAM 0 @F01@ FAM
1 HUSB @IC3a2b1@
1 WIFE @I40@ 1 WIFE @I40@
1 CHIL @I42@ 1 CHIL @I42@
2 _FREL Adopted 2 _FREL Adopted

View File

@ -123,6 +123,7 @@ TOKEN__WTN = 103
TOKEN_HEAD = 105 TOKEN_HEAD = 105
TOKEN_CALN = 106 TOKEN_CALN = 106
TOKEN_MEDI = 107 TOKEN_MEDI = 107
TOKEN_RELA = 108
tokens = { tokens = {
"HEAD" : TOKEN_HEAD, "MEDI" : TOKEN_MEDI, "HEAD" : TOKEN_HEAD, "MEDI" : TOKEN_MEDI,
@ -208,5 +209,5 @@ tokens = {
"_UID" : TOKEN__UID, "VERS" : TOKEN_VERS, "_UID" : TOKEN__UID, "VERS" : TOKEN_VERS,
"VERSION" : TOKEN_VERS, "WIFE" : TOKEN_WIFE, "VERSION" : TOKEN_VERS, "WIFE" : TOKEN_WIFE,
"_WITN" : TOKEN__WITN, "_WTN" : TOKEN__WTN, "_WITN" : TOKEN__WITN, "_WTN" : TOKEN__WTN,
"_CHUR" : TOKEN_IGNORE, "_CHUR" : TOKEN_IGNORE,"RELA" : TOKEN_RELA,
} }

View File

@ -541,7 +541,7 @@ class GedcomParser:
TOKEN_RFN : self.func_person_attr, TOKEN_RFN : self.func_person_attr,
TOKEN__UID : self.func_person_attr, TOKEN__UID : self.func_person_attr,
TOKEN_CHAN : self.skip_record, TOKEN_CHAN : self.skip_record,
TOKEN_ASSO : self.skip_record, TOKEN_ASSO : self.func_person_asso,
TOKEN_ANCI : self.skip_record, TOKEN_ANCI : self.skip_record,
TOKEN_DESI : self.skip_record, TOKEN_DESI : self.skip_record,
TOKEN_RIN : self.skip_record, TOKEN_RIN : self.skip_record,
@ -808,7 +808,8 @@ class GedcomParser:
if mother: if mother:
mother.add_address(self.addr) mother.add_address(self.addr)
self.db.commit_person(mother, self.trans) self.db.commit_person(mother, self.trans)
for child_handle in self.family.get_child_handle_list(): for child_ref in self.family.get_child_ref_list():
child_handle = child_ref.ref
child = self.db.get_person_from_handle(child_handle) child = self.db.get_person_from_handle(child_handle)
if child: if child:
child.add_address(self.addr) child.add_address(self.addr)
@ -1105,26 +1106,12 @@ class GedcomParser:
mrel,frel = self.parse_ftw_relations(2) mrel,frel = self.parse_ftw_relations(2)
gid = matches[2] gid = matches[2]
child = self.find_or_create_person(self.map_gid(gid[1:-1])) child = self.find_or_create_person(self.map_gid(gid[1:-1]))
self.family.add_child_handle(child.handle)
change = False ref = RelLib.ChildRef()
ref.ref = child.handle
for f in child.get_parent_family_handle_list(): ref.set_father_relation(frel)
if f[0] == self.family.handle: ref.set_mother_relation(mrel)
if (mrel != f[1] or frel != f[2]): self.family.add_child_ref(ref)
change = True
child.change_parent_family_handle(self.family.handle,
mrel, frel)
break
else:
change = True
if mrel in rel_types and frel in rel_types:
child.set_main_parent_family_handle(self.family.handle)
else:
if child.get_main_parents_family_handle() == self.family.handle:
child.set_main_parent_family_handle(None)
if change:
self.db.commit_person(child, self.trans)
elif matches[1] == TOKEN_NCHI: elif matches[1] == TOKEN_NCHI:
a = RelLib.Attribute() a = RelLib.Attribute()
a.set_type((RelLib.Attribute.NUM_CHILD,'')) a.set_type((RelLib.Attribute.NUM_CHILD,''))
@ -1540,7 +1527,9 @@ class GedcomParser:
mrel,frel = self.parse_adopt_famc(level+1); mrel,frel = self.parse_adopt_famc(level+1);
if self.person.get_main_parents_family_handle() == handle: if self.person.get_main_parents_family_handle() == handle:
self.person.set_main_parent_family_handle(None) self.person.set_main_parent_family_handle(None)
self.person.add_parent_family_handle(handle,mrel,frel) self.person.add_parent_family_handle(handle)
if mrel[0] != RelLib.ChildRef.BIRTH or frel[0] != RelLib.ChildRef.BIRTH:
print "NOT FIXED YET"
elif matches[1] == TOKEN_PLAC: elif matches[1] == TOKEN_PLAC:
val = matches[2] val = matches[2]
place = self.find_or_create_place(val) place = self.find_or_create_place(val)
@ -2038,6 +2027,32 @@ class GedcomParser:
state.name_cnt += 1 state.name_cnt += 1
self.parse_name(name,2,state) self.parse_name(name,2,state)
def func_person_asso(self, matches, state):
print matches
gid = matches[2]
handle = self.find_person_handle(self.map_gid(gid[1:-1]))
ref = RelLib.PersonRef()
print handle
ref.ref = handle
self.person.add_person_ref(ref)
while True:
matches = self.get_next()
if int(matches[0]) < 2:
self.backup()
return
elif matches[1] == TOKEN_RELA:
ref.rel = matches[2]
elif matches[1] == TOKEN_SOUR:
ref.add_source_reference(self.handle_source(matches,2))
elif matches[1] == TOKEN_NOTE:
note = self.parse_note(matches,ref,2,"")
ref.set_note(note)
else:
self.barf(2)
def func_person_alt_name(self,matches,state): def func_person_alt_name(self,matches,state):
aka = RelLib.Name() aka = RelLib.Name()
try: try:
@ -2107,7 +2122,8 @@ class GedcomParser:
else: else:
if state.person.get_main_parents_family_handle() == handle: if state.person.get_main_parents_family_handle() == handle:
state.person.set_main_parent_family_handle(None) state.person.set_main_parent_family_handle(None)
state.person.add_parent_family_handle(handle,ftype,ftype) state.person.add_parent_family_handle(handle)
print "NEED TO CHANGE CHILDREF TO",ftype,ftype
def func_person_resi(self,matches,state): def func_person_resi(self,matches,state):
addr = RelLib.Address() addr = RelLib.Address()