3021: When ever try to import a data.gramps from 3/2005, it bombs with errors given here

svn: r12574
This commit is contained in:
Benny Malengier 2009-05-27 09:35:50 +00:00
parent 5eb7e18dc6
commit 1edada53d0

View File

@ -37,7 +37,7 @@ import re
# Gramps Modules # Gramps Modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog, WarningDialog
import Mime import Mime
import gen.lib import gen.lib
import Utils import Utils
@ -2402,7 +2402,16 @@ class VersionParser(object):
" Handle XML elements " " Handle XML elements "
if tag == "database" and 'xmlns' in attrs: if tag == "database" and 'xmlns' in attrs:
xmlns = attrs.get('xmlns') xmlns = attrs.get('xmlns')
try:
self.__xml_version = xmlns.split('/')[4] self.__xml_version = xmlns.split('/')[4]
except:
#leave version at 1.0.0
pass
elif tag == "database" and not 'xmlns' in attrs:
#1.0 or before xml, no dtd schema yet on
# http://www.gramps-project.org/xml/
self.__xml_version = '0.0.0'
elif tag == "created" and 'version' in attrs: elif tag == "created" and 'version' in attrs:
self.__gramps_version = attrs.get('version') self.__gramps_version = attrs.get('version')
@ -2472,7 +2481,44 @@ def version_is_valid(filename, cli):
else: else:
ErrorDialog(msg) ErrorDialog(msg)
return False return False
if parser.get_xmlns_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"
"The file will not be imported. Please use an older version of"
" GRAMPS that supports version %(xmlversion)s of the xml.\nSee"
"\n http://gramps-project.org/wiki/index.php?title=GRAMPS_XML\n "
"for more info."
) % {'oldgramps': parser.get_gramps_version(),
'newgramps': const.VERSION,
'xmlversion': parser.get_xmlns_version(),
}
if cli:
print msg
return False
else:
ErrorDialog(_('The file will not be imported'), msg)
return False
elif parser.get_xmlns_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"
"Ensure after import everything is imported correctly. In the "
"event of problems, please submit a bug and use an older "
"version of GRAMPS in the meantime to import this file, which "
"is version %(xmlversion)s of the xml.\nSee"
"\n http://gramps-project.org/wiki/index.php?title=GRAMPS_XML\n"
"for more info."
) % {'oldgramps': parser.get_gramps_version(),
'newgramps': const.VERSION,
'xmlversion': parser.get_xmlns_version(),
}
if cli:
print msg
return True
else:
WarningDialog(_('Old xml file'), msg)
return True
return True return True
#------------------------------------------------------------------------ #------------------------------------------------------------------------