2002-10-20 14:25:16 +00:00
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 05:41:40 +00:00
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2002-10-20 14:25:16 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
2003-11-23 20:55:14 +00:00
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 14:25:16 +00:00
|
|
|
"""
|
|
|
|
Contains the interface to allow a database to get written using
|
|
|
|
GRAMPS' XML file format.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# load standard python libraries
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-06 22:02:46 +00:00
|
|
|
from gettext import gettext as _
|
2002-10-20 14:25:16 +00:00
|
|
|
|
2006-03-05 04:31:24 +00:00
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Set up logging
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".WriteXML")
|
|
|
|
|
2002-10-20 14:25:16 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# load GRAMPS libraries
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2002-10-21 01:18:07 +00:00
|
|
|
from QuestionDialog import ErrorDialog
|
2006-09-01 22:57:57 +00:00
|
|
|
|
2007-02-17 22:12:56 +00:00
|
|
|
from GrampsDb import GrampsDbXmlWriter, GrampsDbWriteFailure
|
|
|
|
from GrampsDb import exportData as _exportData
|
|
|
|
from GrampsDb import quick_write as _quick_write
|
2006-12-11 21:09:25 +00:00
|
|
|
|
2002-10-20 14:25:16 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-02-17 22:12:56 +00:00
|
|
|
def exportData(database, filename, person, callback=None, version=const.version):
|
|
|
|
return _exportData(database, filename, person, version)
|
2002-10-20 14:25:16 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-02-17 22:12:56 +00:00
|
|
|
def quick_write(database, filename,callback=None,version=const.version):
|
|
|
|
return _quick_write(database, filename, version)
|
2002-10-20 14:25:16 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-02-17 22:12:56 +00:00
|
|
|
class XmlWriter(GrampsDbXmlWriter):
|
2002-10-20 14:25:16 +00:00
|
|
|
"""
|
|
|
|
Writes a database to the XML file.
|
|
|
|
"""
|
|
|
|
|
2007-04-08 04:24:38 +00:00
|
|
|
def __init__(self, db, callback, strip_photos, compress=1):
|
2002-10-20 14:25:16 +00:00
|
|
|
"""
|
|
|
|
"""
|
2007-06-20 04:44:32 +00:00
|
|
|
GrampsDbXmlWriter.__init__(self, db, strip_photos, compress, const.version)
|
2002-10-20 14:25:16 +00:00
|
|
|
|
|
|
|
def write(self,filename):
|
|
|
|
"""
|
2003-04-20 03:52:54 +00:00
|
|
|
Write the database to the specified file.
|
2002-10-20 14:25:16 +00:00
|
|
|
"""
|
2006-07-04 05:50:24 +00:00
|
|
|
try:
|
2007-02-17 22:12:56 +00:00
|
|
|
ret = GrampsDbXmlWriter.write(self, filename)
|
|
|
|
except GrampsDbWriteFailure, val:
|
|
|
|
ErrorDialog(val[0],val[1])
|
2006-01-27 20:38:33 +00:00
|
|
|
|
2005-12-06 06:38:09 +00:00
|
|
|
return ret
|
2002-10-20 14:25:16 +00:00
|
|
|
|
2004-07-01 04:09:55 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-07-09 18:19:47 +00:00
|
|
|
_title = _('GRAMPS _XML database')
|
|
|
|
_description = _('The GRAMPS XML database is a format used by older '
|
|
|
|
'versions of GRAMPS. It is read-write compatible with '
|
|
|
|
'the present GRAMPS database format.')
|
|
|
|
_config = None
|
|
|
|
_filename = 'gramps'
|
2004-07-01 04:09:55 +00:00
|
|
|
|
2006-03-11 01:12:06 +00:00
|
|
|
from PluginUtils import register_export
|
2004-07-09 18:19:47 +00:00
|
|
|
register_export(exportData,_title,_description,_config,_filename)
|