7125/7102: port my fix from gramps34
svn: r23355
This commit is contained in:
parent
2bf775fad3
commit
ba541e6c03
@ -25,15 +25,15 @@
|
||||
-->
|
||||
|
||||
<!--
|
||||
This is the Document Type Definition file for v1.5.0
|
||||
This is the Document Type Definition file for v1.5.1
|
||||
of the GRAMPS XML genealogy data format.
|
||||
Please use the following formal public identifier to identify it:
|
||||
|
||||
"-//GRAMPS//DTD GRAMPS XML V1.5.0//EN"
|
||||
"-//GRAMPS//DTD GRAMPS XML V1.5.1//EN"
|
||||
|
||||
For example:
|
||||
<!DOCTYPE database PUBLIC "-//GRAMPS//DTD GRAMPS XML V1.5.0//EN"
|
||||
"http://gramps-project.org/xml/1.5.0/grampsxml.dtd"
|
||||
<!DOCTYPE database PUBLIC "-//GRAMPS//DTD GRAMPS XML V1.5.1//EN"
|
||||
"http://gramps-project.org/xml/1.5.1/grampsxml.dtd"
|
||||
[...]>
|
||||
-->
|
||||
|
||||
@ -62,7 +62,7 @@ DATABASE
|
||||
<!ELEMENT database (header, name-formats?, tags?, events?, people?, families?,
|
||||
citations?, sources?, places?, objects?, repositories?,
|
||||
notes?, bookmarks?, namemaps?)>
|
||||
<!ATTLIST database xmlns CDATA #FIXED "http://gramps-project.org/xml/1.5.0/">
|
||||
<!ATTLIST database xmlns CDATA #FIXED "http://gramps-project.org/xml/1.5.1/">
|
||||
|
||||
|
||||
<!-- ************************************************************
|
||||
@ -367,7 +367,7 @@ CITATIONS
|
||||
|
||||
<!ELEMENT citations (citation)*>
|
||||
|
||||
<!ELEMENT citation ((daterange|datespan|dateval|datestr)?, page?, confidence?,
|
||||
<!ELEMENT citation ((daterange|datespan|dateval|datestr)?, page?, confidence,
|
||||
noteref*, objref*, data_item*, sourceref)>
|
||||
<!ATTLIST citation
|
||||
id CDATA #IMPLIED
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
<grammar
|
||||
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
|
||||
ns="http://gramps-project.org/xml/1.5.0/"
|
||||
ns="http://gramps-project.org/xml/1.5.1/"
|
||||
xmlns="http://relaxng.org/ns/structure/1.0">
|
||||
|
||||
<start><element name="database">
|
||||
@ -434,7 +434,7 @@
|
||||
<ref name="primary-object"/>
|
||||
<optional><ref name="date-content"/></optional>
|
||||
<optional><element name="page"><text/></element></optional>
|
||||
<optional><element name="confidence"><text/></element></optional>
|
||||
<element name="confidence"><text/></element>
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
|
@ -71,6 +71,7 @@ from gramps.version import VERSION
|
||||
from gramps.gen.config import config
|
||||
#import gramps.plugins.lib.libgrampsxml
|
||||
from gramps.plugins.lib import libgrampsxml
|
||||
from gramps.gen.plug.utils import version_str_to_tup
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -480,7 +481,7 @@ class GrampsParser(UpdateCallback):
|
||||
UpdateCallback.__init__(self, user.callback)
|
||||
self.user = user
|
||||
self.__gramps_version = 'unknown'
|
||||
self.__xml_version = '1.0.0'
|
||||
self.__xml_version = (1, 0, 0)
|
||||
self.stext_list = []
|
||||
self.scomments_list = []
|
||||
self.note_list = []
|
||||
@ -979,17 +980,17 @@ class GrampsParser(UpdateCallback):
|
||||
if 'xmlns' in attrs:
|
||||
xmlns = attrs.get('xmlns').split('/')
|
||||
if len(xmlns)>= 2 and not xmlns[2] == 'gramps-project.org':
|
||||
self.__xml_version = '0.0.0'
|
||||
self.__xml_version = (0, 0, 0)
|
||||
else:
|
||||
try:
|
||||
self.__xml_version = xmlns[4]
|
||||
self.__xml_version = version_str_to_tup(xmlns[4], 3)
|
||||
except:
|
||||
#leave version at 1.0.0 although it could be 0.0.0 ??
|
||||
pass
|
||||
else:
|
||||
#1.0 or before xml, no dtd schema yet on
|
||||
# http://www.gramps-project.org/xml/
|
||||
self.__xml_version = '0.0.0'
|
||||
self.__xml_version = (0, 0, 0)
|
||||
|
||||
def start_created(self, attrs):
|
||||
"""
|
||||
@ -1010,18 +1011,13 @@ class GrampsParser(UpdateCallback):
|
||||
"""
|
||||
Check the version of Gramps and XML.
|
||||
"""
|
||||
xmlversion_str = '.'.join(str(i) for i in self.__xml_version)
|
||||
if self.__gramps_version == 'unknown':
|
||||
msg = _("The .gramps file you are importing does not contain information about "
|
||||
"the version of Gramps with, which it was produced.\n\n"
|
||||
"The file will not be imported.")
|
||||
raise GrampsImportError(_('Import file misses Gramps version'), msg)
|
||||
if not re.match("\d+\.\d+\.\d+", self.__xml_version):
|
||||
msg = _("The .gramps file you are importing does not contain a "
|
||||
"valid xml-namespace number.\n\n"
|
||||
"The file will not be imported.")
|
||||
raise GrampsImportError(_('Import file contains unacceptable XML '
|
||||
'namespace version'), msg)
|
||||
if self.__xml_version > libgrampsxml.GRAMPS_XML_VERSION:
|
||||
if self.__xml_version > libgrampsxml.GRAMPS_XML_VERSION_TUPLE:
|
||||
msg = _("The .gramps file you are importing was made by "
|
||||
"version %(newer)s of "
|
||||
"Gramps, while you are running an older version %(older)s. "
|
||||
@ -1029,7 +1025,7 @@ class GrampsParser(UpdateCallback):
|
||||
"latest version of Gramps and try again." ) % {
|
||||
'newer' : self.__gramps_version, 'older' : VERSION }
|
||||
raise GrampsImportError('', msg)
|
||||
if self.__xml_version < '1.0.0':
|
||||
if self.__xml_version < (1, 0, 0):
|
||||
msg = _("The .gramps file you are importing was made by version "
|
||||
"%(oldgramps)s of Gramps, while you are running a more "
|
||||
"recent version %(newgramps)s.\n\n"
|
||||
@ -1040,10 +1036,10 @@ class GrampsParser(UpdateCallback):
|
||||
"\n for more info."
|
||||
) % {'oldgramps': self.__gramps_version,
|
||||
'newgramps': VERSION,
|
||||
'xmlversion': self.__xml_version,
|
||||
'xmlversion': xmlversion_str,
|
||||
}
|
||||
raise GrampsImportError(_('The file will not be imported'), msg)
|
||||
elif self.__xml_version < '1.1.0':
|
||||
elif self.__xml_version < (1, 1, 0):
|
||||
msg = _("The .gramps file you are importing was made by version "
|
||||
"%(oldgramps)s of Gramps, while you are running a much "
|
||||
"more recent version %(newgramps)s.\n\n"
|
||||
@ -1055,7 +1051,7 @@ class GrampsParser(UpdateCallback):
|
||||
"\nfor more info."
|
||||
) % {'oldgramps': self.__gramps_version,
|
||||
'newgramps': VERSION,
|
||||
'xmlversion': self.__xml_version,
|
||||
'xmlversion': xmlversion_str,
|
||||
}
|
||||
self.user.warn(_('Old xml file'), msg)
|
||||
|
||||
@ -1624,7 +1620,7 @@ class GrampsParser(UpdateCallback):
|
||||
self.name = Name()
|
||||
name_type = attrs.get('type', "Birth Name")
|
||||
# Mapping "Other Name" from gramps 2.0.x to Unknown
|
||||
if (self.__xml_version == '1.0.0') and (name_type == 'Other Name'):
|
||||
if (self.__xml_version == (1, 0, 0)) and (name_type == 'Other Name'):
|
||||
self.name.set_type(NameType.UNKNOWN)
|
||||
else:
|
||||
self.name.type.set_from_xml_str(name_type)
|
||||
@ -1985,7 +1981,9 @@ class GrampsParser(UpdateCallback):
|
||||
self.citation)
|
||||
self.citation.private = bool(attrs.get("priv"))
|
||||
self.citation.change = int(attrs.get('change', self.change))
|
||||
self.citation.confidence = self.conf # default
|
||||
self.citation.confidence = (
|
||||
self.conf if self.__xml_version >= (1, 5, 1)
|
||||
else 0 ) # See bug# 7125
|
||||
self.info.add('new-object', CITATION_KEY, self.citation)
|
||||
return self.citation
|
||||
|
||||
|
@ -35,5 +35,5 @@
|
||||
# Public Constants
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
GRAMPS_XML_VERSION = "1.5.0"
|
||||
|
||||
GRAMPS_XML_VERSION_TUPLE = (1,5,1)
|
||||
GRAMPS_XML_VERSION = '.'.join(str(i) for i in GRAMPS_XML_VERSION_TUPLE)
|
||||
|
Loading…
Reference in New Issue
Block a user