2003-10-13 07:25:56 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham, A. Roitman
|
2008-01-09 12:15:15 +05:30
|
|
|
# Copyright (C) 2007-2008 B. Malengier
|
2008-02-25 13:40:19 +05:30
|
|
|
# Copyright (C) 2008 Lukasz Rymarczyk
|
2003-10-13 07:25:56 +05:30
|
|
|
#
|
|
|
|
# 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$
|
|
|
|
|
|
|
|
"""
|
|
|
|
Module responsible for handling the command line arguments for GRAMPS.
|
|
|
|
"""
|
|
|
|
|
2006-04-21 09:44:00 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
2003-10-13 07:25:56 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
2007-01-22 09:26:23 +05:30
|
|
|
import sys
|
2003-10-13 07:25:56 +05:30
|
|
|
import getopt
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2007-02-13 04:03:03 +05:30
|
|
|
import logging
|
2003-10-13 07:25:56 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2007-02-03 22:41:05 +05:30
|
|
|
import GrampsDbUtils
|
2006-03-03 05:53:04 +05:30
|
|
|
import Mime
|
2008-02-18 15:39:50 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2006-03-03 05:40:52 +05:30
|
|
|
import Config
|
2004-11-25 11:12:31 +05:30
|
|
|
import RecentFiles
|
2006-04-21 09:44:00 +05:30
|
|
|
import Utils
|
2007-11-26 10:13:00 +05:30
|
|
|
import gen.db.exceptions as GX
|
2008-01-28 16:46:54 +05:30
|
|
|
from DbManager import CLIDbManager, NAME_FILE, find_locker_name
|
2006-04-21 09:44:00 +05:30
|
|
|
|
2006-05-31 07:33:29 +05:30
|
|
|
from PluginUtils import Tool, cl_list, cli_tool_list
|
|
|
|
from ReportBase import CATEGORY_BOOK, CATEGORY_CODE, CATEGORY_WEB, cl_report
|
2003-10-13 07:25:56 +05:30
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
IMPORT_TYPES = (const.APP_GRAMPS_XML, const.APP_GEDCOM,
|
|
|
|
const.APP_GRAMPS_PKG, const.APP_GENEWEB,
|
|
|
|
const.APP_GRAMPS)
|
2007-11-11 23:55:01 +05:30
|
|
|
|
2008-01-17 01:53:20 +05:30
|
|
|
_help = """
|
|
|
|
Usage: gramps.py [OPTION...]
|
|
|
|
--load-modules=MODULE1,MODULE2,... Dynamic modules to load
|
|
|
|
|
|
|
|
Help options
|
|
|
|
-?, --help Show this help message
|
|
|
|
--usage Display brief usage message
|
|
|
|
|
|
|
|
Application options
|
|
|
|
-O, --open=FAMILY_TREE Open family tree
|
|
|
|
-i, --import=FILENAME Import file
|
|
|
|
-o, --output=FILENAME Write file
|
|
|
|
-f, --format=FORMAT Specify format
|
|
|
|
-a, --action=ACTION Specify action
|
|
|
|
-p, --options=OPTIONS_STRING Specify options
|
|
|
|
-d, --debug=LOGGER_NAME Enable debug logs
|
2008-01-17 01:55:34 +05:30
|
|
|
-l List Family Trees
|
2008-01-28 16:46:54 +05:30
|
|
|
-u Force unlock of family tree
|
2008-01-17 01:53:20 +05:30
|
|
|
"""
|
|
|
|
|
2003-10-13 07:25:56 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# ArgHandler
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class ArgHandler:
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
|
|
|
This class is responsible for handling command line arguments (if any)
|
|
|
|
given to gramps. The valid arguments are:
|
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
FAMTREE : family tree name or database dir to open.
|
2004-06-21 10:40:27 +05:30
|
|
|
All following arguments will be ignored.
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
-O, --open=FAMTREE : Family tree or family tree database dir to open.
|
2004-06-21 10:40:27 +05:30
|
|
|
-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
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
launched using data from filename.
|
2005-01-30 05:04:09 +05:30
|
|
|
In this mode (filename, no flags), the rest of the arguments is ignored.
|
|
|
|
This is a mode suitable by default for GUI launchers, mime type handlers,
|
|
|
|
and the like
|
2004-06-21 10:40:27 +05:30
|
|
|
|
|
|
|
If no filename or -i option is given, a new interactive session (empty
|
2005-01-30 05:04:09 +05:30
|
|
|
database) is launched, since no data is given anyway.
|
2004-06-21 10:40:27 +05:30
|
|
|
|
2005-01-30 05:04:09 +05:30
|
|
|
If -O or -i option is given, but no -o or -a options are given, an
|
|
|
|
interactive session is launched with the FILE (specified with -i).
|
2004-06-21 10:40:27 +05:30
|
|
|
|
2005-01-30 05:04:09 +05:30
|
|
|
If both input (-O or -i) and processing (-o or -a) options are given,
|
|
|
|
interactive session will not be launched.
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
2003-10-13 07:25:56 +05:30
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
def __init__(self, state, vm, args):
|
2005-08-12 21:55:43 +05:30
|
|
|
self.state = state
|
|
|
|
self.vm = vm
|
2004-06-21 10:40:27 +05:30
|
|
|
self.args = args
|
|
|
|
|
2005-01-30 05:04:09 +05:30
|
|
|
self.open_gui = None
|
2004-06-21 10:40:27 +05:30
|
|
|
self.open = None
|
2006-04-11 00:00:30 +05:30
|
|
|
self.cl = 0
|
2004-06-21 10:40:27 +05:30
|
|
|
self.exports = []
|
|
|
|
self.actions = []
|
|
|
|
self.imports = []
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
self.imp_db_path = None
|
|
|
|
self.list = False
|
2008-01-17 01:53:20 +05:30
|
|
|
self.help = False
|
2008-01-28 16:46:54 +05:30
|
|
|
self.force_unlock = False
|
|
|
|
self.dbman = CLIDbManager(self.state)
|
2004-06-21 10:40:27 +05:30
|
|
|
|
|
|
|
self.parse_args()
|
|
|
|
|
2004-06-23 02:19:22 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Argument parser: sorts out given arguments
|
|
|
|
#-------------------------------------------------------------------------
|
2004-06-21 10:40:27 +05:30
|
|
|
def parse_args(self):
|
|
|
|
"""
|
|
|
|
Fill in lists with open, exports, imports, and actions options.
|
2006-05-22 23:37:12 +05:30
|
|
|
|
2008-01-17 03:12:05 +05:30
|
|
|
Any parsing errors lead to abort.
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
|
|
|
Possible:
|
|
|
|
1/ Just the family tree (name or database dir)
|
|
|
|
2/ -O, Open of a family tree
|
|
|
|
3/ -i, Import of any format understood by an importer, optionally provide
|
|
|
|
-f to indicate format (possible: 'gedcom','gramps-xml','gramps-pkg',
|
|
|
|
'grdb','geneweb'
|
|
|
|
4/ -o, output a family tree in required format, optionally provide
|
|
|
|
-f to indicate format (possible: 'gedcom',
|
|
|
|
'gramps-xml','gramps-pkg','iso','wft','geneweb')
|
2008-01-17 03:12:05 +05:30
|
|
|
5/ -a, --action: An action (possible: 'check', 'summary', 'report',
|
|
|
|
'tool')
|
2008-01-28 16:46:54 +05:30
|
|
|
6/ -u, --force-unlock: A locked database can be unlocked by given this
|
|
|
|
argument when opening it
|
2008-01-17 03:12:05 +05:30
|
|
|
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
2003-10-13 07:25:56 +05:30
|
|
|
try:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
options, leftargs = getopt.getopt(self.args[1:],
|
|
|
|
const.SHORTOPTS, const.LONGOPTS)
|
2008-01-17 01:53:20 +05:30
|
|
|
except getopt.GetoptError, msg:
|
|
|
|
print msg
|
2004-06-21 10:40:27 +05:30
|
|
|
# return without filling anything if we could not parse the args
|
2008-01-17 01:53:20 +05:30
|
|
|
print "Error parsing the arguments: %s " % self.args[1:]
|
|
|
|
print "Type gramps --help for an overview of commands, or ",
|
|
|
|
print "read manual pages."
|
|
|
|
sys.exit(0)
|
2004-06-21 10:40:27 +05:30
|
|
|
|
2003-10-13 07:25:56 +05:30
|
|
|
if leftargs:
|
2006-05-22 23:37:12 +05:30
|
|
|
# if there were an argument without option,
|
|
|
|
# use it as a file to open and return
|
2005-01-30 05:04:09 +05:30
|
|
|
self.open_gui = leftargs[0]
|
2004-06-21 10:40:27 +05:30
|
|
|
print "Trying to open: %s ..." % leftargs[0]
|
2008-01-28 16:46:54 +05:30
|
|
|
#see if force open is on
|
|
|
|
for opt_ix in range(len(options)):
|
|
|
|
option, value = options[opt_ix]
|
|
|
|
if option in ('-u', '--force-unlock'):
|
|
|
|
self.force_unlock = True
|
|
|
|
break
|
2004-06-21 10:40:27 +05:30
|
|
|
return
|
|
|
|
|
2006-05-22 23:37:12 +05:30
|
|
|
# Go over all given option and place them into appropriate lists
|
2003-10-13 07:25:56 +05:30
|
|
|
for opt_ix in range(len(options)):
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
option, value = options[opt_ix]
|
|
|
|
if option in ( '-O', '--open'):
|
|
|
|
#only family trees can be opened
|
|
|
|
format = 'famtree'
|
|
|
|
fname = value
|
2006-05-02 02:41:26 +05:30
|
|
|
fullpath = os.path.abspath(os.path.expanduser(fname))
|
|
|
|
ftype = Mime.get_type(fullpath)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if not os.path.exists(fullpath):
|
|
|
|
#see if not just a name of a database is given
|
2008-01-28 16:46:54 +05:30
|
|
|
data = self.dbman.family_tree(fname)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if data is not None:
|
|
|
|
fname, ftype, title = data
|
|
|
|
else:
|
|
|
|
print "Input family tree does not exist: %s" % fullpath
|
|
|
|
print "If gedcom, gramps-xml or grdb, use the -i option"
|
2005-01-30 05:04:09 +05:30
|
|
|
continue
|
|
|
|
else:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if not os.path.isdir(fullpath):
|
|
|
|
print "A file is given, not an existing family tree",
|
|
|
|
print ", use the -i option to import in a family tree",
|
|
|
|
print " instead"
|
|
|
|
continue
|
|
|
|
self.open = (fname, format)
|
|
|
|
elif option in ( '-i', '--import'):
|
|
|
|
fname = value
|
2006-05-02 02:41:26 +05:30
|
|
|
fullpath = os.path.abspath(os.path.expanduser(fname))
|
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
format = 'famtree'
|
|
|
|
ftype = Mime.get_type(fullpath)
|
|
|
|
if not os.path.exists(fullpath):
|
|
|
|
#see if not just a name of a database is given
|
2008-01-28 16:46:54 +05:30
|
|
|
data = self.dbman.family_tree(fname)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if data is not None:
|
|
|
|
fname, ftype, title = data
|
|
|
|
else:
|
|
|
|
print "Input file does not exist: %s" % fullpath
|
|
|
|
continue
|
|
|
|
elif os.path.isdir(fullpath):
|
2008-02-18 18:01:31 +05:30
|
|
|
ftype = const.APP_FAMTREE
|
|
|
|
fname = fullpath
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
elif opt_ix<len(options)-1 \
|
2004-06-21 10:40:27 +05:30
|
|
|
and options[opt_ix+1][0] in ( '-f', '--format'):
|
2003-10-13 07:25:56 +05:30
|
|
|
format = options[opt_ix+1][1]
|
2005-08-18 11:28:28 +05:30
|
|
|
if format not in ('gedcom',
|
|
|
|
'gramps-xml',
|
|
|
|
'gramps-pkg',
|
|
|
|
'grdb',
|
|
|
|
'geneweb'):
|
2003-10-13 07:25:56 +05:30
|
|
|
print "Invalid format: %s" % format
|
2004-06-21 10:40:27 +05:30
|
|
|
print "Ignoring input file: %s" % fname
|
|
|
|
continue
|
2007-09-08 11:24:02 +05:30
|
|
|
elif ftype == const.APP_GEDCOM:
|
2003-10-13 07:25:56 +05:30
|
|
|
format = 'gedcom'
|
2007-09-08 11:24:02 +05:30
|
|
|
elif ftype == const.APP_GRAMPS_PKG:
|
2003-10-13 07:25:56 +05:30
|
|
|
format = 'gramps-pkg'
|
2007-09-08 11:24:02 +05:30
|
|
|
elif ftype == const.APP_GRAMPS_XML:
|
2004-06-21 10:40:27 +05:30
|
|
|
format = 'gramps-xml'
|
2007-09-08 11:24:02 +05:30
|
|
|
elif ftype == const.APP_GRAMPS:
|
2004-06-21 10:40:27 +05:30
|
|
|
format = 'grdb'
|
2007-09-08 11:24:02 +05:30
|
|
|
elif ftype == const.APP_GENEWEB:
|
2005-02-20 00:35:48 +05:30
|
|
|
format = 'geneweb'
|
2003-10-13 07:25:56 +05:30
|
|
|
else:
|
2006-05-02 02:41:26 +05:30
|
|
|
print 'Unrecognized type: "%s" for input file: %s' \
|
|
|
|
% (ftype,fname)
|
2004-06-21 10:40:27 +05:30
|
|
|
print "Ignoring input file: %s" % fname
|
|
|
|
continue
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
self.imports.append((fname, format))
|
|
|
|
elif option in ( '-o', '--output' ):
|
|
|
|
outfname = value
|
2006-05-02 02:41:26 +05:30
|
|
|
fullpath = os.path.abspath(os.path.expanduser(outfname))
|
|
|
|
if os.path.exists(fullpath):
|
|
|
|
print "WARNING: Output file already exist!"
|
|
|
|
print "WARNING: It will be overwritten:\n %s" % fullpath
|
|
|
|
answer = None
|
|
|
|
while not answer:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
answer = raw_input('OK to overwrite? (yes/no) ')
|
2006-05-02 02:41:26 +05:30
|
|
|
if answer.upper() in ('Y','YES'):
|
|
|
|
print "Will overwrite the existing file: %s" % fullpath
|
|
|
|
else:
|
|
|
|
print "Will skip the output file: %s" % fullpath
|
|
|
|
continue
|
2008-02-18 18:01:31 +05:30
|
|
|
if opt_ix < len(options)-1 \
|
2004-06-21 10:40:27 +05:30
|
|
|
and options[opt_ix+1][0] in ( '-f', '--format'):
|
2003-10-13 07:25:56 +05:30
|
|
|
outformat = options[opt_ix+1][1]
|
2005-08-18 11:28:28 +05:30
|
|
|
if outformat not in ('gedcom',
|
|
|
|
'gramps-xml',
|
|
|
|
'gramps-pkg',
|
|
|
|
'grdb',
|
|
|
|
'iso',
|
|
|
|
'wft',
|
|
|
|
'geneweb'):
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "Invalid format for output: %s" % outformat
|
2004-06-21 10:40:27 +05:30
|
|
|
print "Ignoring output file: %s" % outfname
|
|
|
|
continue
|
2003-10-13 07:25:56 +05:30
|
|
|
elif outfname[-3:].upper() == "GED":
|
|
|
|
outformat = 'gedcom'
|
2004-06-23 02:19:22 +05:30
|
|
|
elif outfname[-4:].upper() == "GPKG":
|
2003-10-13 07:25:56 +05:30
|
|
|
outformat = 'gramps-pkg'
|
|
|
|
elif outfname[-3:].upper() == "WFT":
|
|
|
|
outformat = 'wft'
|
2005-02-20 00:35:48 +05:30
|
|
|
elif outfname[-2:].upper() == "GW":
|
|
|
|
outformat = 'geneweb'
|
2005-08-18 11:28:28 +05:30
|
|
|
elif outfname[-6:].upper() == "GRAMPS":
|
2004-06-21 10:40:27 +05:30
|
|
|
outformat = 'gramps-xml'
|
2005-12-06 12:08:09 +05:30
|
|
|
elif outfname[-4:].upper() == "GRDB":
|
|
|
|
outformat = 'grdb'
|
2003-10-13 07:25:56 +05:30
|
|
|
else:
|
|
|
|
print "Unrecognized format for output file %s" % outfname
|
2004-06-21 10:40:27 +05:30
|
|
|
print "Ignoring output file: %s" % outfname
|
|
|
|
continue
|
2008-02-18 18:01:31 +05:30
|
|
|
self.exports.append((fullpath, outformat))
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
elif option in ( '-a', '--action' ):
|
|
|
|
action = value
|
2005-12-06 12:08:09 +05:30
|
|
|
if action not in ( 'check', 'summary', 'report', 'tool' ):
|
2004-06-21 10:40:27 +05:30
|
|
|
print "Unknown action: %s. Ignoring." % action
|
|
|
|
continue
|
2004-12-22 07:26:37 +05:30
|
|
|
options_str = ""
|
2008-02-18 18:01:31 +05:30
|
|
|
if opt_ix < len(options)-1 \
|
2004-12-22 07:26:37 +05:30
|
|
|
and options[opt_ix+1][0] in ( '-p', '--options' ):
|
|
|
|
options_str = options[opt_ix+1][1]
|
2008-02-18 18:01:31 +05:30
|
|
|
self.actions.append((action, options_str))
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
elif option in ('-d', '--debug'):
|
|
|
|
logger = logging.getLogger(value)
|
|
|
|
logger.setLevel(logging.DEBUG)
|
2008-01-17 01:53:20 +05:30
|
|
|
elif option in ('-l',):
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
self.list = True
|
2008-01-17 01:53:20 +05:30
|
|
|
elif option in ('-h', '-?', '--help'):
|
|
|
|
self.help = True
|
2008-01-28 16:46:54 +05:30
|
|
|
elif option in ('-u', '--force-unlock'):
|
|
|
|
self.force_unlock = True
|
2006-05-22 23:37:12 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Determine the need for GUI
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def need_gui(self):
|
|
|
|
"""
|
|
|
|
Determine whether we need a GUI session for the given tasks.
|
|
|
|
"""
|
|
|
|
if self.open_gui:
|
|
|
|
# No-option argument, definitely GUI
|
|
|
|
return True
|
|
|
|
|
|
|
|
# If we have data to work with:
|
|
|
|
if (self.open or self.imports):
|
|
|
|
if (self.exports or self.actions):
|
|
|
|
# have both data and what to do with it => no GUI
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
# data given, but no action/export => GUI
|
|
|
|
return True
|
|
|
|
|
|
|
|
# No data, can only do GUI here
|
|
|
|
return True
|
|
|
|
|
2004-06-23 02:19:22 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# Overall argument handler:
|
|
|
|
# sorts out the sequence and details of operations
|
|
|
|
#-------------------------------------------------------------------------
|
2004-06-21 10:40:27 +05:30
|
|
|
def handle_args(self):
|
|
|
|
"""
|
|
|
|
Depending on the given arguments, import or open data, launch
|
|
|
|
session, write files, and/or perform actions.
|
|
|
|
"""
|
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if self.list:
|
|
|
|
print 'List of known family trees in your database path\n'
|
2008-01-28 16:46:54 +05:30
|
|
|
for name, dirname in self.dbman.family_tree_list():
|
2007-12-29 20:17:38 +05:30
|
|
|
print dirname, ', with name ', name
|
|
|
|
sys.exit(0)
|
2008-01-17 01:53:20 +05:30
|
|
|
if self.help:
|
|
|
|
print _help
|
|
|
|
sys.exit(0)
|
2005-01-30 05:04:09 +05:30
|
|
|
if self.open_gui:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
# Filename was given as gramps FILENAME.
|
|
|
|
# Open a session with that file. Forget the rest of given arguments
|
2004-11-25 11:12:31 +05:30
|
|
|
success = False
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if os.path.isdir(self.open_gui):
|
|
|
|
#only accept if a name.txt is found
|
|
|
|
path_name = os.path.join(self.open_gui, NAME_FILE)
|
|
|
|
if os.path.isfile(path_name):
|
|
|
|
filetype = const.APP_FAMTREE
|
|
|
|
filename = self.open_gui
|
|
|
|
else:
|
|
|
|
filetype = 'No Fam Tree Dir'
|
|
|
|
filename = self.open_gui
|
|
|
|
else:
|
|
|
|
filename = os.path.abspath(os.path.expanduser(self.open_gui))
|
|
|
|
filetype = Mime.get_type(filename)
|
|
|
|
if filetype in ('x-directory/normal',):
|
|
|
|
success = True
|
|
|
|
pass
|
|
|
|
elif filetype in IMPORT_TYPES:
|
2005-02-14 08:39:22 +05:30
|
|
|
# Say the type outloud
|
2007-09-08 11:24:02 +05:30
|
|
|
if filetype == const.APP_GRAMPS:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "Type: GRAMPS 2.2.x GRDB database"
|
2007-09-08 11:24:02 +05:30
|
|
|
elif filetype == const.APP_GEDCOM:
|
2005-02-14 08:39:22 +05:30
|
|
|
print "Type: GEDCOM file"
|
2007-09-08 11:24:02 +05:30
|
|
|
elif filetype == const.APP_GRAMPS_XML:
|
2005-02-14 08:39:22 +05:30
|
|
|
print "Type: GRAMPS XML database"
|
2007-09-08 11:24:02 +05:30
|
|
|
elif filetype == const.APP_GRAMPS_PKG:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "Type: GRAMPS XML package"
|
|
|
|
|
2008-01-28 16:46:54 +05:30
|
|
|
filename, filetype, name = self.dbman.import_new_db(filetype,
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
filename, None)
|
2004-11-25 11:12:31 +05:30
|
|
|
success = True
|
2004-08-24 04:09:41 +05:30
|
|
|
else:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
#see if not just a name of a database is given
|
2008-01-28 16:46:54 +05:30
|
|
|
data = self.dbman.family_tree(self.open_gui)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if data is not None:
|
2008-02-18 18:01:31 +05:30
|
|
|
filename, filetype = data[0], data[1]
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
success = True
|
|
|
|
else:
|
2008-02-18 15:39:50 +05:30
|
|
|
ErrorDialog(
|
2005-04-12 07:26:36 +05:30
|
|
|
_("Could not open file: %s") % filename,
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
_('Not a valid Family tree given to open\n\n'
|
|
|
|
))
|
|
|
|
print "Exiting..."
|
2008-01-17 01:53:20 +05:30
|
|
|
sys.exit(0)
|
2004-11-25 11:12:31 +05:30
|
|
|
if success:
|
2008-01-28 16:46:54 +05:30
|
|
|
# Test if not locked or problematic
|
|
|
|
if not self.__check_db(filename, self.force_unlock):
|
|
|
|
sys.exit(0)
|
2004-11-29 10:45:41 +05:30
|
|
|
# Add the file to the recent items
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
path = os.path.join(filename, "name.txt")
|
|
|
|
try:
|
|
|
|
ifile = open(path)
|
|
|
|
title = ifile.readline().strip()
|
|
|
|
ifile.close()
|
|
|
|
except:
|
|
|
|
title = filename
|
|
|
|
RecentFiles.recent_files(filename, title)
|
2005-06-05 09:31:56 +05:30
|
|
|
else:
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2007-12-11 08:19:58 +05:30
|
|
|
return (filename, filetype)
|
2004-06-21 10:40:27 +05:30
|
|
|
|
2005-01-30 05:04:09 +05:30
|
|
|
if self.open:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
# Family Tree to open was given. Open it
|
|
|
|
# Then go on and process the rest of the command line arguments.
|
2006-04-10 23:47:00 +05:30
|
|
|
self.cl = bool(self.exports or self.actions)
|
2004-06-23 02:19:22 +05:30
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
name, format = self.open
|
2005-01-30 05:04:09 +05:30
|
|
|
success = False
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
|
|
|
if format == 'famtree':
|
|
|
|
path_name = os.path.join(name, NAME_FILE)
|
|
|
|
if os.path.isfile(path_name):
|
|
|
|
filetype = const.APP_FAMTREE
|
|
|
|
filename = name
|
2008-01-28 16:46:54 +05:30
|
|
|
if not self.__check_db(filename, self.force_unlock):
|
|
|
|
sys.exit(0)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
success = True
|
|
|
|
else:
|
|
|
|
print "No valid Family tree given, cannot be opened."
|
|
|
|
print "Exiting..."
|
|
|
|
sys.exit(1)
|
2005-01-30 05:04:09 +05:30
|
|
|
else:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "Only Family trees can be opened."
|
2005-01-30 05:04:09 +05:30
|
|
|
print "Exiting..."
|
2008-01-17 01:53:20 +05:30
|
|
|
sys.exit(0)
|
2005-01-30 05:04:09 +05:30
|
|
|
|
2006-05-18 06:32:52 +05:30
|
|
|
try:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
self.vm.open_activate(filename)
|
2005-01-30 05:04:09 +05:30
|
|
|
print "Opened successfully!"
|
|
|
|
success = True
|
2006-05-18 06:32:52 +05:30
|
|
|
except:
|
2005-01-30 05:04:09 +05:30
|
|
|
print "Error opening the file."
|
|
|
|
print "Exiting..."
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2005-01-30 05:04:09 +05:30
|
|
|
|
|
|
|
if self.imports:
|
2006-04-10 23:47:00 +05:30
|
|
|
self.cl = bool(self.exports or self.actions or self.cl)
|
2005-01-30 05:04:09 +05:30
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if not self.open:
|
|
|
|
# Create empty dir for imported database(s)
|
|
|
|
self.imp_db_path = Utils.get_empty_tempdir("import_dbdir")
|
|
|
|
self.vm.db_loader.read_file(self.imp_db_path)
|
2004-06-21 10:40:27 +05:30
|
|
|
|
|
|
|
for imp in self.imports:
|
2004-06-23 02:19:22 +05:30
|
|
|
print "Importing: file %s, format %s." % imp
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
self.cl_import(imp[0], imp[1])
|
2004-06-23 02:19:22 +05:30
|
|
|
|
2005-01-30 05:04:09 +05:30
|
|
|
elif len(self.args) > 1 and not self.open:
|
2004-06-21 10:40:27 +05:30
|
|
|
print "No data was given -- will launch interactive session."
|
2003-10-13 07:25:56 +05:30
|
|
|
print "To use in the command-line mode,", \
|
|
|
|
"supply at least one input file to process."
|
2004-06-21 10:40:27 +05:30
|
|
|
print "Launching interactive session..."
|
2003-10-13 07:25:56 +05:30
|
|
|
|
2006-04-10 23:47:00 +05:30
|
|
|
if self.cl:
|
2008-02-18 18:01:31 +05:30
|
|
|
for (action, options_str) in self.actions:
|
2006-04-10 23:47:00 +05:30
|
|
|
print "Performing action: %s." % action
|
|
|
|
if options_str:
|
|
|
|
print "Using options string: %s" % options_str
|
2008-02-18 18:01:31 +05:30
|
|
|
self.cl_action(action, options_str)
|
2006-04-10 23:47:00 +05:30
|
|
|
|
|
|
|
for expt in self.exports:
|
|
|
|
print "Exporting: file %s, format %s." % expt
|
2008-02-18 18:01:31 +05:30
|
|
|
self.cl_export(expt[0], expt[1])
|
2006-04-10 23:47:00 +05:30
|
|
|
|
|
|
|
print "Cleaning up."
|
2007-11-11 23:55:01 +05:30
|
|
|
# remove files in import db subdir after use
|
2006-04-10 23:47:00 +05:30
|
|
|
self.state.db.close()
|
2007-11-26 11:11:04 +05:30
|
|
|
if self.imp_db_path:
|
|
|
|
Utils.rm_tempdir(self.imp_db_path)
|
2006-04-10 23:47:00 +05:30
|
|
|
print "Exiting."
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(0)
|
2006-04-10 23:47:00 +05:30
|
|
|
|
2007-12-11 08:19:58 +05:30
|
|
|
elif Config.get(Config.RECENT_FILE) and Config.get(Config.AUTOLOAD):
|
|
|
|
filename = Config.get(Config.RECENT_FILE)
|
2008-01-15 14:51:13 +05:30
|
|
|
if os.path.isdir(filename) and \
|
|
|
|
os.path.isfile(os.path.join(filename, "name.txt")) and \
|
2008-01-28 16:46:54 +05:30
|
|
|
self.__check_db(filename):
|
2008-01-15 14:51:13 +05:30
|
|
|
self.vm.db_loader.read_file(filename)
|
|
|
|
return (filename, const.APP_FAMTREE)
|
2003-10-13 07:25:56 +05:30
|
|
|
|
2008-01-28 16:46:54 +05:30
|
|
|
def __check_db(self, dbpath, force_unlock = False):
|
|
|
|
# Test if not locked or problematic
|
|
|
|
if force_unlock:
|
|
|
|
self.dbman.break_lock(dbpath)
|
|
|
|
if self.dbman.is_locked(dbpath):
|
|
|
|
print _("Database is locked, cannot open it!")
|
|
|
|
print _(" Info: %s") % find_locker_name(dbpath)
|
|
|
|
return False
|
|
|
|
if self.dbman.needs_recovery(dbpath):
|
|
|
|
print _("Database needs recovery, cannot open it!")
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2004-06-23 02:19:22 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Import handler
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
def cl_import(self, filename, format):
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
|
|
|
Command-line import routine. Try to import filename using the format.
|
2007-03-21 00:51:41 +05:30
|
|
|
Any errors will cause the sys.exit(1) call.
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if format == 'famtree':
|
|
|
|
#3.x database
|
2008-01-28 16:46:54 +05:30
|
|
|
if not self.__check_db(filename):
|
2008-02-18 18:01:31 +05:30
|
|
|
sys.exit(0)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
try:
|
|
|
|
GrampsDbUtils.gramps_db_reader_factory(const.APP_FAMTREE)(
|
|
|
|
self.state.db, filename, empty)
|
|
|
|
except AttributeError:
|
|
|
|
print "Error importing Family Tree %s" % filename
|
|
|
|
sys.exit(1)
|
|
|
|
elif format == 'grdb':
|
|
|
|
#2.x database
|
2005-01-29 11:35:51 +05:30
|
|
|
filename = os.path.normpath(os.path.abspath(filename))
|
|
|
|
try:
|
2007-09-08 11:24:02 +05:30
|
|
|
GrampsDbUtils.gramps_db_reader_factory(const.APP_GRAMPS)(
|
2006-05-18 06:32:52 +05:30
|
|
|
self.state.db,filename,empty)
|
2007-11-26 10:13:00 +05:30
|
|
|
except GX.GrampsDbException, e:
|
|
|
|
print "%s" % e.value
|
|
|
|
sys.exit(1)
|
2005-01-29 11:35:51 +05:30
|
|
|
except:
|
|
|
|
print "Error importing %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2005-01-29 11:35:51 +05:30
|
|
|
elif format == 'gedcom':
|
2003-10-13 07:25:56 +05:30
|
|
|
filename = os.path.normpath(os.path.abspath(filename))
|
2008-02-18 18:01:31 +05:30
|
|
|
filename = Utils.get_unicode_path(filename)
|
2003-10-13 07:25:56 +05:30
|
|
|
try:
|
2006-05-18 06:32:52 +05:30
|
|
|
# Cheating here to use default encoding
|
2007-11-01 03:17:58 +05:30
|
|
|
from GrampsDbUtils._ReadGedcom import import2
|
2008-02-18 18:01:31 +05:30
|
|
|
import2(self.state.db, filename, None, "", False)
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
|
|
|
print "Error importing %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2004-06-21 10:40:27 +05:30
|
|
|
elif format == 'gramps-xml':
|
2003-10-13 07:25:56 +05:30
|
|
|
try:
|
2007-09-08 11:24:02 +05:30
|
|
|
GrampsDbUtils.gramps_db_reader_factory(const.APP_GRAMPS_XML)(
|
2006-04-10 23:47:00 +05:30
|
|
|
self.state.db,filename,None,self.cl)
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
|
|
|
print "Error importing %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2005-02-20 00:35:48 +05:30
|
|
|
elif format == 'geneweb':
|
|
|
|
import ImportGeneWeb
|
|
|
|
filename = os.path.normpath(os.path.abspath(filename))
|
|
|
|
try:
|
2008-02-18 18:01:31 +05:30
|
|
|
ImportGeneWeb.importData(self.state.db, filename, None)
|
2005-02-20 00:35:48 +05:30
|
|
|
except:
|
|
|
|
print "Error importing %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2003-10-13 07:25:56 +05:30
|
|
|
elif format == 'gramps-pkg':
|
2007-11-26 11:11:04 +05:30
|
|
|
tmpdir_path = Utils.get_empty_tempdir("imp_gpkgdir")
|
2003-10-13 07:25:56 +05:30
|
|
|
try:
|
2006-03-01 05:56:29 +05:30
|
|
|
import tarfile
|
|
|
|
archive = tarfile.open(filename)
|
|
|
|
for tarinfo in archive:
|
2008-02-18 18:01:31 +05:30
|
|
|
archive.extract(tarinfo, tmpdir_path)
|
2006-03-01 05:56:29 +05:30
|
|
|
archive.close()
|
2008-01-09 00:43:54 +05:30
|
|
|
except tarfile.ReadError, msg:
|
2006-03-01 05:56:29 +05:30
|
|
|
print "Error reading archive:", msg
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2008-01-09 12:15:15 +05:30
|
|
|
except tarfile.CompressionError, msg:
|
2006-03-01 05:56:29 +05:30
|
|
|
print "Error uncompressing archive:", msg
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
2006-03-01 05:56:29 +05:30
|
|
|
print "Error extracting into %s" % tmpdir_path
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2003-10-13 07:25:56 +05:30
|
|
|
|
2008-02-18 18:01:31 +05:30
|
|
|
dbname = os.path.join(tmpdir_path, const.XMLFILE)
|
2003-10-13 07:25:56 +05:30
|
|
|
|
|
|
|
try:
|
2007-09-08 11:24:02 +05:30
|
|
|
GrampsDbUtils.gramps_db_reader_factory(const.APP_GRAMPS_XML)(
|
2006-04-10 23:47:00 +05:30
|
|
|
self.state.db,dbname,None)
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
|
|
|
print "Error importing %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2003-10-13 07:25:56 +05:30
|
|
|
# Clean up tempdir after ourselves
|
2006-05-02 02:41:26 +05:30
|
|
|
# THIS HAS BEEN CHANGED, because now we want to keep images
|
|
|
|
# stay after the import is over. Just delete the XML file.
|
2007-11-26 11:11:04 +05:30
|
|
|
##jgs:FIXME for how long? just for debug? or this session?
|
|
|
|
## must not be forever, since re-exec of this routine
|
|
|
|
## clears dirfiles without asking
|
|
|
|
## & expands nre tarball possibly overwriting subdirs
|
|
|
|
##
|
|
|
|
## if only debugging, could do Utils.rm_tempdir here
|
|
|
|
## in any case, no real harm (exc. space) to leave stuff here
|
|
|
|
## until next exec of this, which will discard all old stuff
|
2006-05-02 02:41:26 +05:30
|
|
|
os.remove(dbname)
|
|
|
|
## files = os.listdir(tmpdir_path)
|
|
|
|
## for fn in files:
|
|
|
|
## os.remove(os.path.join(tmpdir_path,fn))
|
|
|
|
## os.rmdir(tmpdir_path)
|
2003-10-13 07:25:56 +05:30
|
|
|
else:
|
|
|
|
print "Invalid format: %s" % format
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2006-04-10 23:47:00 +05:30
|
|
|
if not self.cl:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
if self.imp_db_path:
|
|
|
|
return self.vm.open_activate(self.imp_db_path)
|
|
|
|
else:
|
|
|
|
return self.vm.open_activate(self.open[0])
|
2003-10-13 07:25:56 +05:30
|
|
|
|
2004-06-23 02:19:22 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Export handler
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-18 18:01:31 +05:30
|
|
|
def cl_export(self, filename, format):
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
|
|
|
Command-line export routine.
|
|
|
|
Try to write into filename using the format.
|
2007-03-21 00:51:41 +05:30
|
|
|
Any errors will cause the sys.exit(1) call.
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
2006-07-19 10:26:41 +05:30
|
|
|
filename = os.path.abspath(os.path.expanduser(filename))
|
2005-12-06 12:08:09 +05:30
|
|
|
if format == 'grdb':
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "GRDB format write is no longer supported!"
|
|
|
|
sys.exit(1)
|
2005-12-06 12:08:09 +05:30
|
|
|
elif format == 'gedcom':
|
2003-10-13 07:25:56 +05:30
|
|
|
try:
|
2007-09-06 10:06:04 +05:30
|
|
|
gw = GrampsDbUtils.GedcomWriter(self.state.db, None, 1)
|
2007-11-01 03:17:58 +05:30
|
|
|
ret = gw.write_gedcom_file(filename)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "... finished writing %s" % filename
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
|
|
|
print "Error exporting %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2004-06-21 10:40:27 +05:30
|
|
|
elif format == 'gramps-xml':
|
2003-10-13 07:25:56 +05:30
|
|
|
filename = os.path.normpath(os.path.abspath(filename))
|
|
|
|
if filename:
|
|
|
|
try:
|
2008-02-18 18:01:31 +05:30
|
|
|
g = GrampsDbUtils.XmlWriter(self.state.db, None, 0, 1)
|
2005-08-18 11:28:28 +05:30
|
|
|
ret = g.write(filename)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "... finished writing %s" % filename
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
|
|
|
print "Error exporting %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
else:
|
|
|
|
print "Error exporting %s" % filename
|
2003-10-13 07:25:56 +05:30
|
|
|
elif format == 'gramps-pkg':
|
|
|
|
try:
|
2005-02-20 00:35:48 +05:30
|
|
|
import WritePkg
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
writer = WritePkg.PackageWriter(self.state.db, filename)
|
2005-02-20 00:35:48 +05:30
|
|
|
ret = writer.export()
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "... finished writing %s" % filename
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
|
|
|
print "Error creating %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2003-10-13 07:25:56 +05:30
|
|
|
elif format == 'iso':
|
2005-02-20 04:03:24 +05:30
|
|
|
import WriteCD
|
|
|
|
try:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
writer = WriteCD.PackageWriter(self.state.db, filename, 1)
|
2005-02-20 04:03:24 +05:30
|
|
|
ret = writer.export()
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "... finished writing %s" % filename
|
2005-02-20 04:03:24 +05:30
|
|
|
except:
|
|
|
|
print "Error exporting %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2005-02-20 00:35:48 +05:30
|
|
|
elif format == 'wft':
|
|
|
|
import WriteFtree
|
2003-10-13 07:25:56 +05:30
|
|
|
try:
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
writer = WriteFtree.FtreeWriter(self.state.db, None, 1,
|
|
|
|
filename)
|
2005-02-20 00:35:48 +05:30
|
|
|
ret = writer.export_data()
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "... finished writing %s" % filename
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
|
|
|
print "Error exporting %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2005-02-20 00:35:48 +05:30
|
|
|
elif format == 'geneweb':
|
|
|
|
import WriteGeneWeb
|
2003-10-13 07:25:56 +05:30
|
|
|
try:
|
2006-04-10 23:47:00 +05:30
|
|
|
writer = WriteGeneWeb.GeneWebWriter(self.state.db,
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
None, 1, filename)
|
2005-02-20 00:35:48 +05:30
|
|
|
ret = writer.export_data()
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
print "... finished writing %s" % filename
|
2003-10-13 07:25:56 +05:30
|
|
|
except:
|
|
|
|
print "Error exporting %s" % filename
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2003-10-13 07:25:56 +05:30
|
|
|
else:
|
|
|
|
print "Invalid format: %s" % format
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2003-10-13 07:25:56 +05:30
|
|
|
|
2004-06-23 02:19:22 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Action handler
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-18 18:01:31 +05:30
|
|
|
def cl_action(self, action, options_str):
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
|
|
|
Command-line action routine. Try to perform specified action.
|
2007-03-21 00:51:41 +05:30
|
|
|
Any errors will cause the sys.exit(1) call.
|
2004-06-21 10:40:27 +05:30
|
|
|
"""
|
2003-10-13 07:25:56 +05:30
|
|
|
if action == 'check':
|
|
|
|
import Check
|
2008-02-18 18:01:31 +05:30
|
|
|
checker = Check.CheckIntegrity(self.state.db, None, None)
|
2003-10-13 07:25:56 +05:30
|
|
|
checker.check_for_broken_family_links()
|
|
|
|
checker.cleanup_missing_photos(1)
|
|
|
|
checker.check_parent_relationships()
|
|
|
|
checker.cleanup_empty_families(0)
|
|
|
|
errs = checker.build_report(1)
|
|
|
|
if errs:
|
|
|
|
checker.report(1)
|
|
|
|
elif action == 'summary':
|
|
|
|
import Summary
|
2008-02-18 18:01:31 +05:30
|
|
|
text = Summary.build_report(self.state.db, None)
|
2008-01-17 17:05:15 +05:30
|
|
|
print text
|
2004-12-22 07:26:37 +05:30
|
|
|
elif action == "report":
|
|
|
|
try:
|
|
|
|
options_str_dict = dict( [ tuple(chunk.split('='))
|
|
|
|
for chunk in options_str.split(',') ] )
|
|
|
|
except:
|
|
|
|
options_str_dict = {}
|
|
|
|
print "Ignoring invalid options string."
|
|
|
|
|
2008-02-18 18:01:31 +05:30
|
|
|
name = options_str_dict.pop('name', None)
|
2004-12-22 07:26:37 +05:30
|
|
|
if not name:
|
|
|
|
print "Report name not given. Please use name=reportname"
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2004-12-22 07:26:37 +05:30
|
|
|
|
2006-03-11 06:42:06 +05:30
|
|
|
for item in cl_list:
|
2004-12-22 07:26:37 +05:30
|
|
|
if name == item[0]:
|
|
|
|
category = item[1]
|
|
|
|
report_class = item[2]
|
|
|
|
options_class = item[3]
|
2008-02-18 18:01:31 +05:30
|
|
|
if category in (CATEGORY_BOOK, CATEGORY_CODE, CATEGORY_WEB):
|
|
|
|
options_class(self.state.db, name, category,
|
|
|
|
options_str_dict)
|
2004-12-22 07:26:37 +05:30
|
|
|
else:
|
2008-02-18 18:01:31 +05:30
|
|
|
cl_report(self.state.db, name, category, report_class,
|
|
|
|
options_class, options_str_dict)
|
2004-12-22 07:26:37 +05:30
|
|
|
return
|
|
|
|
|
|
|
|
print "Unknown report name. Available names are:"
|
2006-03-11 06:42:06 +05:30
|
|
|
for item in cl_list:
|
2008-02-25 13:40:19 +05:30
|
|
|
# Print cli report name ([item[0]) and GUI report name (item[4])
|
|
|
|
if len(item[0]) <= 25:
|
|
|
|
print " %s%s- %s" % (item[0],
|
|
|
|
" " * (26 - len(item[0])), item[4])
|
|
|
|
else:
|
|
|
|
print " %s\t- %s" % (item[0], item[4])
|
2005-12-06 12:08:09 +05:30
|
|
|
elif action == "tool":
|
|
|
|
try:
|
|
|
|
options_str_dict = dict( [ tuple(chunk.split('=')) for
|
|
|
|
chunk in options_str.split(',') ] )
|
|
|
|
except:
|
|
|
|
options_str_dict = {}
|
|
|
|
print "Ignoring invalid options string."
|
|
|
|
|
2008-02-18 18:01:31 +05:30
|
|
|
name = options_str_dict.pop('name', None)
|
2005-12-06 12:08:09 +05:30
|
|
|
if not name:
|
|
|
|
print "Tool name not given. Please use name=toolname"
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2006-03-11 06:42:06 +05:30
|
|
|
for item in cli_tool_list:
|
2005-12-06 12:08:09 +05:30
|
|
|
if name == item[0]:
|
|
|
|
category = item[1]
|
|
|
|
tool_class = item[2]
|
|
|
|
options_class = item[3]
|
2008-02-18 18:01:31 +05:30
|
|
|
Tool.cli_tool(self.state, name, category, tool_class,
|
|
|
|
options_class, options_str_dict)
|
2005-12-06 12:08:09 +05:30
|
|
|
return
|
|
|
|
|
|
|
|
print "Unknown tool name. Available names are:"
|
2006-03-11 06:42:06 +05:30
|
|
|
for item in cli_tool_list:
|
2005-12-06 12:08:09 +05:30
|
|
|
print " %s" % item[0]
|
2003-10-13 07:25:56 +05:30
|
|
|
else:
|
|
|
|
print "Unknown action: %s." % action
|
2007-03-21 00:51:41 +05:30
|
|
|
sys.exit(1)
|
2005-12-30 00:06:59 +05:30
|
|
|
|
|
|
|
def add_all_files_filter(chooser):
|
|
|
|
"""
|
|
|
|
Add an all-permitting filter to the file chooser dialog.
|
|
|
|
"""
|
|
|
|
mime_filter = gtk.FileFilter()
|
|
|
|
mime_filter.set_name(_('All files'))
|
|
|
|
mime_filter.add_pattern('*')
|
|
|
|
chooser.add_filter(mime_filter)
|
|
|
|
|
|
|
|
def add_grdb_filter(chooser):
|
|
|
|
"""
|
|
|
|
Add a GRDB filter to the file chooser dialog.
|
|
|
|
"""
|
|
|
|
mime_filter = gtk.FileFilter()
|
|
|
|
mime_filter.set_name(_('GRAMPS databases'))
|
2007-09-08 11:24:02 +05:30
|
|
|
mime_filter.add_mime_type(const.APP_GRAMPS)
|
2005-12-30 00:06:59 +05:30
|
|
|
chooser.add_filter(mime_filter)
|
2006-04-10 23:47:00 +05:30
|
|
|
|
|
|
|
def read_pkg(filename):
|
|
|
|
print "FIXME: This is not re-implemented yet."
|
2006-05-18 06:32:52 +05:30
|
|
|
|
|
|
|
def empty(val):
|
|
|
|
pass
|