Moved to a single date for addresses instead of start/stop dates

svn: r54
This commit is contained in:
Don Allingham 2001-05-23 22:18:12 +00:00
parent a073ffba61
commit 4bb330f1e1
3 changed files with 35 additions and 26 deletions

View File

@ -82,6 +82,7 @@ class GrampsParser(handler.ContentHandler):
self.source = None self.source = None
self.sourceRef = None self.sourceRef = None
self.is_import = is_import self.is_import = is_import
self.in_address = 0
self.resname = "" self.resname = ""
self.resaddr = "" self.resaddr = ""
@ -157,6 +158,7 @@ class GrampsParser(handler.ContentHandler):
# #
#--------------------------------------------------------------------- #---------------------------------------------------------------------
def start_address(self,attrs): def start_address(self,attrs):
self.in_address = 1
self.address = Address() self.address = Address()
self.person.addAddress(self.address) self.person.addAddress(self.address)
@ -395,6 +397,14 @@ class GrampsParser(handler.ContentHandler):
def stop_attribute(self,tag): def stop_attribute(self,tag):
self.attribute.setValue(tag) self.attribute.setValue(tag)
#---------------------------------------------------------------------
#
#
#
#---------------------------------------------------------------------
def stop_address(self,tag):
self.in_address = 0
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# #
# #
@ -447,6 +457,9 @@ class GrampsParser(handler.ContentHandler):
#--------------------------------------------------------------------- #---------------------------------------------------------------------
def stop_date(self,tag): def stop_date(self,tag):
if tag: if tag:
if self.in_address:
self.address.setDate(tag)
else:
self.event.getDateObj().quick_set(tag) self.event.getDateObj().quick_set(tag)
#--------------------------------------------------------------------- #---------------------------------------------------------------------
@ -502,14 +515,6 @@ class GrampsParser(handler.ContentHandler):
date.quick_set(tag) date.quick_set(tag)
self.source.setDate(date) self.source.setDate(date)
def stop_date_start(self,tag):
date = self.address.getStartDateObj()
date.quick_set(tag)
def stop_date_stop(self,tag):
date = self.address.getStopDateObj()
date.quick_set(tag)
def stop_street(self,tag): def stop_street(self,tag):
self.address.setStreet(tag) self.address.setStreet(tag)
@ -705,7 +710,7 @@ class GrampsParser(handler.ContentHandler):
self.person.addAlternateName(self.name) self.person.addAlternateName(self.name)
func_map = { func_map = {
"address" : (start_address, None), "address" : (start_address, stop_address),
"aka" : (start_name, stop_aka), "aka" : (start_name, stop_aka),
"attribute" : (start_attribute, stop_attribute), "attribute" : (start_attribute, stop_attribute),
"bookmark" : (start_bmark, None), "bookmark" : (start_bmark, None),
@ -756,11 +761,9 @@ class GrampsParser(handler.ContentHandler):
"sources" : (start_sources, None), "sources" : (start_sources, None),
"spage" : (None, stop_spage), "spage" : (None, stop_spage),
"spubinfo" : (None, stop_spubinfo), "spubinfo" : (None, stop_spubinfo),
"date_start" : (None, stop_date_start),
"state" : (None, stop_state), "state" : (None, stop_state),
"stext" : (None, stop_stext), "stext" : (None, stop_stext),
"stitle" : (None, stop_stitle), "stitle" : (None, stop_stitle),
"date_stop" : (None, stop_date_stop),
"street" : (None, stop_street), "street" : (None, stop_street),
"suffix" : (None, stop_suffix), "suffix" : (None, stop_suffix),
"title" : (None, stop_title), "title" : (None, stop_title),

View File

@ -114,12 +114,18 @@ def loadData(database, filename, callback):
parser.parse(xml_file) parser.parse(xml_file)
except xml.sax.SAXParseException: except xml.sax.SAXParseException:
GnomeErrorDialog(_("%s is a corrupt file") % filename) GnomeErrorDialog(_("%s is a corrupt file") % filename)
import traceback
traceback.print_exc()
return 0 return 0
except IOError,msg: except IOError,msg:
GnomeErrorDialog(_("Error reading %s") % filename + "\n" + str(msg)) GnomeErrorDialog(_("Error reading %s") % filename + "\n" + str(msg))
import traceback
traceback.print_exc()
return 0 return 0
except: except:
GnomeErrorDialog(_("Error reading %s") % filename) GnomeErrorDialog(_("Error reading %s") % filename)
import traceback
traceback.print_exc()
return 0 return 0

View File

@ -101,11 +101,18 @@ def dump_my_event(g,name,event):
if source: if source:
sourceRef = source.getBase() sourceRef = source.getBase()
if sourceRef: if sourceRef:
p = source.getPage()
c = source.getComments()
t = source.getText()
d = source.getDate().getSaveDate()
if p == "" and c == "" and t == "" and d == "":
g.write("<sourceref ref=\"%d\"/>\n" % sourceRef.getId())
else:
g.write("<sourceref ref=\"%d\">\n" % sourceRef.getId()) g.write("<sourceref ref=\"%d\">\n" % sourceRef.getId())
write_line(g,"spage",source.getPage()) write_line(g,"spage",p)
writeNote(g,"scomments",source.getComments()) writeNote(g,"scomments",c)
writeNote(g,"stext",source.getText()) writeNote(g,"stext",t)
write_line(g,"sdate",source.getDate().getSaveDate()) write_line(g,"sdate",c)
g.write("</sourceref>\n") g.write("</sourceref>\n")
g.write("</event>\n") g.write("</event>\n")
@ -197,10 +204,8 @@ def exportData(database, filename, callback):
g.write("<people") g.write("<people")
person = database.getDefaultPerson() person = database.getDefaultPerson()
print person
if person: if person:
g.write(" default=\"" + str(person.getId()) + "\"") g.write(" default=\"" + str(person.getId()) + "\"")
print str(person.getId())
g.write(">\n") g.write(">\n")
total = len(personList) + len(familyList) total = len(personList) + len(familyList)
@ -239,12 +244,7 @@ def exportData(database, filename, callback):
g.write("<addresses>\n") g.write("<addresses>\n")
for address in person.getAddressList(): for address in person.getAddressList():
g.write('<address>\n') g.write('<address>\n')
g.write('<date_start>') write_line(g,"date",address.getDateObj().getSaveDate())
g.write(address.getStartDateObj().getSaveDate())
g.write('<date_start>\n')
g.write('<date_stop>')
g.write(address.getStopDateObj().getSaveDate())
g.write('<date_stop>\n')
write_line(g,"street",address.getStreet()) write_line(g,"street",address.getStreet())
write_line(g,"city",address.getCity()) write_line(g,"city",address.getCity())
write_line(g,"state",address.getState()) write_line(g,"state",address.getState())