Removal of command line parameter in XML import
svn: r16762
This commit is contained in:
parent
959bea3507
commit
fadd7c19de
@ -86,7 +86,7 @@ EVENT_PERSON_STR = _("%(event_name)s of %(person)s")
|
|||||||
# Must takes care of renaming media files according to their new IDs.
|
# Must takes care of renaming media files according to their new IDs.
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def importData(database, filename, callback=None, cl=0):
|
def importData(database, filename, callback=None):
|
||||||
## return Utils.profile(importDataPro, database, filename, callback, cl)
|
## return Utils.profile(importDataPro, database, filename, callback, cl)
|
||||||
##def importDataPro(database, filename, callback=None, cl=0):
|
##def importDataPro(database, filename, callback=None, cl=0):
|
||||||
|
|
||||||
@ -100,15 +100,12 @@ def importData(database, filename, callback=None, cl=0):
|
|||||||
database.pmap = {}
|
database.pmap = {}
|
||||||
database.fmap = {}
|
database.fmap = {}
|
||||||
|
|
||||||
xml_file = open_file(filename, cl)
|
xml_file = open_file(filename)
|
||||||
versionparser = VersionParser(xml_file)
|
versionparser = VersionParser(xml_file)
|
||||||
|
|
||||||
if xml_file is None or \
|
if xml_file is None or \
|
||||||
version_is_valid(versionparser, cl) is False:
|
version_is_valid(versionparser) is False:
|
||||||
if cl:
|
return
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
version_string = versionparser.get_xmlns_version()
|
version_string = versionparser.get_xmlns_version()
|
||||||
#reset file to the start
|
#reset file to the start
|
||||||
@ -127,26 +124,14 @@ def importData(database, filename, callback=None, cl=0):
|
|||||||
try:
|
try:
|
||||||
info = parser.parse(xml_file, line_cnt, person_cnt)
|
info = parser.parse(xml_file, line_cnt, person_cnt)
|
||||||
except IOError, msg:
|
except IOError, msg:
|
||||||
if cl:
|
ErrorDialog(_("Error reading %s") % filename, str(msg))
|
||||||
LOG.warn("Error reading %s" % filename)
|
import traceback
|
||||||
LOG.warn(msg)
|
traceback.print_exc()
|
||||||
import traceback
|
return
|
||||||
traceback.print_exc()
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
ErrorDialog(_("Error reading %s") % filename, str(msg))
|
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
return
|
|
||||||
except ExpatError, msg:
|
except ExpatError, msg:
|
||||||
if cl:
|
ErrorDialog(_("Error reading %s") % filename,
|
||||||
LOG.warn("Error reading %s" % filename)
|
_("The file is probably either corrupt or not a valid Gramps database."))
|
||||||
LOG.warn("The file is probably either corrupt or not a valid Gramps database.")
|
return
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
ErrorDialog(_("Error reading %s") % filename,
|
|
||||||
_("The file is probably either corrupt or not a valid Gramps database."))
|
|
||||||
return
|
|
||||||
|
|
||||||
xml_file.close()
|
xml_file.close()
|
||||||
|
|
||||||
@ -2620,7 +2605,7 @@ class VersionParser(object):
|
|||||||
" Get the version of Gramps that created the file "
|
" Get the version of Gramps that created the file "
|
||||||
return self.__gramps_version
|
return self.__gramps_version
|
||||||
|
|
||||||
def open_file(filename, cli):
|
def open_file(filename):
|
||||||
"""
|
"""
|
||||||
Open the xml file.
|
Open the xml file.
|
||||||
Return a valid file handle if the file opened sucessfully.
|
Return a valid file handle if the file opened sucessfully.
|
||||||
@ -2645,22 +2630,15 @@ def open_file(filename, cli):
|
|||||||
else:
|
else:
|
||||||
xml_file = open(filename, "r")
|
xml_file = open(filename, "r")
|
||||||
except IOError, msg:
|
except IOError, msg:
|
||||||
if cli:
|
ErrorDialog(_("%s could not be opened") % filename, str(msg))
|
||||||
LOG.warn("Error: %s could not be opened Exiting." % filename)
|
|
||||||
LOG.warn(msg)
|
|
||||||
else:
|
|
||||||
ErrorDialog(_("%s could not be opened") % filename, str(msg))
|
|
||||||
xml_file = None
|
xml_file = None
|
||||||
except:
|
except:
|
||||||
if cli:
|
ErrorDialog(_("%s could not be opened") % filename)
|
||||||
LOG.warn("Error: %s could not be opened. Exiting." % filename)
|
|
||||||
else:
|
|
||||||
ErrorDialog(_("%s could not be opened") % filename)
|
|
||||||
xml_file = None
|
xml_file = None
|
||||||
|
|
||||||
return xml_file
|
return xml_file
|
||||||
|
|
||||||
def version_is_valid(versionparser, cli):
|
def version_is_valid(versionparser):
|
||||||
"""
|
"""
|
||||||
Validate the xml version.
|
Validate the xml version.
|
||||||
:param versionparser: A VersionParser object to work with
|
:param versionparser: A VersionParser object to work with
|
||||||
@ -2672,12 +2650,8 @@ def version_is_valid(versionparser, cli):
|
|||||||
"The file will not be imported. Please upgrade to the latest "
|
"The file will not be imported. Please upgrade to the latest "
|
||||||
"version of Gramps and try again." ) % {
|
"version of Gramps and try again." ) % {
|
||||||
'newer' : versionparser.get_gramps_version(), 'older' : const.VERSION }
|
'newer' : versionparser.get_gramps_version(), 'older' : const.VERSION }
|
||||||
if cli:
|
ErrorDialog(msg)
|
||||||
LOG.warn(msg)
|
return False
|
||||||
return False
|
|
||||||
else:
|
|
||||||
ErrorDialog(msg)
|
|
||||||
return False
|
|
||||||
if versionparser.get_xmlns_version() < '1.0.0':
|
if versionparser.get_xmlns_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 "
|
||||||
@ -2690,12 +2664,8 @@ def version_is_valid(versionparser, cli):
|
|||||||
'newgramps': const.VERSION,
|
'newgramps': const.VERSION,
|
||||||
'xmlversion': versionparser.get_xmlns_version(),
|
'xmlversion': versionparser.get_xmlns_version(),
|
||||||
}
|
}
|
||||||
if cli:
|
ErrorDialog(_('The file will not be imported'), msg)
|
||||||
LOG.warn(msg)
|
return False
|
||||||
return False
|
|
||||||
else:
|
|
||||||
ErrorDialog(_('The file will not be imported'), msg)
|
|
||||||
return False
|
|
||||||
elif versionparser.get_xmlns_version() < '1.1.0':
|
elif versionparser.get_xmlns_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 "
|
||||||
@ -2710,10 +2680,6 @@ def version_is_valid(versionparser, cli):
|
|||||||
'newgramps': const.VERSION,
|
'newgramps': const.VERSION,
|
||||||
'xmlversion': versionparser.get_xmlns_version(),
|
'xmlversion': versionparser.get_xmlns_version(),
|
||||||
}
|
}
|
||||||
if cli:
|
WarningDialog(_('Old xml file'), msg)
|
||||||
LOG.warn(msg)
|
return True
|
||||||
return True
|
|
||||||
else:
|
|
||||||
WarningDialog(_('Old xml file'), msg)
|
|
||||||
return True
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user