From 9a0a08bfd29ea5ba807ed12d3a3db3e8a5f852c4 Mon Sep 17 00:00:00 2001 From: James G Sack Date: Fri, 7 Mar 2008 07:28:15 +0000 Subject: [PATCH] #1849: omit Y if person/family event has subordinate data svn: r10204 --- ChangeLog | 4 ++++ src/GrampsDbUtils/_WriteGedcom.py | 29 +++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 061e334a0..e5ef62c34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008.03.06 Jim Sack + src/GrampsDbUtils/_WriteGedcom.py: #1849 gedcom output: omit 'Y' + when there is subpordinate data in event (person or family) + 2008.03.06 Jim Sack src/test/gedread_util.py: update test utility per r10169 changes that removed the "TRANSACTIONS" option. diff --git a/src/GrampsDbUtils/_WriteGedcom.py b/src/GrampsDbUtils/_WriteGedcom.py index 5ed35019d..2e7fbec57 100644 --- a/src/GrampsDbUtils/_WriteGedcom.py +++ b/src/GrampsDbUtils/_WriteGedcom.py @@ -263,6 +263,26 @@ def breakup(txt, limit): data.append(txt) return data + +#------------------------------------------------------------------------- +# +# event_has_subordinate_data +# may want to compare description w/ auto-generated one, and +# if so, treat it same as if it were empty for this purpose +# +#------------------------------------------------------------------------- +def event_has_subordinate_data(event, event_ref): + gotany = event.get_description().strip() or\ + not event.get_date_object().is_empty() or\ + event.get_place_handle() or\ + event.get_attribute_list() or\ + event_ref.get_attribute_list() or\ + event.get_note_list() or\ + event.get_source_references() or\ + event.get_media_list() + return gotany + + #------------------------------------------------------------------------- # # GedcomWriter class @@ -641,8 +661,7 @@ class GedcomWriter(BasicUtils.UpdateCallback): else: self.__writeln(1, val) else: - if (not event.get_date_object().is_empty()) \ - or event.get_place_handle(): + if event_has_subordinate_data(event, event_ref): self.__writeln(1, val) else: self.__writeln(1, val, 'Y') @@ -910,8 +929,7 @@ class GedcomWriter(BasicUtils.UpdateCallback): val = GedcomInfo.familyConstantEvents.get(etype) if val: - if (not event.get_date_object().is_empty() - or event.get_place_handle()): + if event_has_subordinate_data(event, event_ref): self.__writeln(1, val) else: self.__writeln(1, val, 'Y') @@ -1106,8 +1124,7 @@ class GedcomWriter(BasicUtils.UpdateCallback): """ if event_ref: event = self.dbase.get_event_from_handle(event_ref.ref) - if (not event.get_date_object().is_empty()) \ - or event.get_place_handle(): + if event_has_subordinate_data(event, event_ref): self.__writeln(1, key) else: self.__writeln(1, key, 'Y')