* src/const.py.in: Add gramps-package mime type.
* src/ArgHandler.py (auto_save_load): Subclass database depending on the format. svn: r3496
This commit is contained in:
parent
b003d00a00
commit
2437f85dcd
@ -37,6 +37,10 @@
|
|||||||
then fall back to home.
|
then fall back to home.
|
||||||
* src/data/Makefile.am: Kill gconfd using SIGTERM -- HUP did not work.
|
* src/data/Makefile.am: Kill gconfd using SIGTERM -- HUP did not work.
|
||||||
|
|
||||||
|
* src/const.py.in: Add gramps-package mime type.
|
||||||
|
* src/ArgHandler.py (auto_save_load): Subclass database depending
|
||||||
|
on the format.
|
||||||
|
|
||||||
2004-08-23 Tim Waugh <twaugh@redhat.com>
|
2004-08-23 Tim Waugh <twaugh@redhat.com>
|
||||||
* install-sh: Removed this generated file.
|
* install-sh: Removed this generated file.
|
||||||
|
|
||||||
|
@ -20,9 +20,7 @@
|
|||||||
|
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
#
|
|
||||||
# Written by Alex Roitman
|
# Written by Alex Roitman
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Module responsible for handling the command line arguments for GRAMPS.
|
Module responsible for handling the command line arguments for GRAMPS.
|
||||||
@ -34,7 +32,6 @@ Module responsible for handling the command line arguments for GRAMPS.
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import os
|
import os
|
||||||
import os.path
|
|
||||||
import getopt
|
import getopt
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
@ -129,13 +126,13 @@ class ArgHandler:
|
|||||||
print "Invalid format: %s" % format
|
print "Invalid format: %s" % format
|
||||||
print "Ignoring input file: %s" % fname
|
print "Ignoring input file: %s" % fname
|
||||||
continue
|
continue
|
||||||
elif ftype == "application/x-gedcom":
|
elif ftype == const.app_gedcom:
|
||||||
format = 'gedcom'
|
format = 'gedcom'
|
||||||
elif ftype == "application/x-gramps-package":
|
elif ftype == const.app_gramps_package:
|
||||||
format = 'gramps-pkg'
|
format = 'gramps-pkg'
|
||||||
elif ftype == "x-directory/normal":
|
elif ftype == "x-directory/normal":
|
||||||
format = 'gramps-xml'
|
format = 'gramps-xml'
|
||||||
elif ftype == "application/x-gramps":
|
elif ftype == const.app_gramps:
|
||||||
format = 'grdb'
|
format = 'grdb'
|
||||||
else:
|
else:
|
||||||
print "Unrecognized format for input file %s" % fname
|
print "Unrecognized format for input file %s" % fname
|
||||||
@ -180,10 +177,32 @@ class ArgHandler:
|
|||||||
continue
|
continue
|
||||||
self.actions.append(action)
|
self.actions.append(action)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# open data in native format
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
def auto_save_load(self,filename):
|
def auto_save_load(self,filename):
|
||||||
filename = os.path.normpath(os.path.abspath(filename))
|
|
||||||
self.parent.active_person = None
|
self.parent.active_person = None
|
||||||
return self.parent.read_file(filename)
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
|
filetype = GrampsMime.get_type(filename)
|
||||||
|
if filetype == const.app_gramps:
|
||||||
|
import GrampsBSDDB
|
||||||
|
self.parent.db = GrampsBSDDB.GrampsBSDDB()
|
||||||
|
self.parent.read_file(filename)
|
||||||
|
return 1
|
||||||
|
elif filetype == const.app_gramps_xml:
|
||||||
|
import GrampsXMLDB
|
||||||
|
self.parent.db = GrampsXMLDB.GrampsXMLDB()
|
||||||
|
self.parent.read_file(filename)
|
||||||
|
return 1
|
||||||
|
elif filetype == const.app_gedcom:
|
||||||
|
import GrampsGEDDB
|
||||||
|
self.parent.db = GrampsGEDDB.GrampsGEDDB()
|
||||||
|
self.parent.read_file(filename)
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -202,14 +221,14 @@ class ArgHandler:
|
|||||||
# the rest of given arguments.
|
# the rest of given arguments.
|
||||||
filename = os.path.abspath(os.path.expanduser(self.open))
|
filename = os.path.abspath(os.path.expanduser(self.open))
|
||||||
filetype = GrampsMime.get_type(filename)
|
filetype = GrampsMime.get_type(filename)
|
||||||
if filetype == "application/x-gramps":
|
if filetype == const.app_gramps:
|
||||||
print "Type: GRAMPS database"
|
print "Type: GRAMPS database"
|
||||||
if self.auto_save_load(filename):
|
if self.auto_save_load(filename):
|
||||||
print "Opened successfully!"
|
print "Opened successfully!"
|
||||||
else:
|
else:
|
||||||
print "Cannot open %s. Exiting..."
|
print "Cannot open %s. Exiting..."
|
||||||
elif filetype in ("application/x-gedcom","x-directory/normal",
|
elif filetype in (const.app_gedcom,"x-directory/normal",
|
||||||
"application/x-gramps-package"):
|
const.app_gramps_package):
|
||||||
QuestionDialog.OkDialog( _("Opening non-native format"),
|
QuestionDialog.OkDialog( _("Opening non-native format"),
|
||||||
_("New GRAMPS database has to be set up when opening non-native formats. The following dialog will let you select the new database."),
|
_("New GRAMPS database has to be set up when opening non-native formats. The following dialog will let you select the new database."),
|
||||||
self.parent.topWindow)
|
self.parent.topWindow)
|
||||||
@ -220,13 +239,13 @@ class ArgHandler:
|
|||||||
_('GRAMPS cannot open non-native data without setting up new GRAMPS database.'))
|
_('GRAMPS cannot open non-native data without setting up new GRAMPS database.'))
|
||||||
print "Cannot continue without native database. Exiting..."
|
print "Cannot continue without native database. Exiting..."
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
elif filetype == "application/x-gedcom":
|
elif filetype == const.app_gedcom:
|
||||||
print "Type: GEDCOM"
|
print "Type: GEDCOM"
|
||||||
self.parent.read_gedcom(filename)
|
self.parent.read_gedcom(filename)
|
||||||
elif filetype == "x-directory/normal":
|
elif filetype == "x-directory/normal":
|
||||||
print "Type: GRAMPS XML"
|
print "Type: GRAMPS XML"
|
||||||
self.parent.read_xml(filename)
|
self.parent.read_xml(filename)
|
||||||
elif filetype == "application/x-gramps-package":
|
elif filetype == const.app_gramps_package:
|
||||||
print "Type: GRAMPS package"
|
print "Type: GRAMPS package"
|
||||||
self.parent.read_pkg(filename)
|
self.parent.read_pkg(filename)
|
||||||
else:
|
else:
|
||||||
|
@ -42,10 +42,10 @@ from TransTable import TransTable
|
|||||||
# Mime Types
|
# Mime Types
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
app_gramps = "application/x-gramps"
|
app_gramps = "application/x-gramps"
|
||||||
app_gramps_xml = "application/x-gramps-xml"
|
app_gramps_xml = "application/x-gramps-xml"
|
||||||
app_gedcom = "application/x-gedcom"
|
app_gedcom = "application/x-gedcom"
|
||||||
|
app_gramps_package = "application/x-gramps-package"
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user