9945: Write PlaceID links in CSV export
When places are included in the export use PlaceID links, otherwise generate a formatted place for the event.
This commit is contained in:
parent
f3e11efeaf
commit
9ca01a3211
@ -401,9 +401,7 @@ class CSVWriter:
|
||||
birth = self.db.get_event_from_handle(birth_ref.ref)
|
||||
if birth:
|
||||
birthdate = self.format_date( birth)
|
||||
place_handle = birth.get_place_handle()
|
||||
if place_handle:
|
||||
birthplace = _pd.display_event(self.db, birth)
|
||||
birthplace = self.format_place(birth)
|
||||
birthsource = get_primary_source_title(self.db, birth)
|
||||
# Baptism:
|
||||
baptismdate = ""
|
||||
@ -415,9 +413,7 @@ class CSVWriter:
|
||||
baptism = self.db.get_event_from_handle(baptism_ref.ref)
|
||||
if baptism:
|
||||
baptismdate = self.format_date( baptism)
|
||||
place_handle = baptism.get_place_handle()
|
||||
if place_handle:
|
||||
baptismplace = _pd.display_event(self.db, baptism)
|
||||
baptismplace = self.format_place(baptism)
|
||||
baptismsource = get_primary_source_title(self.db, baptism)
|
||||
# Death:
|
||||
deathdate = ""
|
||||
@ -428,9 +424,7 @@ class CSVWriter:
|
||||
death = self.db.get_event_from_handle(death_ref.ref)
|
||||
if death:
|
||||
deathdate = self.format_date( death)
|
||||
place_handle = death.get_place_handle()
|
||||
if place_handle:
|
||||
deathplace = _pd.display_event(self.db, death)
|
||||
deathplace = self.format_place(death)
|
||||
deathsource = get_primary_source_title(self.db, death)
|
||||
# Burial:
|
||||
burialdate = ""
|
||||
@ -442,9 +436,7 @@ class CSVWriter:
|
||||
burial = self.db.get_event_from_handle(burial_ref.ref)
|
||||
if burial:
|
||||
burialdate = self.format_date( burial)
|
||||
place_handle = burial.get_place_handle()
|
||||
if place_handle:
|
||||
burialplace = _pd.display_event(self.db, burial)
|
||||
burialplace = self.format_place(burial)
|
||||
burialsource = get_primary_source_title(self.db, burial)
|
||||
# Write it out:
|
||||
self.write_csv(grampsid_ref, surname, first_name, callname,
|
||||
@ -502,10 +494,8 @@ class CSVWriter:
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
if event.get_type() == EventType.MARRIAGE:
|
||||
mdate = self.format_date( event)
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
mplace = _pd.display_event(self.db, event)
|
||||
source = get_primary_source_title(self.db, event)
|
||||
mplace = self.format_place(event)
|
||||
source = get_primary_source_title(self.db, event)
|
||||
note = ''
|
||||
self.write_csv(marriage_id, father_id, mother_id, mdate,
|
||||
mplace, source, note)
|
||||
@ -537,3 +527,18 @@ class CSVWriter:
|
||||
|
||||
def format_date(self, date):
|
||||
return get_date(date)
|
||||
|
||||
def format_place(self, event):
|
||||
"""
|
||||
If places are included in the export return a link, else return a
|
||||
formatted place for the given event.
|
||||
"""
|
||||
if self.include_places:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.db.get_place_from_handle(place_handle)
|
||||
if place:
|
||||
return "[%s]" % place.get_gramps_id()
|
||||
return ""
|
||||
else:
|
||||
return _pd.display_event(self.db, event)
|
||||
|
Loading…
Reference in New Issue
Block a user