# # Gramps - a GTK+/GNOME based genealogy program # # 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 # 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 # # $Id$ # # Written by Alex Roitman # """ Module responsible for handling the command line arguments for GRAMPS. """ #------------------------------------------------------------------------- # # Standard python modules # #------------------------------------------------------------------------- import os import getopt #------------------------------------------------------------------------- # # gramps modules # #------------------------------------------------------------------------- import const import ReadXML #------------------------------------------------------------------------- # # ArgHandler # #------------------------------------------------------------------------- class ArgHandler: def __init__(self,parent,args): self.parent = parent self.handle_args(args) def handle_args(self,args): try: options,leftargs = getopt.getopt(args, const.shortopts,const.longopts) except getopt.GetoptError,msg: print "Error: %s. Exiting." % msg os._exit(1) except: print "Error parsing arguments: %s " % args if leftargs: print "Unrecognized option: %s" % leftargs[0] os._exit(1) exports = [] actions = [] imports = [] 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