Cleanup in location saving. Don't write locations if they are empty

svn: r408
This commit is contained in:
Don Allingham 2001-09-16 13:12:12 +00:00
parent 45081a072c
commit d6d24d4169
4 changed files with 756 additions and 725 deletions

View File

@ -213,6 +213,27 @@ def dump_name(g,label,name,index=1):
g.write('%s</%s>\n' % (sp,label))
def dump_location(g,loc):
"Writes the location information to the output file"
city = fix(loc.get_city())
state = fix(loc.get_state())
country = fix(loc.get_country())
county = fix(loc.get_county())
if not city and not state and not county and not country:
return
g.write(' <location')
if city:
g.write(' city="%s"' % city)
if county:
g.write(' county="%s"' % county)
if state:
g.write(' state="%s"' % state)
if country:
g.write(' country="%s"' % country)
g.write('/>\n')
#-------------------------------------------------------------------------
#
#
@ -449,24 +470,9 @@ def exportData(database, filename, callback):
if place.get_longitude() != "" or place.get_latitude() != "":
g.write(' <coord long="%s" lat=%s"/>\n' % \
(fix(place.get_longitude()),fix(place.get_latitude())))
loc = place.get_main_location()
city = fix(loc.get_city())
state = fix(loc.get_state())
country = fix(loc.get_country())
county = fix(loc.get_county())
if city or state or country or county:
g.write(' <location city="%s"' % city)
g.write(' county="%s" state="%s"' % (county,state))
g.write(' country="%s"/>\n' % country)
dump_location(g,place.get_main_location())
for loc in place.get_alternate_locations():
city = fix(loc.get_city())
state = fix(loc.get_state())
country = fix(loc.get_country())
county = fix(loc.get_county())
if city or state or country or county:
g.write(' <location')
g.write(' city="%s" county="%s"' % (city,county))
g.write(' state="%s" country="%s"/>\n' % (state,country))
dump_location(g,loc)
for photo in place.getPhotoList():
path = photo.getPath()
l = len(fileroot)

View File

@ -137,14 +137,19 @@ class AncestorReport:
for child in family.getChildList():
self.doc.start_paragraph("ChildList")
t= child.getPrimaryName().getRegularName()
#print "getBirth()", child.getBirth().__dict__
if child.getBirth().getDate() != "" and \
child.getBirth().getPlaceName() != "":
t= t+ " Born: "+child.getBirth().getDate() + \
child.getBirth().getPlaceName() != "":
#print child.getBirth().getPlace().__dict__
t= t+ " Born: "+child.getBirth().getDate() + \
" "+child.getBirth().getPlaceName()
if child.getDeath().getPlaceName() != "":
if child.getDeath().getDate() != "" or child.getDeath().getPlaceName() != "":
t= t+ " Died: "+child.getDeath().getDate() + \
" "+child.getDeath().getPlaceName()
#print "getDeath()", child.getDeath().__dict__
if child.getDeath().getPlace() != None:
#print child.getDeath().getPlace().__dict__
if child.getDeath().getDate() != "" or \
child.getDeath().getPlaceName() != "":
t= t+ " Died: "+child.getDeath().getDate() + \
" "+child.getDeath().getPlaceName()
self.doc.write_text(_(t))
self.doc.end_paragraph()
@ -168,11 +173,13 @@ class AncestorReport:
self.doc.end_bold()
# Check birth record
print person.getPrimaryName().getRegularName()
#print person.getPrimaryName().getRegularName()
birth = person.getBirth()
if birth:
date = birth.getDateObj().get_start_date()
place = birth.getPlaceName()
if birth.getPlaceName() != "":
place = birth.getPlaceName()
else: place= ""
if place[-1:] == '.':
place = place[:-1]
t= ""
@ -182,15 +189,15 @@ class AncestorReport:
t= "on %s" % date.getDate()
else:
t= "in the year %s" % date.getYear()
elif rptOptions.dateBlank == reportOptions.Yes:
elif rptOptions.blankDate == reportOptions.Yes:
t= "on _______________"
if place != "":
t= t + " in %s" % place
elif rptOptions.placeBlank == reportOptions.Yes:
elif rptOptions.blankPlace == reportOptions.Yes:
t= t + " in _____________________"
if t != "":
self.doc.write_text(_(" was born " + t + "."))
self.doc.write_text(_(" was born " + t + "."))
else: self.doc.write_text(_("."))
t= ""
@ -212,12 +219,12 @@ class AncestorReport:
t= t + ("on %s" % date.getDate())
else:
t= t + ("in the year %s" % date.getDate())
elif rptOptions.dateBlank == reportOptions.Yes:
elif rptOptions.blankDate == reportOptions.Yes:
t= "on ______________"
if place != "":
t= t + (" in %s") % place
elif rptOptions.placeBlank == reportOptions.Yes:
elif rptOptions.blankPlace == reportOptions.Yes:
t= t + (" in _____________")
if buried:
@ -235,7 +242,7 @@ class AncestorReport:
t = t + " in %s" % place
else:
t = t + "in the year %s" % date.getDate()
elif rptOptions.dateBlank == reportOptions.Yes:
elif rptOptions.blankDate == reportOptions.Yes:
t= t + " on ___________"
if place != "":
t = t + " in %s" % place
@ -301,13 +308,14 @@ class AncestorReport:
rptOptions.fullDate == reportOptions.Yes:
t= t + " on "+date.getDate()
else: t= t + " in the year %s" % date.getYear()
elif rptOptions.dateBlank == reportOptions.Yes:
elif rptOptions.blankDate == reportOptions.Yes:
t= t + " on __________"
else: t= t + " on __________"
if marriage.getPlaceName() != "":
if marriage.getPlace() != None and \
marriage.getPlaceName() != "":
t= t + " in " + marriage.getPlaceName()
elif rptOptions.placeBlank == reportOptions.Yes:
elif rptOptions.blankPlace == reportOptions.Yes:
t= t + " in ____________"
self.doc.write_text(_(t+"."))
@ -576,9 +584,9 @@ from Plugins import register_report
register_report(
report,
_("Produces a detailed textual ancestral report"),
_("Detailed Ancestral Report"),
category=_("Generate Files"),
description= _("Detailed Ancestral Report"),
description= _("Produces a detailed ancestral report"),
xpm= get_xpm_image()
)
@ -624,11 +632,11 @@ class reportOptions:
#Include source notes
#self.noSourceNotes= reportOptions.Yes
#Replace missing with ___________
self.placeBlank= reportOptions.Yes
#Replace missing Place with ___________
self.blankPlace= reportOptions.Yes
#Replace missing dates with __________
self.dateBlank= reportOptions.Yes
self.blankDate= reportOptions.Yes
#Omit country code
#self.noCountryInfo= reportOptions.No

File diff suppressed because it is too large Load Diff