From 598441547115729623a51431306e0a2319758937 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 11 Jul 2007 04:56:11 +0000 Subject: [PATCH] 2007-07-10 Alex Roitman * src/GrampsDb/_GrampsDbWriteXML.py (write_date): Write datespan. * src/GrampsDbUtils/_ReadXML.py: (start_compound_date): Add new method; (start_datespan): Add new method. * data/grampsxml.dtd: Add datespan. * data/grampsxml.rng: Add datespan. svn: r8712 --- ChangeLog | 7 +++++++ data/grampsxml.dtd | 20 ++++++++++++++------ data/grampsxml.rng | 9 +++++++++ src/GrampsDb/_GrampsDbWriteXML.py | 9 +++++++-- src/GrampsDbUtils/_ReadXML.py | 9 ++++++++- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c701f224..6b1b0cb98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-07-10 Alex Roitman + * src/GrampsDb/_GrampsDbWriteXML.py (write_date): Write datespan. + * src/GrampsDbUtils/_ReadXML.py: (start_compound_date): Add new + method; (start_datespan): Add new method. + * data/grampsxml.dtd: Add datespan. + * data/grampsxml.rng: Add datespan. + 2007-07-08 Alex Roitman * configure.in: Add check for python-cairo>=1.2.6. diff --git a/data/grampsxml.dtd b/data/grampsxml.dtd index e6cbdffa4..c3d1bf5b3 100644 --- a/data/grampsxml.dtd +++ b/data/grampsxml.dtd @@ -111,7 +111,7 @@ GENDER has values of M, F, or U. + (daterange|datespan|dateval|datestr)?,noteref*,sourceref*)> - + @@ -201,7 +201,7 @@ EVENT --> - - + + + + + + + + + estimated + calculated + + + diff --git a/src/GrampsDb/_GrampsDbWriteXML.py b/src/GrampsDb/_GrampsDbWriteXML.py index 008bcb18e..8abbdc420 100644 --- a/src/GrampsDb/_GrampsDbWriteXML.py +++ b/src/GrampsDb/_GrampsDbWriteXML.py @@ -793,11 +793,16 @@ class GrampsDbXmlWriter(object): mode = date.get_modifier() if date.is_compound(): + if mode == RelLib.Date.MOD_RANGE: + tagname = 'daterange' + else: + tagname = 'datespan' + d1 = self.get_iso_date(date.get_start_date()) d2 = self.get_iso_date(date.get_stop_date()) if d1 != "" or d2 != "": - self.g.write('%s\n' - % (sp,d1,d2,qual_str,calstr)) + self.g.write('%s<%s start="%s" stop="%s"%s%s/>\n' + % (sp,tagname,d1,d2,qual_str,calstr)) elif mode != RelLib.Date.MOD_TEXTONLY: date_str = self.get_iso_date(date.get_start_date()) if date_str == "": diff --git a/src/GrampsDbUtils/_ReadXML.py b/src/GrampsDbUtils/_ReadXML.py index 714bd8ec4..23afc0a0a 100644 --- a/src/GrampsDbUtils/_ReadXML.py +++ b/src/GrampsDbUtils/_ReadXML.py @@ -412,6 +412,7 @@ class GrampsParser(UpdateCallback): "place" : (self.start_place, self.stop_place), "dateval" : (self.start_dateval, None), "daterange" : (self.start_daterange, None), + "datespan" : (self.start_datespan, None), "datestr" : (self.start_datestr, None), "places" : (None, self.stop_places), "placeobj" : (self.start_placeobj,self.stop_placeobj), @@ -1421,6 +1422,12 @@ class GrampsParser(UpdateCallback): self.placeobj.add_media_reference(self.pref) def start_daterange(self,attrs): + self.start_compound_date(attrs,RelLib.Date.MOD_RANGE) + + def start_datespan(self,attrs): + self.start_compound_date(attrs,RelLib.Date.MOD_SPAN) + + def start_compound_date(self,attrs,mode): if self.source_ref: dv = self.source_ref.get_date_object() elif self.ord: @@ -1483,7 +1490,7 @@ class GrampsParser(UpdateCallback): else: qual = RelLib.Date.QUAL_NONE - dv.set(qual,RelLib.Date.MOD_RANGE,cal,(d,m,y,False,rd,rm,ry,False)) + dv.set(qual,mode,cal,(d,m,y,False,rd,rm,ry,False)) def start_dateval(self,attrs): if self.source_ref: