REFN changes for GEDCOM import

svn: r802
This commit is contained in:
Don Allingham 2002-02-27 01:18:49 +00:00
parent e466d17c79
commit 42cfd52db4
5 changed files with 55 additions and 9 deletions

View File

@ -34,6 +34,7 @@ intl22.so: intl.c
install:
${INSTALL} -d ${datadir}
(cd ${datadir} ;rm -f *.py *.pyo *.pyc *.glade *.xpm *.so)
${INSTALL} *.py *.jpg *.pyo *.png *.glade *.xpm *.so ${datadir}
${INSTALL} -d ${prefix}/share/pixmaps
${INSTALL} gramps.png ${prefix}/share/pixmaps

View File

@ -1701,8 +1701,8 @@ class GrampsDB:
for p in self.personMap.values():
p.MainFamily = None
p.AltFamilyList = None
p.FamilyList = None
p.AltFamilyList = []
p.FamilyList = []
self.personMap = {}
self.sourceMap = {}

View File

@ -229,8 +229,6 @@ class OpenOfficeDoc(TextDoc):
image = ImgManip.ImgManip(name)
(x,y) = image.size()
aspect_ratio = float(x)/float(y)
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
if ratio < 1:

View File

@ -520,7 +520,7 @@ class Gramps:
if val == 1:
return
self.clear_database()
DbPrompter.DbPrompter(self.database,1)
DbPrompter.DbPrompter(self,1)
def clear_database(self):
"""Clear out the database if permission was granted"""
@ -1146,6 +1146,14 @@ class Gramps:
file = self.database.getSavePath()
self.database.new()
self.active_person = None
self.active_father = None
self.active_family = None
self.active_mother = None
self.active_child = None
self.active_spouse = None
self.id2col = {}
self.alt2col = {}
self.read_file(file)
Utils.clearModified()
Utils.clear_timer()

View File

@ -67,6 +67,7 @@ for val in const.familyConstantEvents.keys():
if key != "":
ged2fam[key] = val
intRE = re.compile(r"\s*(\d+)\s*$")
lineRE = re.compile(r"\s*(\d+)\s+(\S+)\s*(.*)$")
headRE = re.compile(r"\s*(\d+)\s+HEAD")
nameRegexp= re.compile(r"/?([^/]*)(/([^/]*)(/([^/]*))?)?")
@ -108,6 +109,7 @@ def importData(database, filename):
return
g.parse_gedcom_file()
g.resolve_refns()
statusTop.get_widget("close").set_sensitive(1)
@ -142,6 +144,8 @@ class GedcomParser:
self.fmap = {}
self.smap = {}
self.nmap = {}
self.refn = {}
self.added = []
self.gedmap = GedcomInfoDB()
self.gedsource = None
self.dir_path = os.path.dirname(file)
@ -367,6 +371,7 @@ class GedcomParser:
self.update(self.people_obj,str(self.indi_count))
self.indi_count = self.indi_count + 1
self.person = self.db.findPerson(matches[1],self.pmap)
self.added.append(self.person)
self.parse_individual()
elif matches[2] in ["SUBM","SUBN"]:
self.ignore_sub_junk(1)
@ -701,10 +706,8 @@ class GedcomParser:
self.parse_source_reference(source_ref,2)
self.person.getPrimaryName().addSourceRef(source_ref)
elif matches[1] == "REFN":
attr = Attribute()
attr.setType("Reference Number")
attr.setValue(matches[2])
self.person.addAttribute(attr)
if intRE.match(matches[2]):
self.refn[self.person] = int(matches[2])
elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
self.ignore_sub_junk(2)
elif matches[1] in ["ANCI","DESI","RIN","RFN"]:
@ -1635,6 +1638,42 @@ class GedcomParser:
return dateobj
def resolve_refns(self):
prefix = self.db.iprefix
pmap = self.db.getPersonMap()
renamed = []
new_pmax = self.db.pmapIndex
for person in self.added:
if self.refn.has_key(person):
val = self.refn[person]
new_key = prefix % val
new_pmax = max(new_pmax,val)
# new ID is not used
if not pmap.has_key(new_key):
del pmap[person.getId()]
pmap[new_key] = person
person.setId(new_key)
else:
tp = pmap[new_key]
# same person, just change it
if person == tp:
del pmap[person.getId()]
pmap[new_key] = person
person.setId(new_key)
# person currently using it was just added, change it
elif tp in self.added:
if not self.refn.has_key(tp):
renamed.append(tp)
del pmap[person.getId()]
pmap[new_key] = person
person.setId(new_key)
self.db.pmapIndex = new_pmax
for person in renamed:
del pmap[person]
self.db.addPerson(person)
#-------------------------------------------------------------------------
#
#