* 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
7f2b5265da
commit
73d8bdafdc
@ -37,6 +37,10 @@
|
||||
then fall back to home.
|
||||
* 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>
|
||||
* install-sh: Removed this generated file.
|
||||
|
||||
|
@ -20,9 +20,7 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
#
|
||||
# Written by Alex Roitman
|
||||
#
|
||||
|
||||
"""
|
||||
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.path
|
||||
import getopt
|
||||
from gettext import gettext as _
|
||||
|
||||
@ -129,13 +126,13 @@ class ArgHandler:
|
||||
print "Invalid format: %s" % format
|
||||
print "Ignoring input file: %s" % fname
|
||||
continue
|
||||
elif ftype == "application/x-gedcom":
|
||||
elif ftype == const.app_gedcom:
|
||||
format = 'gedcom'
|
||||
elif ftype == "application/x-gramps-package":
|
||||
elif ftype == const.app_gramps_package:
|
||||
format = 'gramps-pkg'
|
||||
elif ftype == "x-directory/normal":
|
||||
format = 'gramps-xml'
|
||||
elif ftype == "application/x-gramps":
|
||||
elif ftype == const.app_gramps:
|
||||
format = 'grdb'
|
||||
else:
|
||||
print "Unrecognized format for input file %s" % fname
|
||||
@ -180,10 +177,32 @@ class ArgHandler:
|
||||
continue
|
||||
self.actions.append(action)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# open data in native format
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def auto_save_load(self,filename):
|
||||
filename = os.path.normpath(os.path.abspath(filename))
|
||||
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.
|
||||
filename = os.path.abspath(os.path.expanduser(self.open))
|
||||
filetype = GrampsMime.get_type(filename)
|
||||
if filetype == "application/x-gramps":
|
||||
if filetype == const.app_gramps:
|
||||
print "Type: GRAMPS database"
|
||||
if self.auto_save_load(filename):
|
||||
print "Opened successfully!"
|
||||
else:
|
||||
print "Cannot open %s. Exiting..."
|
||||
elif filetype in ("application/x-gedcom","x-directory/normal",
|
||||
"application/x-gramps-package"):
|
||||
elif filetype in (const.app_gedcom,"x-directory/normal",
|
||||
const.app_gramps_package):
|
||||
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."),
|
||||
self.parent.topWindow)
|
||||
@ -220,13 +239,13 @@ class ArgHandler:
|
||||
_('GRAMPS cannot open non-native data without setting up new GRAMPS database.'))
|
||||
print "Cannot continue without native database. Exiting..."
|
||||
os._exit(1)
|
||||
elif filetype == "application/x-gedcom":
|
||||
elif filetype == const.app_gedcom:
|
||||
print "Type: GEDCOM"
|
||||
self.parent.read_gedcom(filename)
|
||||
elif filetype == "x-directory/normal":
|
||||
print "Type: GRAMPS XML"
|
||||
self.parent.read_xml(filename)
|
||||
elif filetype == "application/x-gramps-package":
|
||||
elif filetype == const.app_gramps_package:
|
||||
print "Type: GRAMPS package"
|
||||
self.parent.read_pkg(filename)
|
||||
else:
|
||||
|
@ -42,10 +42,10 @@ from TransTable import TransTable
|
||||
# Mime Types
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
app_gramps = "application/x-gramps"
|
||||
app_gramps_xml = "application/x-gramps-xml"
|
||||
app_gedcom = "application/x-gedcom"
|
||||
app_gramps_package = "application/x-gramps-package"
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user