* configure.in: Bump up the version number.
* src/gramps.py: Pass complete argument string. * src/gramps_main.py: Pass popt table to gnome_init(). Always enable argument handling. (read_xml,read_pkg): Add functions. * src/const.py.in: Define popt table, add all gnome options. * src/ArgHandler.py: Add long options for gramps-specific options. Add handling for the first filename argument. Use 'gramps-xml' to denote old gramps (XML) format. * src/DbPrompter.py: Add hint for the filename. * src/plugins/ReadNative.py: Cosmetic changes. * src/plugins/ReadPkg.py: Cosmetic changes. * src/plugins/WritePkg.py: Typo. * src/data/gramps.xml: Add mime type for gramps package. * src/data/gramps.applications: Add gramps package to the list. * src/data/Makefile.am: Typo. * src/gramps_main.py: removed new database info message * src/plugins/ReadGedcom.py: Fixed typos preventing import. (i.e. set_type instead of SetType, etc.) * Release: Version 1.1.0 "And now for something completely different" released. svn: r3218
This commit is contained in:
parent
77fce526cf
commit
2e477a5936
26
ChangeLog
26
ChangeLog
@ -1,11 +1,33 @@
|
|||||||
|
2004-06-20 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
|
* configure.in: Bump up the version number.
|
||||||
|
* src/gramps.py: Pass complete argument string.
|
||||||
|
* src/gramps_main.py: Pass popt table to gnome_init().
|
||||||
|
Always enable argument handling. (read_xml,read_pkg): Add functions.
|
||||||
|
* src/const.py.in: Define popt table, add all gnome options.
|
||||||
|
* src/ArgHandler.py: Add long options for gramps-specific options.
|
||||||
|
Add handling for the first filename argument. Use 'gramps-xml'
|
||||||
|
to denote old gramps (XML) format.
|
||||||
|
* src/DbPrompter.py: Add hint for the filename.
|
||||||
|
* src/plugins/ReadNative.py: Cosmetic changes.
|
||||||
|
* src/plugins/ReadPkg.py: Cosmetic changes.
|
||||||
|
* src/plugins/WritePkg.py: Typo.
|
||||||
|
* src/data/gramps.xml: Add mime type for gramps package.
|
||||||
|
* src/data/gramps.applications: Add gramps package to the list.
|
||||||
|
* src/data/Makefile.am: Typo.
|
||||||
|
|
||||||
2004-06-19 Don Allingham <dallingham@users.sourceforge.net>
|
2004-06-19 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
* src/DisplayModels,py: faster sorting of places
|
* src/DisplayModels,py: faster sorting of places
|
||||||
* src/PlaceView,py: faster sorting of places
|
* src/PlaceView,py: faster sorting of places
|
||||||
* src/RelLib,py: faster sorting of places
|
* src/RelLib,py: faster sorting of places
|
||||||
* src/gramp_main.py: removed new database info message
|
* src/gramps_main.py: removed new database info message
|
||||||
|
|
||||||
2004-06-18 Jason Salaz <whatsizbucket@users.sourceforge.net>
|
2004-06-18 Jason Salaz <whatsizbucket@users.sourceforge.net>
|
||||||
* src/plugins/ReadGedcom.py Fixed typos preventing import. (i.e. set_type instead of SetType, etc.)
|
* src/plugins/ReadGedcom.py: Fixed typos preventing import.
|
||||||
|
(i.e. set_type instead of SetType, etc.)
|
||||||
|
|
||||||
|
2004-06-16 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
|
* Release: Version 1.1.0 "And now for something completely different"
|
||||||
|
released.
|
||||||
|
|
||||||
2004-06-14 Don Allingham <dallingham@users.sourceforge.net>
|
2004-06-14 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
* src/RelLib.py: fix index for place map
|
* src/RelLib.py: fix index for place map
|
||||||
|
@ -2,11 +2,11 @@ dnl Process this file with autoconf to produce a configure script.
|
|||||||
dnl May need to run automake && aclocal first
|
dnl May need to run automake && aclocal first
|
||||||
|
|
||||||
AC_PREREQ(2.57)
|
AC_PREREQ(2.57)
|
||||||
AC_INIT(gramps, 1.1.0, gramps-bugs@lists.sourceforge.net)
|
AC_INIT(gramps, 1.1.1, gramps-bugs@lists.sourceforge.net)
|
||||||
AC_CONFIG_SRCDIR(src/gramps.py)
|
AC_CONFIG_SRCDIR(src/gramps.py)
|
||||||
AM_INIT_AUTOMAKE(1.6.3)
|
AM_INIT_AUTOMAKE(1.6.3)
|
||||||
dnl RELEASE=0.CVS$(head -c 10 ${srcdir}/ChangeLog | tr -d '-')
|
RELEASE=0.CVS$(head -c 10 ${srcdir}/ChangeLog | tr -d '-')
|
||||||
RELEASE=1
|
dnl RELEASE=1
|
||||||
|
|
||||||
VERSIONSTRING=$VERSION
|
VERSIONSTRING=$VERSION
|
||||||
if test x"$RELEASE" != "x"
|
if test x"$RELEASE" != "x"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2003 Donald N. Allingham
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -43,6 +43,10 @@ import getopt
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import const
|
import const
|
||||||
import ReadXML
|
import ReadXML
|
||||||
|
import GrampsMime
|
||||||
|
import DbPrompter
|
||||||
|
import QuestionDialog
|
||||||
|
import GrampsCfg
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -50,54 +54,96 @@ import ReadXML
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class ArgHandler:
|
class ArgHandler:
|
||||||
|
"""
|
||||||
|
This class is responsible for handling command line arguments (if any)
|
||||||
|
given to gramps. The valid arguments are:
|
||||||
|
|
||||||
|
FILE : filename to open.
|
||||||
|
All following arguments will be ignored.
|
||||||
|
-i, --import=FILE : filename to import.
|
||||||
|
-o, --output=FILE : filename to export.
|
||||||
|
-f, --format=FORMAT : format of the file preceding this option.
|
||||||
|
|
||||||
|
If the filename (no flags) is specified, the interactive session is
|
||||||
|
launched using data from filename. If the filename is not a natvive (grdb) format, dialog will
|
||||||
|
be presented to set up a grdb database.
|
||||||
|
|
||||||
|
If no filename or -i option is given, a new interactive session (empty
|
||||||
|
database) is launched, since no data is goven anyway.
|
||||||
|
|
||||||
|
If -i option is given, but no -o or -a options are given, and interactive
|
||||||
|
session is launched with the FILE (specified with -i).
|
||||||
|
|
||||||
|
If both -i and -o or -a are given, interactive session will not be
|
||||||
|
launched.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self,parent,args):
|
def __init__(self,parent,args):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.handle_args(args)
|
self.args = args
|
||||||
|
|
||||||
|
self.open = None
|
||||||
|
self.exports = []
|
||||||
|
self.actions = []
|
||||||
|
self.imports = []
|
||||||
|
|
||||||
|
self.parse_args()
|
||||||
|
self.handle_args()
|
||||||
|
|
||||||
|
def parse_args(self):
|
||||||
|
"""
|
||||||
|
Fill in lists with open, exports, imports, and actions options.
|
||||||
|
"""
|
||||||
|
|
||||||
def handle_args(self,args):
|
|
||||||
try:
|
try:
|
||||||
options,leftargs = getopt.getopt(args,
|
options,leftargs = getopt.getopt(self.args[1:],
|
||||||
const.shortopts,const.longopts)
|
const.shortopts,const.longopts)
|
||||||
except getopt.GetoptError,msg:
|
except getopt.GetoptError:
|
||||||
print "Error: %s. Exiting." % msg
|
# return without filling anything if we could not parse the args
|
||||||
os._exit(1)
|
print "Error parsing arguments: %s " % self.args[1:]
|
||||||
except:
|
return
|
||||||
print "Error parsing arguments: %s " % args
|
|
||||||
if leftargs:
|
if leftargs:
|
||||||
print "Unrecognized option: %s" % leftargs[0]
|
# if there were an argument without option, use it as a file to
|
||||||
os._exit(1)
|
# open and return
|
||||||
exports = []
|
self.open = leftargs[0]
|
||||||
actions = []
|
print "Trying to open: %s ..." % leftargs[0]
|
||||||
imports = []
|
return
|
||||||
|
|
||||||
for opt_ix in range(len(options)):
|
for opt_ix in range(len(options)):
|
||||||
o = options[opt_ix][0][1]
|
o,v = options[opt_ix]
|
||||||
if o == '-':
|
if o in ( '-i', '--import'):
|
||||||
continue
|
fname = v
|
||||||
elif o == 'i':
|
ftype = GrampsMime.get_type(os.path.abspath(os.path.expanduser(fname)))
|
||||||
fname = options[opt_ix][1]
|
if opt_ix<len(options)-1 \
|
||||||
if opt_ix<len(options)-1 and options[opt_ix+1][0][1]=='f':
|
and options[opt_ix+1][0] in ( '-f', '--format'):
|
||||||
format = options[opt_ix+1][1]
|
format = options[opt_ix+1][1]
|
||||||
if format not in [ 'gedcom', 'gramps', 'gramps-pkg' ]:
|
if format not in ('gedcom','gramps-xml','gramps-pkg','grdb'):
|
||||||
print "Invalid format: %s" % format
|
print "Invalid format: %s" % format
|
||||||
os._exit(1)
|
print "Ignoring input file: %s" % fname
|
||||||
elif fname[-3:].upper()== "GED":
|
continue
|
||||||
|
elif ftype == "application/x-gedcom":
|
||||||
format = 'gedcom'
|
format = 'gedcom'
|
||||||
elif fname[-3:].upper() == "TGZ":
|
elif ftype == "application/x-gramps-package":
|
||||||
format = 'gramps-pkg'
|
format = 'gramps-pkg'
|
||||||
elif os.path.isdir(fname):
|
elif ftype == "x-directory/normal":
|
||||||
format = 'gramps'
|
format = 'gramps-xml'
|
||||||
|
elif ftype == "application/x-gramps":
|
||||||
|
format = 'grdb'
|
||||||
else:
|
else:
|
||||||
print "Unrecognized format for input file %s" % fname
|
print "Unrecognized format for input file %s" % fname
|
||||||
os._exit(1)
|
print "Ignoring input file: %s" % fname
|
||||||
imports.append((fname,format))
|
continue
|
||||||
elif o == 'o':
|
self.imports.append((fname,format))
|
||||||
outfname = options[opt_ix][1]
|
elif o in ( '-o', '--output' ):
|
||||||
if opt_ix<len(options)-1 and options[opt_ix+1][0][1]=='f':
|
outfname = v
|
||||||
|
if opt_ix<len(options)-1 \
|
||||||
|
and options[opt_ix+1][0] in ( '-f', '--format'):
|
||||||
outformat = options[opt_ix+1][1]
|
outformat = options[opt_ix+1][1]
|
||||||
if outformat not in [ 'gedcom', 'gramps', 'gramps-pkg', 'iso', 'wft' ]:
|
if outformat not in ('gedcom','gramps-xml','gramps-pkg','grdb','iso','wft'):
|
||||||
print "Invalid format: %s" % outformat
|
print "Invalid format: %s" % outformat
|
||||||
os._exit(1)
|
print "Ignoring output file: %s" % outfname
|
||||||
|
continue
|
||||||
elif outfname[-3:].upper() == "GED":
|
elif outfname[-3:].upper() == "GED":
|
||||||
outformat = 'gedcom'
|
outformat = 'gedcom'
|
||||||
elif outfname[-3:].upper() == "TGZ":
|
elif outfname[-3:].upper() == "TGZ":
|
||||||
@ -110,69 +156,118 @@ class ArgHandler:
|
|||||||
os.makedirs(outfname,0700)
|
os.makedirs(outfname,0700)
|
||||||
except:
|
except:
|
||||||
print "Cannot create directory %s" % outfname
|
print "Cannot create directory %s" % outfname
|
||||||
os._exit(1)
|
print "Ignoring output file: %s" % outfname
|
||||||
outformat = 'gramps'
|
continue
|
||||||
|
outformat = 'gramps-xml'
|
||||||
|
elif fname[-3:].upper() == "GRDB":
|
||||||
|
format = 'grdb'
|
||||||
else:
|
else:
|
||||||
print "Unrecognized format for output file %s" % outfname
|
print "Unrecognized format for output file %s" % outfname
|
||||||
os._exit(1)
|
print "Ignoring output file: %s" % outfname
|
||||||
exports.append((outfname,outformat))
|
continue
|
||||||
elif o == 'a':
|
self.exports.append((outfname,outformat))
|
||||||
action = options[opt_ix][1]
|
elif o in ( '-a', '--action' ):
|
||||||
if action not in [ 'check', 'summary' ]:
|
action = v
|
||||||
print "Unknown action: %s." % action
|
if action not in ( 'check', 'summary' ):
|
||||||
os._exit(1)
|
print "Unknown action: %s. Ignoring." % action
|
||||||
actions.append(action)
|
continue
|
||||||
|
self.actions.append(action)
|
||||||
|
|
||||||
if imports:
|
def handle_args(self):
|
||||||
self.parent.cl = bool(exports or actions)
|
"""
|
||||||
# Create dir for imported database(s)
|
Depending on the given arguments, import or open data, launch
|
||||||
self.impdir_path = os.path.expanduser("~/.gramps/import" )
|
session, write files, and/or perform actions.
|
||||||
if not os.path.isdir(self.impdir_path):
|
"""
|
||||||
try:
|
|
||||||
os.mkdir(self.impdir_path,0700)
|
if self.open:
|
||||||
except:
|
# Filename was given. Open a session with that file. Forget
|
||||||
print "Could not create import directory %s. Exiting." \
|
# the rest of given arguments.
|
||||||
% self.impdir_path
|
filename = os.path.abspath(os.path.expanduser(self.open))
|
||||||
os._exit(1)
|
filetype = GrampsMime.get_type(filename)
|
||||||
elif not os.access(self.impdir_path,os.W_OK):
|
if filetype == "application/x-gramps":
|
||||||
print "Import directory %s is not writable. Exiting." \
|
print "Type: GRAMPS database"
|
||||||
% self.impdir_path
|
if self.parent.auto_save_load(filename):
|
||||||
os._exit(1)
|
print "Opened successfully!"
|
||||||
# and clean it up before use
|
|
||||||
files = os.listdir(self.impdir_path) ;
|
|
||||||
for fn in files:
|
|
||||||
if os.path.isfile(os.path.join(self.impdir_path,fn)):
|
|
||||||
os.remove(os.path.join(self.impdir_path,fn))
|
|
||||||
self.parent.clear_database()
|
|
||||||
self.parent.db.set_save_path(self.impdir_path)
|
|
||||||
for imp in imports:
|
|
||||||
print "Importing: file %s, format %s." % (imp[0],imp[1])
|
|
||||||
self.cl_import(imp[0],imp[1])
|
|
||||||
else:
|
else:
|
||||||
print "No data was given. Launching interactive session."
|
print "Cannot open %s. Exiting..."
|
||||||
|
elif filetype == "application/x-gedcom":
|
||||||
|
print "Type: GEDCOM"
|
||||||
|
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)
|
||||||
|
DbPrompter.DbPrompter(self.parent,1,self.parent.topWindow,filename)
|
||||||
|
self.parent.read_gedcom(filename)
|
||||||
|
elif filetype == "x-directory/normal":
|
||||||
|
print "Type: GRAMPS XML"
|
||||||
|
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)
|
||||||
|
DbPrompter.DbPrompter(self.parent,1,self.parent.topWindow,filename)
|
||||||
|
self.parent.read_xml(filename)
|
||||||
|
elif filetype == "application/x-gramps-package":
|
||||||
|
print "Type: 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)
|
||||||
|
DbPrompter.DbPrompter(self.parent,1,self.parent.topWindow,filename)
|
||||||
|
self.parent.read_pkg(filename)
|
||||||
|
else:
|
||||||
|
print "Unknown file type: %s" % filetype
|
||||||
|
QuestionDialog.ErrorDialog(
|
||||||
|
_("Cannot open file: unknown type"),
|
||||||
|
_('File type "%s" is unknown to GRAMPS.\n\nValid types are: GRAMPS database, GRAMPS XML, GRAMPS package, and GEDCOM.') % filetype,
|
||||||
|
self.parent.topWindow)
|
||||||
|
print "Exiting..."
|
||||||
|
os._exit(1)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.imports:
|
||||||
|
self.parent.cl = bool(self.exports or self.actions)
|
||||||
|
# Create file for imported database(s)
|
||||||
|
self.imp_db_path = os.path.expanduser("~/.gramps/import_db" )
|
||||||
|
# remove if it exists
|
||||||
|
if os.path.isdir(self.imp_db_path):
|
||||||
|
os.removedirs(self.imp_db_path)
|
||||||
|
elif os.path.isfile(self.imp_db_path):
|
||||||
|
os.remove(self.imp_db_path)
|
||||||
|
self.parent.load_database(self.imp_db_path)
|
||||||
|
|
||||||
|
for imp in self.imports:
|
||||||
|
print "Importing: file %s, format %s." % imp #(imp[0],imp[1])
|
||||||
|
self.cl_import(imp[0],imp[1])
|
||||||
|
elif len(self.args) > 1:
|
||||||
|
print "No data was given -- will launch interactive session."
|
||||||
print "To use in the command-line mode,", \
|
print "To use in the command-line mode,", \
|
||||||
"supply at least one input file to process."
|
"supply at least one input file to process."
|
||||||
|
print "Launching interactive session..."
|
||||||
|
|
||||||
if self.parent.cl:
|
if self.parent.cl:
|
||||||
for expt in exports:
|
for expt in self.exports:
|
||||||
print "Exporting: file %s, format %s." % (expt[0],expt[1])
|
print "Exporting: file %s, format %s." % expt #(expt[0],expt[1])
|
||||||
self.cl_export(expt[0],expt[1])
|
self.cl_export(expt[0],expt[1])
|
||||||
|
|
||||||
for action in actions:
|
for action in self.actions:
|
||||||
print "Performing action: %s." % action
|
print "Performing action: %s." % action
|
||||||
self.cl_action(action)
|
self.cl_action(action)
|
||||||
|
|
||||||
print "Cleaning up."
|
print "Cleaning up."
|
||||||
# clean import dir up after use
|
# remove import db after use
|
||||||
files = os.listdir(self.impdir_path) ;
|
os.remove(self.imp_db_path)
|
||||||
for fn in files:
|
|
||||||
if os.path.isfile(os.path.join(self.impdir_path,fn)):
|
|
||||||
os.remove(os.path.join(self.impdir_path,fn))
|
|
||||||
print "Exiting."
|
print "Exiting."
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
elif GrampsCfg.lastfile and GrampsCfg.autoload:
|
||||||
|
if self.parent.auto_save_load(GrampsCfg.lastfile) == 0:
|
||||||
|
DbPrompter.DbPrompter(self.parent,0,self.parent.topWindow)
|
||||||
|
else:
|
||||||
|
DbPrompter.DbPrompter(self.parent,0,self.parent.topWindow)
|
||||||
|
|
||||||
|
|
||||||
def cl_import(self,filename,format):
|
def cl_import(self,filename,format):
|
||||||
|
"""
|
||||||
|
Command-line import routine. Try to import filename using the format.
|
||||||
|
Any errors will cause the os._exit(1) call.
|
||||||
|
"""
|
||||||
if format == 'gedcom':
|
if format == 'gedcom':
|
||||||
import ReadGedcom
|
import ReadGedcom
|
||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
@ -184,7 +279,7 @@ class ArgHandler:
|
|||||||
except:
|
except:
|
||||||
print "Error importing %s" % filename
|
print "Error importing %s" % filename
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
elif format == 'gramps':
|
elif format == 'gramps-xml':
|
||||||
try:
|
try:
|
||||||
dbname = os.path.join(filename,const.xmlFile)
|
dbname = os.path.join(filename,const.xmlFile)
|
||||||
ReadXML.importData(self.parent.db,dbname,None,self.parent.cl)
|
ReadXML.importData(self.parent.db,dbname,None,self.parent.cl)
|
||||||
@ -233,9 +328,14 @@ class ArgHandler:
|
|||||||
print "Invalid format: %s" % format
|
print "Invalid format: %s" % format
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
if not self.parent.cl:
|
if not self.parent.cl:
|
||||||
return self.parent.post_load(self.impdir_path)
|
return self.parent.post_load(self.imp_db_path)
|
||||||
|
|
||||||
def cl_export(self,filename,format):
|
def cl_export(self,filename,format):
|
||||||
|
"""
|
||||||
|
Command-line export routine.
|
||||||
|
Try to write into filename using the format.
|
||||||
|
Any errors will cause the os._exit(1) call.
|
||||||
|
"""
|
||||||
if format == 'gedcom':
|
if format == 'gedcom':
|
||||||
import WriteGedcom
|
import WriteGedcom
|
||||||
try:
|
try:
|
||||||
@ -244,7 +344,7 @@ class ArgHandler:
|
|||||||
except:
|
except:
|
||||||
print "Error exporting %s" % filename
|
print "Error exporting %s" % filename
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
elif format == 'gramps':
|
elif format == 'gramps-xml':
|
||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
dbname = os.path.join(filename,const.xmlFile)
|
dbname = os.path.join(filename,const.xmlFile)
|
||||||
if filename:
|
if filename:
|
||||||
@ -315,6 +415,10 @@ class ArgHandler:
|
|||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
def cl_action(self,action):
|
def cl_action(self,action):
|
||||||
|
"""
|
||||||
|
Command-line action routine. Try to perform specified action.
|
||||||
|
Any errors will cause the os._exit(1) call.
|
||||||
|
"""
|
||||||
if action == 'check':
|
if action == 'check':
|
||||||
import Check
|
import Check
|
||||||
checker = Check.CheckIntegrity(self.parent.db)
|
checker = Check.CheckIntegrity(self.parent.db)
|
||||||
|
@ -20,6 +20,14 @@
|
|||||||
|
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Python modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
import os
|
||||||
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GNOME modules
|
# GNOME modules
|
||||||
@ -28,6 +36,7 @@
|
|||||||
import gtk
|
import gtk
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
import gobject
|
import gobject
|
||||||
|
import gnome
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -37,10 +46,7 @@ import gobject
|
|||||||
import Utils
|
import Utils
|
||||||
import const
|
import const
|
||||||
import GrampsCfg
|
import GrampsCfg
|
||||||
import gnome
|
|
||||||
import QuestionDialog
|
import QuestionDialog
|
||||||
from gettext import gettext as _
|
|
||||||
import os
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -50,12 +56,13 @@ import os
|
|||||||
class DbPrompter:
|
class DbPrompter:
|
||||||
"""Make sure a database is opened"""
|
"""Make sure a database is opened"""
|
||||||
|
|
||||||
def __init__(self,db,want_new,parent=None):
|
def __init__(self,parent,want_new,parent_window=None,file_hint=None):
|
||||||
self.db = db
|
self.parent = parent
|
||||||
|
self.file_hint = file_hint
|
||||||
opendb = gtk.glade.XML(const.gladeFile, "opendb","gramps")
|
opendb = gtk.glade.XML(const.gladeFile, "opendb","gramps")
|
||||||
top = opendb.get_widget('opendb')
|
top = opendb.get_widget('opendb')
|
||||||
if parent:
|
if parent_window:
|
||||||
top.set_transient_for(parent)
|
top.set_transient_for(parent_window)
|
||||||
title = opendb.get_widget('title')
|
title = opendb.get_widget('title')
|
||||||
|
|
||||||
Utils.set_titles(top,title,_('Open a database'))
|
Utils.set_titles(top,title,_('Open a database'))
|
||||||
@ -89,7 +96,7 @@ class DbPrompter:
|
|||||||
gtk.RESPONSE_CANCEL,
|
gtk.RESPONSE_CANCEL,
|
||||||
gtk.STOCK_OPEN,
|
gtk.STOCK_OPEN,
|
||||||
gtk.RESPONSE_OK))
|
gtk.RESPONSE_OK))
|
||||||
self.db.clear_database()
|
self.parent.clear_database()
|
||||||
else:
|
else:
|
||||||
choose = gtk.FileChooserDialog('Open GRAMPS database',
|
choose = gtk.FileChooserDialog('Open GRAMPS database',
|
||||||
None,
|
None,
|
||||||
@ -109,7 +116,10 @@ class DbPrompter:
|
|||||||
filter.add_pattern('*')
|
filter.add_pattern('*')
|
||||||
choose.add_filter(filter)
|
choose.add_filter(filter)
|
||||||
|
|
||||||
if save and GrampsCfg.lastfile:
|
if save:
|
||||||
|
if self.file_hint:
|
||||||
|
choose.set_filename(self.file_hint)
|
||||||
|
elif GrampsCfg.lastfile:
|
||||||
choose.set_filename(GrampsCfg.lastfile)
|
choose.set_filename(GrampsCfg.lastfile)
|
||||||
|
|
||||||
response = choose.run()
|
response = choose.run()
|
||||||
@ -118,9 +128,8 @@ class DbPrompter:
|
|||||||
if save and os.path.splitext(filename)[1] != ".grdb":
|
if save and os.path.splitext(filename)[1] != ".grdb":
|
||||||
filename = filename + ".grdb"
|
filename = filename + ".grdb"
|
||||||
choose.destroy()
|
choose.destroy()
|
||||||
self.db.read_file(filename)
|
self.parent.read_file(filename)
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
choose.destroy()
|
choose.destroy()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -149,6 +149,14 @@ unknown = _("unknown")
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# (longName, shortName, type , default, flags, descrip , argDescrip)
|
||||||
|
popt_table = [
|
||||||
|
("import", 'i', str, None, 0, "Import file", "FILENAME"),
|
||||||
|
("output", 'o', str, None, 0, "Write file", "FILENAME"),
|
||||||
|
("format", 'f', str, None, 0, 'Specify format', "FORMAT"),
|
||||||
|
("action", 'a', str, None, 0, 'Specify action', "ACTION"),
|
||||||
|
]
|
||||||
|
|
||||||
longopts = [
|
longopts = [
|
||||||
"load-modules=",
|
"load-modules=",
|
||||||
"help",
|
"help",
|
||||||
@ -160,6 +168,28 @@ longopts = [
|
|||||||
"enable-sound",
|
"enable-sound",
|
||||||
"espeaker=",
|
"espeaker=",
|
||||||
"version",
|
"version",
|
||||||
|
"gdk-debug=",
|
||||||
|
"gdk-no-debug=",
|
||||||
|
"display=",
|
||||||
|
"screen=",
|
||||||
|
"sync",
|
||||||
|
"name=",
|
||||||
|
"class=",
|
||||||
|
"gtk-debug=",
|
||||||
|
"gtk-no-debug=",
|
||||||
|
"g-fatal-warnings",
|
||||||
|
"gtk-module=",
|
||||||
|
"sm-client-id=",
|
||||||
|
"sm-config-prefix=",
|
||||||
|
"sm-disable",
|
||||||
|
"disable-crash-dialog",
|
||||||
|
"disable-sound",
|
||||||
|
"enable-sound",
|
||||||
|
"espeaker=",
|
||||||
|
"import=",
|
||||||
|
"output=",
|
||||||
|
"format=",
|
||||||
|
"action=",
|
||||||
]
|
]
|
||||||
|
|
||||||
shortopts = "i:o:f:a:?"
|
shortopts = "i:o:f:a:?"
|
||||||
|
@ -12,7 +12,7 @@ dist_pkgdata_DATA = gedcom.xml \
|
|||||||
gramps.keys \
|
gramps.keys \
|
||||||
gramps.mime
|
gramps.mime
|
||||||
|
|
||||||
EXTRA_DIST = $(pkgdata_DATA)
|
EXTRA_DIST = $(dist_pkgdata_DATA)
|
||||||
|
|
||||||
install-data-local:
|
install-data-local:
|
||||||
$(INSTALL) -d $(DESTDIR)$(prefix)/share/gnome/apps/Applications
|
$(INSTALL) -d $(DESTDIR)$(prefix)/share/gnome/apps/Applications
|
||||||
|
@ -4,4 +4,4 @@ gramps
|
|||||||
can_open_multiple_files=false
|
can_open_multiple_files=false
|
||||||
expects_uris=false
|
expects_uris=false
|
||||||
requires_terminal=false
|
requires_terminal=false
|
||||||
mime_types=application/x-gramps,application/x-gedcom
|
mime_types=application/x-gramps,application/x-gedcom,application/x-gramps-package
|
||||||
|
@ -8,4 +8,8 @@
|
|||||||
<comment xml:lang="en">GEDCOM</comment>
|
<comment xml:lang="en">GEDCOM</comment>
|
||||||
<glob pattern="*.ged"/>
|
<glob pattern="*.ged"/>
|
||||||
</mime-type>
|
</mime-type>
|
||||||
|
<mime-type type="application/x-gramps-package">
|
||||||
|
<comment xml:lang="en">GRAMPS package</comment>
|
||||||
|
<glob pattern="*.gpkg"/>
|
||||||
|
</mime-type>
|
||||||
</mime-info>
|
</mime-info>
|
||||||
|
@ -82,7 +82,7 @@ import gobject
|
|||||||
|
|
||||||
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
||||||
|
|
||||||
args = sys.argv[1:]
|
args = sys.argv
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
try:
|
try:
|
||||||
|
@ -70,6 +70,7 @@ import EditPerson
|
|||||||
import Find
|
import Find
|
||||||
import DbPrompter
|
import DbPrompter
|
||||||
import TipOfDay
|
import TipOfDay
|
||||||
|
import ArgHandler
|
||||||
|
|
||||||
from QuestionDialog import *
|
from QuestionDialog import *
|
||||||
|
|
||||||
@ -104,7 +105,9 @@ class Gramps:
|
|||||||
|
|
||||||
def __init__(self,args):
|
def __init__(self,args):
|
||||||
|
|
||||||
self.program = gnome.program_init('gramps',const.version)
|
self.program = gnome.program_init('gramps',const.version,
|
||||||
|
gnome.libgnome_module_info_get(),
|
||||||
|
args, const.popt_table)
|
||||||
self.program.set_property('app-libdir','%s/lib' % const.prefixdir)
|
self.program.set_property('app-libdir','%s/lib' % const.prefixdir)
|
||||||
self.program.set_property('app-datadir','%s/share/gramps' % const.prefixdir)
|
self.program.set_property('app-datadir','%s/share/gramps' % const.prefixdir)
|
||||||
self.program.set_property('app-sysconfdir','%s/etc' % const.prefixdir)
|
self.program.set_property('app-sysconfdir','%s/etc' % const.prefixdir)
|
||||||
@ -144,25 +147,11 @@ class Gramps:
|
|||||||
self.gtop = gtk.glade.XML(const.gladeFile, "gramps", "gramps")
|
self.gtop = gtk.glade.XML(const.gladeFile, "gramps", "gramps")
|
||||||
self.init_interface()
|
self.init_interface()
|
||||||
|
|
||||||
|
ArgHandler.ArgHandler(self,args)
|
||||||
|
|
||||||
if GrampsCfg.usetips:
|
if GrampsCfg.usetips:
|
||||||
TipOfDay.TipOfDay()
|
TipOfDay.TipOfDay()
|
||||||
|
|
||||||
if args and len(args)==1:
|
|
||||||
if GrampsMime.get_type(args[0]) == "application/x-gramps":
|
|
||||||
if self.auto_save_load(args[0]) == 0:
|
|
||||||
DbPrompter.DbPrompter(self,0,self.topWindow)
|
|
||||||
else:
|
|
||||||
import ArgHandler
|
|
||||||
ArgHandler.ArgHandler(self,args)
|
|
||||||
elif args:
|
|
||||||
import ArgHandler
|
|
||||||
ArgHandler.ArgHandler(self,args)
|
|
||||||
elif GrampsCfg.lastfile and GrampsCfg.autoload:
|
|
||||||
if self.auto_save_load(GrampsCfg.lastfile) == 0:
|
|
||||||
DbPrompter.DbPrompter(self,0,self.topWindow)
|
|
||||||
else:
|
|
||||||
DbPrompter.DbPrompter(self,0,self.topWindow)
|
|
||||||
|
|
||||||
self.db.set_researcher(GrampsCfg.get_researcher())
|
self.db.set_researcher(GrampsCfg.get_researcher())
|
||||||
|
|
||||||
def pref_callback(self,val):
|
def pref_callback(self,val):
|
||||||
@ -1033,12 +1022,64 @@ class Gramps:
|
|||||||
import ReadGedcom
|
import ReadGedcom
|
||||||
|
|
||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
self.topWindow.set_title("%s - GRAMPS" % filename)
|
|
||||||
try:
|
try:
|
||||||
ReadGedcom.importData(self.db,filename)
|
ReadGedcom.importData(self.db,filename,None)
|
||||||
|
self.import_tool_callback()
|
||||||
except:
|
except:
|
||||||
DisplayTrace.DisplayTrace()
|
DisplayTrace.DisplayTrace()
|
||||||
self.full_update()
|
|
||||||
|
def read_xml(self,filename):
|
||||||
|
import ReadXML
|
||||||
|
|
||||||
|
filename = os.path.normpath(os.path.abspath(os.path.join(filename,const.xmlFile)))
|
||||||
|
|
||||||
|
try:
|
||||||
|
ReadXML.importData(self.db,filename,None)
|
||||||
|
self.import_tool_callback()
|
||||||
|
except:
|
||||||
|
DisplayTrace.DisplayTrace()
|
||||||
|
|
||||||
|
def read_pkg(self,filename):
|
||||||
|
# Create tempdir, if it does not exist, then check for writability
|
||||||
|
tmpdir_path = os.path.expanduser("~/.gramps/tmp" )
|
||||||
|
if not os.path.isdir(tmpdir_path):
|
||||||
|
try:
|
||||||
|
os.mkdir(tmpdir_path,0700)
|
||||||
|
except:
|
||||||
|
DisplayTrace.DisplayTrace()
|
||||||
|
return
|
||||||
|
elif not os.access(tmpdir_path,os.W_OK):
|
||||||
|
ErrorDialog( _("Cannot unpak archive"),
|
||||||
|
_("Temporary directory %s is not writable") % tmpdir_path )
|
||||||
|
return
|
||||||
|
else: # tempdir exists and writable -- clean it up if not empty
|
||||||
|
files = os.listdir(tmpdir_path) ;
|
||||||
|
for fn in files:
|
||||||
|
os.remove( os.path.join(tmpdir_path,fn) )
|
||||||
|
|
||||||
|
try:
|
||||||
|
import TarFile
|
||||||
|
t = TarFile.ReadTarFile(filename,tmpdir_path)
|
||||||
|
t.extract()
|
||||||
|
t.close()
|
||||||
|
except:
|
||||||
|
DisplayTrace.DisplayTrace()
|
||||||
|
return
|
||||||
|
|
||||||
|
dbname = os.path.join(tmpdir_path,const.xmlFile)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import ReadXML
|
||||||
|
ReadXML.importData(self.db,dbname,None)
|
||||||
|
except:
|
||||||
|
DisplayTrace.DisplayTrace()
|
||||||
|
|
||||||
|
# Clean up tempdir after ourselves
|
||||||
|
files = os.listdir(tmpdir_path)
|
||||||
|
for fn in files:
|
||||||
|
os.remove(os.path.join(tmpdir_path,fn))
|
||||||
|
os.rmdir(tmpdir_path)
|
||||||
|
self.import_tool_callback()
|
||||||
|
|
||||||
def read_file(self,filename):
|
def read_file(self,filename):
|
||||||
self.topWindow.set_resizable(gtk.FALSE)
|
self.topWindow.set_resizable(gtk.FALSE)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2003 Donald N. Allingham
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -18,6 +18,8 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
#
|
#
|
||||||
# Modified by Alex Roitman to handle media object files.
|
# Modified by Alex Roitman to handle media object files.
|
||||||
#
|
#
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000 Donald N. Allingham
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -18,6 +18,8 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
#
|
#
|
||||||
# Written by Alex Roitman, largely based on ReadNative.py by Don Allingham
|
# Written by Alex Roitman, largely based on ReadNative.py by Don Allingham
|
||||||
#
|
#
|
||||||
|
@ -93,7 +93,7 @@ class PackageWriter:
|
|||||||
|
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
name = choose.get_filename()
|
name = choose.get_filename()
|
||||||
if os.path.splitext(filename)[1] != ".gpkg":
|
if os.path.splitext(name)[1] != ".gpkg":
|
||||||
name = name + ".gpkg"
|
name = name + ".gpkg"
|
||||||
choose.destroy()
|
choose.destroy()
|
||||||
self.export(name)
|
self.export(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user