* src/WriteXML.py (write_xml_data): Use ISO date in the created
attribute; (get_iso_date): Return empty string on empty date; (write_date): Write quality attributes, if any. * src/ReadXML.py (start_daterange,start_dateval): Parse quality attributes. svn: r5315
This commit is contained in:
parent
1edd0bf53d
commit
29022a6f1e
@ -2,6 +2,11 @@
|
|||||||
* example/gramps/data.gramps: Update example data to conform with
|
* example/gramps/data.gramps: Update example data to conform with
|
||||||
the format changes and the DTD.
|
the format changes and the DTD.
|
||||||
* doc/grampsxml.dtd, doc/grampsxml.rng: Update.
|
* doc/grampsxml.dtd, doc/grampsxml.rng: Update.
|
||||||
|
* src/WriteXML.py (write_xml_data): Use ISO date in the created
|
||||||
|
attribute; (get_iso_date): Return empty string on empty date;
|
||||||
|
(write_date): Write quality attributes, if any.
|
||||||
|
* src/ReadXML.py (start_daterange,start_dateval): Parse quality
|
||||||
|
attributes.
|
||||||
|
|
||||||
2005-10-13 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
2005-10-13 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||||
* src/plugins/TestcaseGenerator.py: Randomize more; Add LDS events
|
* src/plugins/TestcaseGenerator.py: Randomize more; Add LDS events
|
||||||
|
@ -256,14 +256,16 @@ SHARED ELEMENTS
|
|||||||
<!ATTLIST daterange
|
<!ATTLIST daterange
|
||||||
start CDATA #REQUIRED
|
start CDATA #REQUIRED
|
||||||
stop CDATA #REQUIRED
|
stop CDATA #REQUIRED
|
||||||
|
quality (estimated|calculated) #IMPLIED
|
||||||
cformat CDATA #IMPLIED
|
cformat CDATA #IMPLIED
|
||||||
>
|
>
|
||||||
|
|
||||||
<!ELEMENT dateval EMPTY>
|
<!ELEMENT dateval EMPTY>
|
||||||
<!ATTLIST dateval
|
<!ATTLIST dateval
|
||||||
val CDATA #REQUIRED
|
val CDATA #REQUIRED
|
||||||
type (before|after|about) #IMPLIED
|
type (before|after|about) #IMPLIED
|
||||||
cformat CDATA #IMPLIED
|
quality (estimated|calculated) #IMPLIED
|
||||||
|
cformat CDATA #IMPLIED
|
||||||
>
|
>
|
||||||
|
|
||||||
<!ELEMENT datestr EMPTY>
|
<!ELEMENT datestr EMPTY>
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
<element name="header">
|
<element name="header">
|
||||||
<element name="created">
|
<element name="created">
|
||||||
<attribute name="date"><text/></attribute>
|
<attribute name="date"><data type="date"/></attribute>
|
||||||
<attribute name="version"><text/></attribute>
|
<attribute name="version"><text/></attribute>
|
||||||
</element>
|
</element>
|
||||||
<optional><element name="researcher">
|
<optional><element name="researcher">
|
||||||
@ -229,6 +229,10 @@
|
|||||||
<element name="daterange">
|
<element name="daterange">
|
||||||
<attribute name="start"><text/></attribute>
|
<attribute name="start"><text/></attribute>
|
||||||
<attribute name="stop"><text/></attribute>
|
<attribute name="stop"><text/></attribute>
|
||||||
|
<optional><attribute name="quality"><choice>
|
||||||
|
<value>estimated</value>
|
||||||
|
<value>calculated</value>
|
||||||
|
</choice></attribute></optional>
|
||||||
<optional><attribute name="cformat"><text/></attribute></optional>
|
<optional><attribute name="cformat"><text/></attribute></optional>
|
||||||
</element>
|
</element>
|
||||||
<element name="dateval">
|
<element name="dateval">
|
||||||
@ -239,6 +243,10 @@
|
|||||||
<value>after</value>
|
<value>after</value>
|
||||||
<value>about</value>
|
<value>about</value>
|
||||||
</choice></attribute></optional>
|
</choice></attribute></optional>
|
||||||
|
<optional><attribute name="quality"><choice>
|
||||||
|
<value>estimated</value>
|
||||||
|
<value>calculated</value>
|
||||||
|
</choice></attribute></optional>
|
||||||
</element>
|
</element>
|
||||||
<element name="datestr">
|
<element name="datestr">
|
||||||
<attribute name="val"><text/></attribute>
|
<attribute name="val"><text/></attribute>
|
||||||
|
@ -990,7 +990,18 @@ class GrampsParser:
|
|||||||
else:
|
else:
|
||||||
cal = Date.CAL_GREGORIAN
|
cal = Date.CAL_GREGORIAN
|
||||||
|
|
||||||
dv.set(Date.QUAL_NONE,Date.MOD_RANGE,cal,(d,m,y,False,rd,rm,ry,False))
|
if attrs.has_key('quality'):
|
||||||
|
val = attrs['quality']
|
||||||
|
if val == 'estimated':
|
||||||
|
qual = Date.QUAL_ESTIMATED
|
||||||
|
elif val == 'calculated':
|
||||||
|
qual = Date.QUAL_CALCULATED
|
||||||
|
else:
|
||||||
|
qual = Date.QUAL_NONE
|
||||||
|
else:
|
||||||
|
qual = Date.QUAL_NONE
|
||||||
|
|
||||||
|
dv.set(qual,Date.MOD_RANGE,cal,(d,m,y,False,rd,rm,ry,False))
|
||||||
|
|
||||||
def start_dateval(self,attrs):
|
def start_dateval(self,attrs):
|
||||||
if self.source_ref:
|
if self.source_ref:
|
||||||
@ -1042,8 +1053,19 @@ class GrampsParser:
|
|||||||
mod = Date.MOD_BEFORE
|
mod = Date.MOD_BEFORE
|
||||||
else:
|
else:
|
||||||
mod = Date.MOD_NONE
|
mod = Date.MOD_NONE
|
||||||
|
|
||||||
|
if attrs.has_key('quality'):
|
||||||
|
val = attrs['quality']
|
||||||
|
if val == 'estimated':
|
||||||
|
qual = Date.QUAL_ESTIMATED
|
||||||
|
elif val == 'calculated':
|
||||||
|
qual = Date.QUAL_CALCULATED
|
||||||
|
else:
|
||||||
|
qual = Date.QUAL_NONE
|
||||||
|
else:
|
||||||
|
qual = Date.QUAL_NONE
|
||||||
|
|
||||||
dv.set(Date.QUAL_NONE,mod,cal,(d,m,y,False))
|
dv.set(qual,mod,cal,(d,m,y,False))
|
||||||
|
|
||||||
def start_datestr(self,attrs):
|
def start_datestr(self,attrs):
|
||||||
if self.source_ref:
|
if self.source_ref:
|
||||||
|
@ -197,7 +197,7 @@ class XmlWriter:
|
|||||||
|
|
||||||
def write_xml_data(self):
|
def write_xml_data(self):
|
||||||
|
|
||||||
date = time.ctime(time.time()).split()
|
date = time.localtime(time.time())
|
||||||
owner = self.db.get_researcher()
|
owner = self.db.get_researcher()
|
||||||
person_len = self.db.get_number_of_people()
|
person_len = self.db.get_number_of_people()
|
||||||
family_len = len(self.db.get_family_handles())
|
family_len = len(self.db.get_family_handles())
|
||||||
@ -212,11 +212,10 @@ class XmlWriter:
|
|||||||
'PUBLIC "-//GRAMPS//DTD GRAMPS XML V%s//EN"\n'
|
'PUBLIC "-//GRAMPS//DTD GRAMPS XML V%s//EN"\n'
|
||||||
'"http://gramps-project.org/xml/%s/grampsxml.dtd">\n'
|
'"http://gramps-project.org/xml/%s/grampsxml.dtd">\n'
|
||||||
% (_xml_version,_xml_version))
|
% (_xml_version,_xml_version))
|
||||||
|
|
||||||
self.g.write("<database xmlns=\"http://gramps-project.org/\">\n")
|
self.g.write("<database xmlns=\"http://gramps-project.org/\">\n")
|
||||||
self.g.write(" <header>\n")
|
self.g.write(" <header>\n")
|
||||||
self.g.write(" <created date=\"%s %s %s\"" % \
|
self.g.write(' <created date="%04d-%02d-%02d\"' %
|
||||||
(date[2],date[1].upper(),date[4]))
|
(date[0],date[1],date[2]) )
|
||||||
self.g.write(" version=\"" + const.version + "\"")
|
self.g.write(" version=\"" + const.version + "\"")
|
||||||
self.g.write("/>\n")
|
self.g.write("/>\n")
|
||||||
self.g.write(" <researcher>\n")
|
self.g.write(" <researcher>\n")
|
||||||
@ -614,7 +613,12 @@ class XmlWriter:
|
|||||||
d = ''
|
d = ''
|
||||||
else:
|
else:
|
||||||
d = "-%02d" % date[0]
|
d = "-%02d" % date[0]
|
||||||
return "%s%s%s" % (y,m,d)
|
ret = "%s%s%s" % (y,m,d)
|
||||||
|
# If the result does not contain anything beyond dashes
|
||||||
|
# and question marks then it's as good as empty
|
||||||
|
if ret.replace('-','').replace('?','') == '':
|
||||||
|
ret = ''
|
||||||
|
return ret
|
||||||
|
|
||||||
def write_date(self,date,indent=1):
|
def write_date(self,date,indent=1):
|
||||||
sp = ' '*indent
|
sp = ' '*indent
|
||||||
@ -625,27 +629,41 @@ class XmlWriter:
|
|||||||
else:
|
else:
|
||||||
calstr = ''
|
calstr = ''
|
||||||
|
|
||||||
|
qual = date.get_quality()
|
||||||
|
if qual == Date.QUAL_ESTIMATED:
|
||||||
|
qual_str = ' quality="estimated"'
|
||||||
|
elif qual == Date.QUAL_CALCULATED:
|
||||||
|
qual_str = ' quality="calculated"'
|
||||||
|
else:
|
||||||
|
qual_str = ""
|
||||||
|
|
||||||
mode = date.get_modifier()
|
mode = date.get_modifier()
|
||||||
|
|
||||||
if date.is_compound():
|
if date.is_compound():
|
||||||
d1 = self.get_iso_date(date.get_start_date())
|
d1 = self.get_iso_date(date.get_start_date())
|
||||||
d2 = self.get_iso_date(date.get_stop_date())
|
d2 = self.get_iso_date(date.get_stop_date())
|
||||||
self.g.write('%s<daterange start="%s" stop="%s"%s/>\n' % (sp,d1,d2,calstr))
|
if d1 != "" or d2 != "":
|
||||||
|
self.g.write('%s<daterange start="%s" stop="%s"%s%s/>\n'
|
||||||
|
% (sp,d1,d2,qual_str,calstr))
|
||||||
elif mode != Date.MOD_TEXTONLY:
|
elif mode != Date.MOD_TEXTONLY:
|
||||||
dstr = self.get_iso_date(date.get_start_date())
|
date_str = self.get_iso_date(date.get_start_date())
|
||||||
|
if date_str == "":
|
||||||
|
return
|
||||||
|
|
||||||
if mode == Date.MOD_BEFORE:
|
if mode == Date.MOD_BEFORE:
|
||||||
pref = ' type="before"'
|
mode_str = ' type="before"'
|
||||||
elif mode == Date.MOD_AFTER:
|
elif mode == Date.MOD_AFTER:
|
||||||
pref = ' type="after"'
|
mode_str = ' type="after"'
|
||||||
elif mode == Date.MOD_ABOUT:
|
elif mode == Date.MOD_ABOUT:
|
||||||
pref = ' type="about"'
|
mode_str = ' type="about"'
|
||||||
else:
|
else:
|
||||||
pref = ""
|
mode_str = ""
|
||||||
|
|
||||||
self.g.write('%s<dateval val="%s"%s%s/>\n' % (sp,dstr,pref,calstr))
|
self.g.write('%s<dateval val="%s"%s%s%s/>\n'
|
||||||
|
% (sp,date_str,mode_str,qual_str,calstr))
|
||||||
else:
|
else:
|
||||||
self.g.write('%s<datestr val="%s"/>\n' %(sp,self.fix(date.get_text())))
|
self.g.write('%s<datestr val="%s"/>\n'
|
||||||
|
%(sp,self.fix(date.get_text())))
|
||||||
|
|
||||||
def write_force_line(self,label,value,indent=1):
|
def write_force_line(self,label,value,indent=1):
|
||||||
if value != None:
|
if value != None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user