Move common XML import/export data into libgrampsxml.py.

svn: r11945
This commit is contained in:
Brian Matherly 2009-02-10 05:59:26 +00:00
parent 2472d94621
commit 5eb3f7e446
4 changed files with 61 additions and 6 deletions

View File

@ -63,6 +63,7 @@ from QuestionDialog import ErrorDialog
import ExportOptions import ExportOptions
import gen.proxy import gen.proxy
from gen.plug import PluginManager, ExportPlugin from gen.plug import PluginManager, ExportPlugin
import libgrampsxml
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -76,8 +77,6 @@ try:
except: except:
_gzip_ok = 0 _gzip_ok = 0
XML_VERSION = "1.3.0"
# table for skipping control chars from XML # table for skipping control chars from XML
strip_dict = dict.fromkeys(range(9)+range(12,20)) strip_dict = dict.fromkeys(range(9)+range(12,20))
@ -204,9 +203,10 @@ class GrampsDbXmlWriter(UpdateCallback):
self.g.write('<!DOCTYPE database ' self.g.write('<!DOCTYPE database '
'PUBLIC "-//GRAMPS//DTD GRAMPS XML %s//EN"\n' 'PUBLIC "-//GRAMPS//DTD GRAMPS XML %s//EN"\n'
'"http://gramps-project.org/xml/%s/grampsxml.dtd">\n' '"http://gramps-project.org/xml/%s/grampsxml.dtd">\n'
% (XML_VERSION, XML_VERSION)) % (libgrampsxml.GRAMPS_XML_VERSION,
libgrampsxml.GRAMPS_XML_VERSION))
self.g.write('<database xmlns="http://gramps-project.org/xml/%s/">\n' self.g.write('<database xmlns="http://gramps-project.org/xml/%s/">\n'
% XML_VERSION) % libgrampsxml.GRAMPS_XML_VERSION)
self.g.write(" <header>\n") self.g.write(" <header>\n")
self.g.write(' <created date="%04d-%02d-%02d\"' % self.g.write(' <created date="%04d-%02d-%02d\"' %
(date[0],date[1],date[2]) ) (date[0],date[1],date[2]) )

View File

@ -46,9 +46,9 @@ from BasicUtils import name_displayer
from gen.db.dbconst import (PERSON_KEY, FAMILY_KEY, SOURCE_KEY, EVENT_KEY, from gen.db.dbconst import (PERSON_KEY, FAMILY_KEY, SOURCE_KEY, EVENT_KEY,
MEDIA_KEY, PLACE_KEY, REPOSITORY_KEY, NOTE_KEY) MEDIA_KEY, PLACE_KEY, REPOSITORY_KEY, NOTE_KEY)
from BasicUtils import UpdateCallback from BasicUtils import UpdateCallback
import ExportXml
import const import const
from gen.plug import PluginManager, ImportPlugin from gen.plug import PluginManager, ImportPlugin
import libgrampsxml
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -2460,7 +2460,7 @@ def version_is_valid(filename, cli):
""" """
parser = VersionParser(filename) parser = VersionParser(filename)
if parser.get_xmlns_version() > ExportXml.XML_VERSION: if parser.get_xmlns_version() > libgrampsxml.GRAMPS_XML_VERSION:
msg = _("The .gramps file you are importing was made by version %s of " msg = _("The .gramps file you are importing was made by version %s of "
"GRAMPS, while you are running an older version %s. " "GRAMPS, while you are running an older version %s. "
"The file will not be imported. Please upgrade to the latest " "The file will not be imported. Please upgrade to the latest "

View File

@ -6,6 +6,7 @@
pkgdatadir = $(datadir)/@PACKAGE@/plugins/lib pkgdatadir = $(datadir)/@PACKAGE@/plugins/lib
pkgdata_PYTHON = \ pkgdata_PYTHON = \
libgrampsxml.py\
libholiday.py\ libholiday.py\
libmapservice.py libmapservice.py

View File

@ -0,0 +1,54 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Brian G. Matherly
#
# 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$
#------------------------------------------------------------------------
#
# python modules
#
#------------------------------------------------------------------------
from gettext import gettext as _
#------------------------------------------------------------------------
#
# GRAMPS modules
#
#------------------------------------------------------------------------
from gen.plug import PluginManager, Plugin
#------------------------------------------------------------------------
#
# Public Constants
#
#------------------------------------------------------------------------
GRAMPS_XML_VERSION = "1.3.0"
#------------------------------------------------------------------------
#
# Register the plugins
#
#------------------------------------------------------------------------
PluginManager.get_instance().register_plugin(
Plugin(
name = __name__,
description = _("Provides common functionality for Gramps XML "
"import/export."),
module_name = __name__
)
)