Command line parameters
svn: r1536
This commit is contained in:
parent
b2e5c516b8
commit
fc1daf4b66
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000 Donald N. Allingham
|
||||
# Copyright (C) 2000-2003 Donald N. Allingham
|
||||
#
|
||||
# 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
|
||||
@ -41,10 +41,10 @@ def need_to_run():
|
||||
|
||||
class StartupDialog:
|
||||
|
||||
def __init__(self,task,arg):
|
||||
def __init__(self,task,args):
|
||||
|
||||
self.task = task
|
||||
self.arg = arg
|
||||
self.args = args
|
||||
|
||||
self.w = gtk.Window()
|
||||
self.fg_color = gtk.gdk.color_parse('#7d684a')
|
||||
@ -69,7 +69,7 @@ class StartupDialog:
|
||||
self.w.show_all()
|
||||
|
||||
def close(self,obj):
|
||||
self.task(self.arg)
|
||||
self.task(self.args)
|
||||
|
||||
def build_page1(self):
|
||||
p = gnome.ui.DruidPageEdge(0)
|
||||
@ -130,7 +130,7 @@ class StartupDialog:
|
||||
self.client.set_int("/apps/gramps/UseLDS",self.lds.get_active())
|
||||
self.client.set_int(_StartupEntry,const.startup)
|
||||
self.w.destroy()
|
||||
self.task(self.arg)
|
||||
self.task(self.args)
|
||||
|
||||
def build_page2(self):
|
||||
p = gnome.ui.DruidPageStandard()
|
||||
|
@ -134,6 +134,27 @@ male = _("male")
|
||||
female = _("female")
|
||||
unknown = _("unknown")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Options Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
longopts = [
|
||||
"load-modules=",
|
||||
"help",
|
||||
"usage",
|
||||
"oaf-ior-fd=",
|
||||
"oaf-activate-iid=",
|
||||
"oaf-private",
|
||||
"disable-sound",
|
||||
"enable-sound",
|
||||
"espeaker=",
|
||||
"version",
|
||||
]
|
||||
|
||||
shortopts = "i:o:f:a:?"
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
|
@ -1,4 +1,23 @@
|
||||
#! /usr/bin/python -O
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2003 Donald N. Allinghamg
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
import sys
|
||||
import os
|
||||
@ -43,18 +62,15 @@ import gtk
|
||||
#-------------------------------------------------------------------------
|
||||
import gramps_main
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
arg = sys.argv[1]
|
||||
else:
|
||||
arg = None
|
||||
args = sys.argv[1:]
|
||||
|
||||
try:
|
||||
import StartupDialog
|
||||
|
||||
if StartupDialog.need_to_run():
|
||||
StartupDialog.StartupDialog(gramps_main.Gramps,arg)
|
||||
StartupDialog.StartupDialog(gramps_main.Gramps,args)
|
||||
else:
|
||||
gramps_main.Gramps(arg)
|
||||
gramps_main.Gramps(args)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -1,8 +1,7 @@
|
||||
#! /usr/bin/python -O
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000 Donald N. Allinghamg
|
||||
# Copyright (C) 2000-2003 Donald N. Allinghamg
|
||||
#
|
||||
# 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
|
||||
@ -26,6 +25,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
import string
|
||||
import os
|
||||
import getopt
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -97,7 +97,7 @@ _sel_mode = gtk.SELECTION_MULTIPLE
|
||||
#-------------------------------------------------------------------------
|
||||
class Gramps:
|
||||
|
||||
def __init__(self,arg):
|
||||
def __init__(self,args):
|
||||
|
||||
self.pl_titles = [ (_('Name'),5,250), (_('ID'),1,50),(_('Gender'),2,70),
|
||||
(_('Birth date'),6,150),(_('Death date'),7,150), ('',5,0),
|
||||
@ -140,11 +140,66 @@ class Gramps:
|
||||
self.relationship = Plugins.relationship_function()
|
||||
self.init_interface()
|
||||
|
||||
if arg != None:
|
||||
if string.upper(arg[-3:]) == "GED":
|
||||
self.read_gedcom(arg)
|
||||
else:
|
||||
self.read_file(arg)
|
||||
self.cl = 0
|
||||
if args:
|
||||
options,leftargs = getopt.getopt(args,
|
||||
const.shortopts,const.longopts)
|
||||
if leftargs:
|
||||
print "Unrecognized option: %s" % leftargs[0]
|
||||
return
|
||||
outfile = ''
|
||||
action = ''
|
||||
for opt_ix in range(len(options)):
|
||||
o = options[opt_ix][0][1]
|
||||
if o == '-':
|
||||
continue
|
||||
elif o == 'i':
|
||||
fname = options[opt_ix][1]
|
||||
if opt_ix<len(options)-1 and options[opt_ix+1][0][1]=='f':
|
||||
format = options[opt_ix+1][1]
|
||||
if format not in [ 'gedcom', 'gramps', 'gramps-pkg' ]:
|
||||
print "Invalid format: %s" % format
|
||||
return
|
||||
elif string.upper(fname[-3:]) == "GED":
|
||||
format = 'gedcom'
|
||||
elif string.upper(fname[-3:]) == "TGZ":
|
||||
format = 'gramps-pkg'
|
||||
elif os.path.isdir(fname):
|
||||
format = 'gramps'
|
||||
else:
|
||||
print "Unrecognized format for input file %s" % fname
|
||||
return
|
||||
self.cl_import(fname,format)
|
||||
elif o == 'o':
|
||||
outfname = options[opt_ix][1]
|
||||
if opt_ix<len(options)-1 and options[opt_ix+1][0][1]=='f':
|
||||
outformat = options[opt_ix+1][1]
|
||||
if outformat not in [ 'gedcom', 'gramps', 'gramps-pkg', 'iso' ]:
|
||||
print "Invalid format: %s" % outformat
|
||||
return
|
||||
elif string.upper(outfname[-3:]) == "GED":
|
||||
outformat = 'gedcom'
|
||||
elif string.upper(outfname[-3:]) == "TGZ":
|
||||
outformat = 'gramps-pkg'
|
||||
elif os.path.isdir(outfname):
|
||||
outformat = 'gramps'
|
||||
else:
|
||||
print "Unrecognized format for output file %s" % outfname
|
||||
return
|
||||
elif o == 'a':
|
||||
action = options[opt_ix][1]
|
||||
|
||||
if outfname:
|
||||
self.cl_export(outfname,outformat)
|
||||
self.cl = 1
|
||||
|
||||
if action:
|
||||
self.cl_action(action)
|
||||
self.cl = 1
|
||||
|
||||
if self.cl:
|
||||
os._exit(0)
|
||||
|
||||
elif GrampsCfg.lastfile and GrampsCfg.autoload:
|
||||
self.auto_save_load(GrampsCfg.lastfile)
|
||||
else:
|
||||
@ -832,6 +887,15 @@ class Gramps:
|
||||
GrampsCfg.save_last_file("")
|
||||
self.topWindow.set_resizable(gtk.TRUE)
|
||||
|
||||
def cl_import(self,filename,format):
|
||||
pass
|
||||
|
||||
def cl_export(self,filename,format):
|
||||
pass
|
||||
|
||||
def cl_action(self,action):
|
||||
pass
|
||||
|
||||
def on_ok_button2_clicked(self,obj):
|
||||
filename = obj.get_filename()
|
||||
filename = os.path.normpath(os.path.abspath(filename))
|
||||
|
Loading…
Reference in New Issue
Block a user