7125/7102: port my fix from gramps40
Don't bump 1.6.0 XML version, because Gramps 4.1 -- the first version to use it -- hasn't been released yet svn: r23356
This commit is contained in:
parent
59457923fa
commit
bf6901e6ed
@ -431,7 +431,7 @@
|
|||||||
<ref name="primary-object"/>
|
<ref name="primary-object"/>
|
||||||
<optional><ref name="date-content"/></optional>
|
<optional><ref name="date-content"/></optional>
|
||||||
<optional><element name="page"><text/></element></optional>
|
<optional><element name="page"><text/></element></optional>
|
||||||
<optional><element name="confidence"><text/></element></optional>
|
<element name="confidence"><text/></element>
|
||||||
<zeroOrMore><element name="noteref">
|
<zeroOrMore><element name="noteref">
|
||||||
<ref name="noteref-content"/>
|
<ref name="noteref-content"/>
|
||||||
</element></zeroOrMore>
|
</element></zeroOrMore>
|
||||||
|
@ -74,6 +74,7 @@ from gramps.version import VERSION
|
|||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
#import gramps.plugins.lib.libgrampsxml
|
#import gramps.plugins.lib.libgrampsxml
|
||||||
from gramps.plugins.lib import libgrampsxml
|
from gramps.plugins.lib import libgrampsxml
|
||||||
|
from gramps.gen.plug.utils import version_str_to_tup
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -487,7 +488,7 @@ class GrampsParser(UpdateCallback):
|
|||||||
UpdateCallback.__init__(self, user.callback)
|
UpdateCallback.__init__(self, user.callback)
|
||||||
self.user = user
|
self.user = user
|
||||||
self.__gramps_version = 'unknown'
|
self.__gramps_version = 'unknown'
|
||||||
self.__xml_version = '1.0.0'
|
self.__xml_version = (1, 0, 0)
|
||||||
self.stext_list = []
|
self.stext_list = []
|
||||||
self.scomments_list = []
|
self.scomments_list = []
|
||||||
self.note_list = []
|
self.note_list = []
|
||||||
@ -988,17 +989,17 @@ class GrampsParser(UpdateCallback):
|
|||||||
if 'xmlns' in attrs:
|
if 'xmlns' in attrs:
|
||||||
xmlns = attrs.get('xmlns').split('/')
|
xmlns = attrs.get('xmlns').split('/')
|
||||||
if len(xmlns)>= 2 and not xmlns[2] == 'gramps-project.org':
|
if len(xmlns)>= 2 and not xmlns[2] == 'gramps-project.org':
|
||||||
self.__xml_version = '0.0.0'
|
self.__xml_version = (0, 0, 0)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.__xml_version = xmlns[4]
|
self.__xml_version = version_str_to_tup(xmlns[4], 3)
|
||||||
except:
|
except:
|
||||||
#leave version at 1.0.0 although it could be 0.0.0 ??
|
#leave version at 1.0.0 although it could be 0.0.0 ??
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
#1.0 or before xml, no dtd schema yet on
|
#1.0 or before xml, no dtd schema yet on
|
||||||
# http://www.gramps-project.org/xml/
|
# http://www.gramps-project.org/xml/
|
||||||
self.__xml_version = '0.0.0'
|
self.__xml_version = (0, 0, 0)
|
||||||
|
|
||||||
def start_created(self, attrs):
|
def start_created(self, attrs):
|
||||||
"""
|
"""
|
||||||
@ -1019,18 +1020,13 @@ class GrampsParser(UpdateCallback):
|
|||||||
"""
|
"""
|
||||||
Check the version of Gramps and XML.
|
Check the version of Gramps and XML.
|
||||||
"""
|
"""
|
||||||
|
xmlversion_str = '.'.join(str(i) for i in self.__xml_version)
|
||||||
if self.__gramps_version == 'unknown':
|
if self.__gramps_version == 'unknown':
|
||||||
msg = _("The .gramps file you are importing does not contain information about "
|
msg = _("The .gramps file you are importing does not contain information about "
|
||||||
"the version of Gramps with, which it was produced.\n\n"
|
"the version of Gramps with, which it was produced.\n\n"
|
||||||
"The file will not be imported.")
|
"The file will not be imported.")
|
||||||
raise GrampsImportError(_('Import file misses Gramps version'), msg)
|
raise GrampsImportError(_('Import file misses Gramps version'), msg)
|
||||||
if not re.match("\d+\.\d+\.\d+", self.__xml_version):
|
if self.__xml_version > libgrampsxml.GRAMPS_XML_VERSION_TUPLE:
|
||||||
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:
|
|
||||||
msg = _("The .gramps file you are importing was made by "
|
msg = _("The .gramps file you are importing was made by "
|
||||||
"version %(newer)s of "
|
"version %(newer)s of "
|
||||||
"Gramps, while you are running an older version %(older)s. "
|
"Gramps, while you are running an older version %(older)s. "
|
||||||
@ -1038,7 +1034,7 @@ class GrampsParser(UpdateCallback):
|
|||||||
"latest version of Gramps and try again." ) % {
|
"latest version of Gramps and try again." ) % {
|
||||||
'newer' : self.__gramps_version, 'older' : VERSION }
|
'newer' : self.__gramps_version, 'older' : VERSION }
|
||||||
raise GrampsImportError('', msg)
|
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 "
|
msg = _("The .gramps file you are importing was made by version "
|
||||||
"%(oldgramps)s of Gramps, while you are running a more "
|
"%(oldgramps)s of Gramps, while you are running a more "
|
||||||
"recent version %(newgramps)s.\n\n"
|
"recent version %(newgramps)s.\n\n"
|
||||||
@ -1049,10 +1045,10 @@ class GrampsParser(UpdateCallback):
|
|||||||
"\n for more info."
|
"\n for more info."
|
||||||
) % {'oldgramps': self.__gramps_version,
|
) % {'oldgramps': self.__gramps_version,
|
||||||
'newgramps': VERSION,
|
'newgramps': VERSION,
|
||||||
'xmlversion': self.__xml_version,
|
'xmlversion': xmlversion_str,
|
||||||
}
|
}
|
||||||
raise GrampsImportError(_('The file will not be imported'), msg)
|
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 "
|
msg = _("The .gramps file you are importing was made by version "
|
||||||
"%(oldgramps)s of Gramps, while you are running a much "
|
"%(oldgramps)s of Gramps, while you are running a much "
|
||||||
"more recent version %(newgramps)s.\n\n"
|
"more recent version %(newgramps)s.\n\n"
|
||||||
@ -1064,7 +1060,7 @@ class GrampsParser(UpdateCallback):
|
|||||||
"\nfor more info."
|
"\nfor more info."
|
||||||
) % {'oldgramps': self.__gramps_version,
|
) % {'oldgramps': self.__gramps_version,
|
||||||
'newgramps': VERSION,
|
'newgramps': VERSION,
|
||||||
'xmlversion': self.__xml_version,
|
'xmlversion': xmlversion_str,
|
||||||
}
|
}
|
||||||
self.user.warn(_('Old xml file'), msg)
|
self.user.warn(_('Old xml file'), msg)
|
||||||
|
|
||||||
@ -1660,7 +1656,7 @@ class GrampsParser(UpdateCallback):
|
|||||||
self.name = Name()
|
self.name = Name()
|
||||||
name_type = attrs.get('type', "Birth Name")
|
name_type = attrs.get('type', "Birth Name")
|
||||||
# Mapping "Other Name" from gramps 2.0.x to Unknown
|
# 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)
|
self.name.set_type(NameType.UNKNOWN)
|
||||||
else:
|
else:
|
||||||
self.name.type.set_from_xml_str(name_type)
|
self.name.type.set_from_xml_str(name_type)
|
||||||
@ -2036,7 +2032,9 @@ class GrampsParser(UpdateCallback):
|
|||||||
self.citation)
|
self.citation)
|
||||||
self.citation.private = bool(attrs.get("priv"))
|
self.citation.private = bool(attrs.get("priv"))
|
||||||
self.citation.change = int(attrs.get('change', self.change))
|
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)
|
self.info.add('new-object', CITATION_KEY, self.citation)
|
||||||
return self.citation
|
return self.citation
|
||||||
|
|
||||||
|
@ -35,5 +35,5 @@
|
|||||||
# Public Constants
|
# Public Constants
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
GRAMPS_XML_VERSION = "1.6.0" # version for Gramps 4.1
|
GRAMPS_XML_VERSION_TUPLE = (1,6,0) # version for Gramps 4.1
|
||||||
|
GRAMPS_XML_VERSION = '.'.join(str(i) for i in GRAMPS_XML_VERSION_TUPLE)
|
||||||
|
Loading…
Reference in New Issue
Block a user