Fixed level problem with GEDCOM import, fixed ZODB detection

svn: r1011
This commit is contained in:
Don Allingham 2002-05-28 13:58:03 +00:00
parent 601d5a1762
commit d4135cf745
2 changed files with 11 additions and 12 deletions

View File

@ -77,10 +77,9 @@ import ReadXML
from GrampsXML import GrampsXML from GrampsXML import GrampsXML
try: try:
from GrampsZODB import GrampsZODB from GrampsZODB import GrampsZODB
USE_ZODB = 1 zodb_ok = 1
except: except:
USE_ZODB = 0 zodb_ok = 0
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -1799,7 +1798,7 @@ class Gramps:
def load_database(self,name): def load_database(self,name):
filename = "%s/%s" % (name,const.xmlFile) filename = "%s/%s" % (name,const.xmlFile)
if not os.path.isfile(filename): if not os.path.isfile(filename) and zodb_ok:
filename = "%s/%s" % (name,const.zodbFile) filename = "%s/%s" % (name,const.zodbFile)
self.clear_database(1) self.clear_database(1)
else: else:

View File

@ -459,7 +459,7 @@ class GedcomParser:
self.backup() self.backup()
return return
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
event.addSourceRef(self.handle_source(matches)) event.addSourceRef(self.handle_source(matches,level))
else: else:
self.barf(1) self.barf(1)
@ -742,7 +742,7 @@ class GedcomParser:
else: else:
self.person.addEvent(event) self.person.addEvent(event)
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
source_ref = self.handle_source(matches) source_ref = self.handle_source(matches,2)
self.person.getPrimaryName().addSourceRef(source_ref) self.person.getPrimaryName().addSourceRef(source_ref)
elif matches[1] == "REFN": elif matches[1] == "REFN":
if intRE.match(matches[2]): if intRE.match(matches[2]):
@ -1026,7 +1026,7 @@ class GedcomParser:
except NameError: except NameError:
print 'please fix the val NameError' print 'please fix the val NameError'
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
ord.addSourceRef(self.handle_source(matches)) ord.addSourceRef(self.handle_source(matches,level))
elif matches[1] == "NOTE": elif matches[1] == "NOTE":
if matches[2] and matches[2][0] != "@": if matches[2] and matches[2][0] != "@":
note = matches[2] + self.parse_continue_data(level+1) note = matches[2] + self.parse_continue_data(level+1)
@ -1072,7 +1072,7 @@ class GedcomParser:
elif matches[1] in ["TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]: elif matches[1] in ["TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]:
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
event.addSourceRef(self.handle_source(matches)) event.addSourceRef(self.handle_source(matches,level))
elif matches[1] == "PLAC": elif matches[1] == "PLAC":
val = matches[2] val = matches[2]
n = string.strip(event.getName()) n = string.strip(event.getName())
@ -1126,7 +1126,7 @@ class GedcomParser:
elif matches[1] in ["TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]: elif matches[1] in ["TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]:
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
event.addSourceRef(self.handle_source(matches)) event.addSourceRef(self.handle_source(matches,level))
elif matches[1] == "FAMC": elif matches[1] == "FAMC":
family = self.db.findFamily(matches[2],self.fmap) family = self.db.findFamily(matches[2],self.fmap)
mrel,frel = self.parse_adopt_famc(level+1); mrel,frel = self.parse_adopt_famc(level+1);
@ -1206,7 +1206,7 @@ class GedcomParser:
elif matches[1] in ["CAUS", "DATE","TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]: elif matches[1] in ["CAUS", "DATE","TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]:
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
attr.addSourceRef(self.handle_source(matches)) attr.addSourceRef(self.handle_source(matches,level))
elif matches[1] == "PLAC": elif matches[1] == "PLAC":
val = matches[2] val = matches[2]
if attr.getValue() == "": if attr.getValue() == "":
@ -1253,7 +1253,7 @@ class GedcomParser:
elif matches[1] in ["TIME","AGE","AGNC","ADDR","STAT","TEMP","HUSB","WIFE","OBJE","_CHUR"]: elif matches[1] in ["TIME","AGE","AGNC","ADDR","STAT","TEMP","HUSB","WIFE","OBJE","_CHUR"]:
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
elif matches[1] == "SOUR": elif matches[1] == "SOUR":
event.addSourceRef(self.handle_source(matches)) event.addSourceRef(self.handle_source(matches,level))
elif matches[1] == "PLAC": elif matches[1] == "PLAC":
val = matches[2] val = matches[2]
if self.placemap.has_key(val): if self.placemap.has_key(val):
@ -1634,7 +1634,7 @@ class GedcomParser:
return dateobj return dateobj
def handle_source(self,matches): def handle_source(self,matches,level):
source_ref = SourceRef() source_ref = SourceRef()
if matches[2] and matches[2][0] != "@": if matches[2] and matches[2][0] != "@":
self.localref = self.localref + 1 self.localref = self.localref + 1