refactor GrampsDb and clean RelLib deps.

svn: r8032
This commit is contained in:
Richard Taylor 2007-02-03 17:11:05 +00:00
parent bc95f86aaf
commit f96b6f5dc2
33 changed files with 386 additions and 135 deletions

View File

@ -1,3 +1,52 @@
2007-01-26 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/ViewManager.py: refactor GrampsDb and clean RelLib deps
* src/Exporter.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_WriteGrdb.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_GrampsDbBase.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_ReadGedcom.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_ReadXML.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_GrampsDbFactories.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/__init__.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_GrampsDbExceptions.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_GrampsDbConst.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_WriteGedcom.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_GedcomInfo.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_ReadGrdb.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_WriteXML.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/gedcomimport.glade: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_GrampsXMLDB.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_GedTokens.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/gedcomexport.glade: refactor GrampsDb and clean RelLib deps
* src/GrampsDb/_GrampsBSDDB.py: refactor GrampsDb and clean RelLib deps
* src/GrampsLocale: refactor GrampsDb and clean RelLib deps
* src/GrampsLocale/_GrampsLocale.py: refactor GrampsDb and clean RelLib deps
* src/GrampsLocale/__init__.py: refactor GrampsDb and clean RelLib deps
* src/plugins/WriteCD.py: refactor GrampsDb and clean RelLib deps
* src/plugins/Checkpoint.py: refactor GrampsDb and clean RelLib deps
* src/plugins/WritePkg.py: refactor GrampsDb and clean RelLib deps
* src/plugins/ReadPkg.py: refactor GrampsDb and clean RelLib deps
* src/BasicUtils: refactor GrampsDb and clean RelLib deps
* src/BasicUtils/__init__.py: refactor GrampsDb and clean RelLib deps
* src/BasicUtils/BasicUtils.py: refactor GrampsDb and clean RelLib deps
* src/Errors.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_WriteGrdb.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_WriteGedcom.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_ReadGrdb.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_ReadGedcom.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_GedcomInfo.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_WriteXML.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_ReadXML.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/gedcomimport.glade: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/__init__.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_GedTokens.py: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/gedcomexport.glade: refactor GrampsDb and clean RelLib deps
* src/GrampsDbUtils/_GrampsDbWRFactories.py: refactor GrampsDb and clean RelLib deps
* src/BasicUtils.py: refactor GrampsDb and clean RelLib deps
* src/ArgHandler.py: refactor GrampsDb and clean RelLib deps
* src/GrampsLocale.py: refactor GrampsDb and clean RelLib deps
* src/DbLoader.py: refactor GrampsDb and clean RelLib deps
2007-02-02 Alex Roitman <shura@gramps-project.org>
* src/plugins/WriteCD.py: Properly encode URI.

View File

@ -50,6 +50,7 @@ from gettext import gettext as _
#-------------------------------------------------------------------------
import const
import GrampsDb
import GrampsDbUtils
import Mime
import QuestionDialog
import Config
@ -452,7 +453,7 @@ class ArgHandler:
if format == 'grdb':
filename = os.path.normpath(os.path.abspath(filename))
try:
GrampsDb.gramps_db_reader_factory(const.app_gramps)(
GrampsDbUtils.gramps_db_reader_factory(const.app_gramps)(
self.state.db,filename,empty)
except:
print "Error importing %s" % filename
@ -461,14 +462,14 @@ class ArgHandler:
filename = os.path.normpath(os.path.abspath(filename))
try:
# Cheating here to use default encoding
from GrampsDb._ReadGedcom import import2
from GrampsDbUtils._ReadGedcom import import2
import2(self.state.db,filename,None,None,False)
except:
print "Error importing %s" % filename
os._exit(1)
elif format == 'gramps-xml':
try:
GrampsDb.gramps_db_reader_factory(const.app_gramps_xml)(
GrampsDbUtils.gramps_db_reader_factory(const.app_gramps_xml)(
self.state.db,filename,None,self.cl)
except:
print "Error importing %s" % filename
@ -518,7 +519,7 @@ class ArgHandler:
dbname = os.path.join(tmpdir_path,const.xmlFile)
try:
GrampsDb.gramps_db_reader_factory(const.app_gramps_xml)(
GrampsDbUtils.gramps_db_reader_factory(const.app_gramps_xml)(
self.state.db,dbname,None)
except:
print "Error importing %s" % filename
@ -551,14 +552,14 @@ class ArgHandler:
filename = os.path.abspath(os.path.expanduser(filename))
if format == 'grdb':
try:
GrampsDb.gramps_db_writer_factory(const.app_gramps)(
GrampsDbUtils.gramps_db_writer_factory(const.app_gramps)(
self.state.db,filename)
except:
print "Error exporting %s" % filename
os._exit(1)
elif format == 'gedcom':
try:
gw = GrampsDb.GedcomWriter(self.state.db,None,1,filename)
gw = GrampsDbUtils.GedcomWriter(self.state.db,None,1,filename)
ret = gw.export_data(filename)
except:
print "Error exporting %s" % filename
@ -567,7 +568,7 @@ class ArgHandler:
filename = os.path.normpath(os.path.abspath(filename))
if filename:
try:
g = GrampsDb.XmlWriter(self.state.db,None,0,1)
g = GrampsDbUtils.XmlWriter(self.state.db,None,0,1)
ret = g.write(filename)
except:
print "Error exporting %s" % filename

View File

@ -0,0 +1 @@
from BasicUtils import UpdateCallback

View File

@ -52,6 +52,7 @@ import const
import Config
import Mime
import GrampsDb
import GrampsDbUtils
import Utils
from PluginUtils import import_list
import QuestionDialog
@ -334,7 +335,7 @@ class DbLoader:
if filetype in (const.app_gramps,
const.app_gramps_xml,
const.app_gedcom):
importer = GrampsDb.gramps_db_reader_factory(filetype)
importer = GrampsDbUtils.gramps_db_reader_factory(filetype)
self.do_import(choose,importer,filename)
return True

View File

@ -100,17 +100,6 @@ class GConfSchemaError(Exception):
def __str__(self):
return self.value
class FileVersionError(Exception):
"""
Error used to report that a file could not be read because
it is written in an unsupported version of the file format.
"""
def __init__(self,value):
Exception.__init__(self)
self.value = value
def __str__(self):
return self.value
class WindowActiveError(Exception):
"""Error used to report that the request window is already displayed."""

View File

@ -59,7 +59,7 @@ import Config
import GrampsDisplay
import Assistant
import Errors
from GrampsDb import gramps_db_writer_factory
from GrampsDbUtils import gramps_db_writer_factory
#-------------------------------------------------------------------------
#
# Exporter

View File

@ -47,8 +47,8 @@ log = logging.getLogger(".GrampsDb")
from RelLib import *
from _GrampsDbBase import *
from _DbUtils import db_copy
import const
import Errors
import _GrampsDbConst as const
from _GrampsDbExceptions import FileVersionError
from BasicUtils import UpdateCallback
_MINVERSION = 5
@ -1056,11 +1056,11 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
self.metadata = None
self.env = None
self.db_is_open = False
raise Errors.FileVersionError(
"The database version is not supported by this "
"version of GRAMPS.\nPlease upgrade to the "
"corresponding version or use XML for porting"
"data between different database versions.")
raise FileVersionError(
"The database version is not supported by this "
"version of GRAMPS.\nPlease upgrade to the "
"corresponding version or use XML for porting"
"data between different database versions.")
def close(self):
if not self.db_is_open:

View File

@ -51,7 +51,6 @@ log = logging.getLogger(".GrampsDb")
#
#-------------------------------------------------------------------------
from RelLib import *
import Config
from _GrampsDBCallback import GrampsDBCallback
#-------------------------------------------------------------------------
@ -59,26 +58,10 @@ from _GrampsDBCallback import GrampsDBCallback
# constants
#
#-------------------------------------------------------------------------
from _GrampsDbConst import *
_UNDO_SIZE = 1000
PERSON_KEY = 0
FAMILY_KEY = 1
SOURCE_KEY = 2
EVENT_KEY = 3
MEDIA_KEY = 4
PLACE_KEY = 5
REPOSITORY_KEY = 6
REFERENCE_KEY = 7
PERSON_COL_KEY = 'columns'
CHILD_COL_KEY = 'child_columns'
PLACE_COL_KEY = 'place_columns'
SOURCE_COL_KEY = 'source_columns'
MEDIA_COL_KEY = 'media_columns'
REPOSITORY_COL_KEY = 'repository_columns'
EVENT_COL_KEY = 'event_columns'
FAMILY_COL_KEY = 'family_columns'
# The following two dictionaries provide fast translation
# between the primary class names and the keys used to reference
@ -180,6 +163,10 @@ class GrampsDbBase(GrampsDBCallback):
database interfaces.
"""
# This holds a reference to the gramps Config module if
# it is available, it is setup by the factory methods.
__config__ = None
__signals__ = {
'person-add' : (list, ),
'person-update' : (list, ),
@ -227,6 +214,27 @@ class GrampsDbBase(GrampsDBCallback):
"""
GrampsDBCallback.__init__(self)
# If we have the gramps Config module available
# then use it to get the prefix values, if
# not then just use the default values.
if self.__class__.__config__ != None:
IPREFIX = Config.get(Config.IPREFIX)
OPREFIX = Config.get(Config.OPREFIX)
FPREFIX = Config.get(Config.FPREFIX)
SPREFIX = Config.get(Config.SPREFIX)
PPREFIX = Config.get(Config.PPREFIX)
EPREFIX = Config.get(Config.EPREFIX)
RPREFIX = Config.get(Config.RPREFIX)
else:
FPREFIX = 'F%04d'
EPREFIX = 'E%04d'
RPREFIX = 'R%04d'
IPREFIX = 'I%04d'
OPREFIX = 'O%04d'
PPREFIX = 'P%04d'
SPREFIX = 'S%04d'
self.readonly = False
self.rand = random.Random(time.time())
self.smap_index = 0
@ -252,13 +260,13 @@ class GrampsDbBase(GrampsDBCallback):
self.url_types = set()
self.media_attributes = set()
self.set_person_id_prefix(Config.get(Config.IPREFIX))
self.set_object_id_prefix(Config.get(Config.OPREFIX))
self.set_family_id_prefix(Config.get(Config.FPREFIX))
self.set_source_id_prefix(Config.get(Config.SPREFIX))
self.set_place_id_prefix(Config.get(Config.PPREFIX))
self.set_event_id_prefix(Config.get(Config.EPREFIX))
self.set_repository_id_prefix(Config.get(Config.RPREFIX))
self.set_person_id_prefix(IPREFIX)
self.set_object_id_prefix(OPREFIX)
self.set_family_id_prefix(FPREFIX)
self.set_source_id_prefix(SPREFIX)
self.set_place_id_prefix(PPREFIX)
self.set_event_id_prefix(EPREFIX)
self.set_repository_id_prefix(RPREFIX)
self.open = 0
self.genderStats = GenderStats()

View File

@ -0,0 +1,44 @@
import os
#-------------------------------------------------------------------------
#
# constants
#
#-------------------------------------------------------------------------
if os.environ.has_key('USERPROFILE'):
user_home = os.environ['USERPROFILE']
home_dir = os.path.join(user_home,'gramps')
else:
user_home = os.environ['HOME']
home_dir = os.path.join(user_home,'.gramps')
bsddbenv_dir = os.path.join(home_dir,"bsddbenv")
env_dir = os.path.join(home_dir,"env")
app_gramps = "application/x-gramps"
app_gramps_xml = "application/x-gramps-xml"
app_gedcom = "application/x-gedcom"
app_gramps_package = "application/x-gramps-package"
app_geneweb = "application/x-geneweb"
app_vcard = ["text/x-vcard","text/x-vcalendar"]
PERSON_KEY = 0
FAMILY_KEY = 1
SOURCE_KEY = 2
EVENT_KEY = 3
MEDIA_KEY = 4
PLACE_KEY = 5
REPOSITORY_KEY = 6
REFERENCE_KEY = 7
PERSON_COL_KEY = 'columns'
CHILD_COL_KEY = 'child_columns'
PLACE_COL_KEY = 'place_columns'
SOURCE_COL_KEY = 'source_columns'
MEDIA_COL_KEY = 'media_columns'
REPOSITORY_COL_KEY = 'repository_columns'
EVENT_COL_KEY = 'event_columns'
FAMILY_COL_KEY = 'family_columns'

View File

@ -30,3 +30,16 @@ class GrampsDbException(Exception):
def __str__(self):
return repr(self.value)
class FileVersionError(Exception):
"""
Error used to report that a file could not be read because
it is written in an unsupported version of the file format.
"""
def __init__(self,value):
Exception.__init__(self)
self.value = value
def __str__(self):
return self.value

View File

@ -38,8 +38,18 @@ required e.g.:
> GrampsDb.gramps_db_reader_factory(db_type = const.app_gedcom)
"""
import const
import _GrampsDbConst as const
import logging
log = logging.getLogger(".GrampDb")
try:
import Config
config = Config
except:
log.warn("No Config module available, using defaults.")
config = None
from _GrampsDbExceptions import GrampsDbException
def gramps_db_factory(db_type):
@ -64,60 +74,10 @@ def gramps_db_factory(db_type):
raise GrampsDbException("Attempt to create unknown "
"database backend class: "
"db_type = %s" % (str(db_type),))
cls.__config__ = config
return cls
def gramps_db_writer_factory(db_type):
"""Factory class for obtaining a Gramps database writers.
@param db_type: the type of backend required.
@type db_type: one of the app_* constants in const.py
Raises GrampsDbException if the db_type is not recognised.
"""
if db_type == const.app_gramps:
import _WriteGrdb as WriteGrdb
md = WriteGrdb.exportData
elif db_type == const.app_gramps_xml:
import _WriteXML as WriteXML
md = WriteXML.exportData
elif db_type == const.app_gedcom:
import _WriteGedcom as WriteGedcom
md = WriteGedcom.exportData
else:
raise GrampsDbException("Attempt to create a database "
"writer for unknown format: "
"db_type = %s" % (str(db_type),))
return md
def gramps_db_reader_factory(db_type):
"""Factory class for obtaining a Gramps database writers.
@param db_type: the type of backend required.
@type db_type: one of the app_* constants in const.py
Raises GrampsDbException if the db_type is not recognised.
"""
if db_type == const.app_gramps:
import _ReadGrdb as ReadGrdb
md = ReadGrdb.importData
elif db_type == const.app_gramps_xml:
import _ReadXML as ReadXML
md = ReadXML.importData
elif db_type == const.app_gedcom:
import _ReadGedcom as ReadGedcom
md = ReadGedcom.importData
else:
raise GrampsDbException("Attempt to create a database "
"reader for unknown format: "
"db_type = %s" % (str(db_type),))
return md

View File

@ -25,13 +25,16 @@ Provides the GRAMPS DB interface for supporting in-memory editing
of GRAMPS XML format.
"""
import logging
log = logging.getLogger(".GrampsDb")
from RelLib import *
from _GrampsInMemDB import *
from _GrampsDbExceptions import GrampsDbException
from _ReadXML import importData
from _WriteXML import quick_write
from _DbUtils import db_copy
#-------------------------------------------------------------------------
#
# GrampsXMLDB
@ -53,6 +56,12 @@ class GrampsXMLDB(GrampsInMemDB):
GrampsInMemDB.load(self, name, callback, mode)
self.id_trans = {}
try:
from GrampsDbUtils._ReadXML import importData
except:
log.warning("Failed to load XML reader", exc_info=True)
raise GrampsDbException("Failed to load XML reader")
try:
importData(self, name, callback, use_trans=False)
except OSError, IOError:
@ -68,12 +77,25 @@ class GrampsXMLDB(GrampsInMemDB):
GrampsInMemDB.load(self,filename,callback)
self.bookmarks.set(self.metadata.get('bookmarks',[]))
self.db_is_open = True
try:
from GrampsDbUtils._WriteXML import quick_write
except:
log.warning("Failed to load XML writer", exc_info=True)
raise GrampsDbException("Failed to load XML writer")
quick_write(self,self.full_name,callback)
return 1
def close(self):
if not self.db_is_open:
return
try:
from GrampsDbUtils._WriteXML import quick_write
except:
log.warning("Failed to load XML writer", exc_info=True)
raise GrampsDbException("Failed to load XML writer")
if not self.readonly and len(self.undodb) > 0:
quick_write(self,self.full_name)
self.db_is_open = False

View File

@ -41,18 +41,12 @@ information.
from _GrampsDbBase import DbState, GrampsDbBase
from _GrampsDbFactories import \
gramps_db_factory, \
gramps_db_writer_factory, \
gramps_db_reader_factory
gramps_db_factory
from _ReadGedcom import GedcomParser
from _WriteGedcom import GedcomWriter
from _WriteXML import XmlWriter
from _GrampsDbExceptions import GrampsDbException
from _GrampsDbExceptions import GrampsDbException, FileVersionError
from _GrampsDBCallback import GrampsDBCallback
from _DbUtils import *
import _GrampsDbConst as GrampsDbConst

View File

@ -0,0 +1,102 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2004-2005 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
"""
This module contains factory methods for accessing the different
GrampsDb backends. These methods should be used obtain the correct class
for a database backend.
The app_* constants in const.py can be used to indicate which backend is
required e.g.:
> # To get the class for the grdb backend
> db_class = GrampsDb.gramps_db_factory(db_type = const.app_gramps)
>
> # To get a XML writer
> GrampsDb.gramps_db_writer_factory(db_type = const.app_gramps_xml)
>
> # To get a Gedcom reader
> GrampsDb.gramps_db_reader_factory(db_type = const.app_gedcom)
"""
import const
import logging
log = logging.getLogger(".GrampDb")
from GrampsDb import GrampsDbException
def gramps_db_writer_factory(db_type):
"""Factory class for obtaining a Gramps database writers.
@param db_type: the type of backend required.
@type db_type: one of the app_* constants in const.py
Raises GrampsDbException if the db_type is not recognised.
"""
if db_type == const.app_gramps:
import _WriteGrdb as WriteGrdb
md = WriteGrdb.exportData
elif db_type == const.app_gramps_xml:
import _WriteXML as WriteXML
md = WriteXML.exportData
elif db_type == const.app_gedcom:
import _WriteGedcom as WriteGedcom
md = WriteGedcom.exportData
else:
raise GrampsDbException("Attempt to create a database "
"writer for unknown format: "
"db_type = %s" % (str(db_type),))
return md
def gramps_db_reader_factory(db_type):
"""Factory class for obtaining a Gramps database writers.
@param db_type: the type of backend required.
@type db_type: one of the app_* constants in const.py
Raises GrampsDbException if the db_type is not recognised.
"""
if db_type == const.app_gramps:
import _ReadGrdb as ReadGrdb
md = ReadGrdb.importData
elif db_type == const.app_gramps_xml:
import _ReadXML as ReadXML
md = ReadXML.importData
elif db_type == const.app_gedcom:
import _ReadGedcom as ReadGedcom
md = ReadGedcom.importData
else:
raise GrampsDbException("Attempt to create a database "
"reader for unknown format: "
"db_type = %s" % (str(db_type),))
return md

View File

@ -49,7 +49,6 @@ log = logging.getLogger(".GedcomImport")
#-------------------------------------------------------------------------
import const
import Errors
import Config
import RelLib
from DateHandler._DateParser import DateParser
import NameDisplay
@ -61,9 +60,16 @@ from ansel_utf8 import ansel_to_utf8
from _GedcomInfo import *
from _GedTokens import *
from QuestionDialog import ErrorDialog, WarningDialog
from _GrampsDbBase import EVENT_KEY
from GrampsDb._GrampsDbConst import EVENT_KEY
from BasicUtils import UpdateCallback
try:
import Config
DEFAULT_SOURCE = Config.get(Config.DEFAULT_SOURCE)
except:
log.warn("No Config module available using defaults.")
DEFAULT_SOURCE = False
#-------------------------------------------------------------------------
#
# Address/Place constants
@ -521,7 +527,7 @@ class GedcomParser(UpdateCallback):
self.added = set()
self.gedmap = GedcomInfoDB()
self.gedsource = self.gedmap.get_from_source_tag('GEDCOM 5.5')
self.use_def_src = Config.get(Config.DEFAULT_SOURCE)
self.use_def_src = DEFAULT_SOURCE
if self.use_def_src:
self.def_src = RelLib.Source()
fname = os.path.basename(filename).split('\\')[-1]

View File

@ -37,7 +37,7 @@ import sets
# Gramps Modules
#
#-------------------------------------------------------------------------
from _GrampsBSDDB import GrampsBSDDB
from GrampsDb._GrampsBSDDB import GrampsBSDDB
from QuestionDialog import ErrorDialog
from Errors import HandleError
from BasicUtils import UpdateCallback

View File

@ -52,7 +52,7 @@ import const
import Utils
import DateHandler
import NameDisplay
from _GrampsDbBase import \
from GrampsDb._GrampsDbConst import \
PERSON_KEY,FAMILY_KEY,SOURCE_KEY,EVENT_KEY,\
MEDIA_KEY,PLACE_KEY,REPOSITORY_KEY
from BasicUtils import UpdateCallback

View File

@ -51,7 +51,6 @@ import RelLib
from Filters import GenericFilter, Rules, build_filter_menu
import const
import _GedcomInfo as GedcomInfo
import Config
import Errors
import ansel_utf8
import Utils
@ -59,6 +58,15 @@ import NameDisplay
from QuestionDialog import *
from BasicUtils import UpdateCallback
try:
import Config
STARTUP = Config.STARTUP
STARTUP_VAL = Config.get(Config.STARTUP)
except:
log.warn("No Config module available using defaults.")
STARTUP = ('behavior','startup', 1)
STARTUP_VAL = 0
#------------------------------------------------------------------------
#
# Helper functions
@ -71,7 +79,7 @@ def iso8859(s):
return s.encode('iso-8859-1','replace')
def researcher_info_missing():
val = Config.get(Config.STARTUP)
val = STARTUP_VAL
if val < const.startup:
return True
return False
@ -470,7 +478,7 @@ class GedcomWriter(UpdateCallback):
'information. You need to fill these data in the '
'Preferences dialog.\n\n'
'However, most programs do not require it. '
'You may leave this empty if you want.'),Config.STARTUP)
'You may leave this empty if you want.'),STARTUP)
if self.option_box.cfilter == None:
self.plist = set(self.db.get_person_handles(sort_handles=False))

View File

@ -53,7 +53,7 @@ log = logging.getLogger(".WriteXML")
import const
import RelLib
from QuestionDialog import ErrorDialog
from _GrampsDbBase import \
from GrampsDb._GrampsDbConst import \
PERSON_KEY,FAMILY_KEY,SOURCE_KEY,EVENT_KEY,\
MEDIA_KEY,PLACE_KEY,REPOSITORY_KEY
from BasicUtils import UpdateCallback

View File

@ -0,0 +1,51 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2004-2006 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
"""
This package implements the GrampsDb database. It provides a number
of different backends for different storage mechanisms.
A number of importers and exporters are provided to convert between
the different backend formats.
To obtain a class that implements the backend required you should use the
gramps_db_factory method, likewise for writers use the gramps_db_writer_factory
method and for readers use the gramps_db_reader_factory method. For information
on using these factories see the _GrampsDbFactories.py file comments.
The package also contains GrampsDBCallback which provides signal/slot type
functionality to allow objects to hook into signals that are generated from
the database objects. Read the comments in _GrampsDBCallback.py for more
information.
"""
from _GrampsDbWRFactories import \
gramps_db_writer_factory, \
gramps_db_reader_factory
from _ReadGedcom import GedcomParser
from _WriteGedcom import GedcomWriter
from _WriteXML import XmlWriter

View File

@ -0,0 +1,2 @@
from _GrampsLocale import *

View File

@ -500,7 +500,7 @@ class ViewManager:
"""
Backup the current file as an XML file.
"""
import GrampsDb
import GrampsDbUtils
if self.state.db.undoindex > 0:
@ -516,7 +516,7 @@ class ViewManager:
self.uistate.set_busy_cursor(1)
self.uistate.progress.show()
self.uistate.push_message(self.state, _("Autobackup..."))
writer = GrampsDb.XmlWriter(self.state.db, self.uistate.pulse_progressbar, 0, 1)
writer = GrampsDbUtils.XmlWriter(self.state.db, self.uistate.pulse_progressbar, 0, 1)
writer.write(backup)
self.uistate.set_busy_cursor(0)
self.uistate.progress.hide()

View File

@ -46,7 +46,7 @@ import gtk.glade
# gramps modules
#
#-------------------------------------------------------------------------
import GrampsDb
import GrampsDbUtils
import Utils
import GrampsDisplay
import ManagedWindow
@ -238,7 +238,7 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow):
"""
proc = popen2.Popen3(cmd, True)
if checkin:
xmlwrite = GrampsDb.XmlWriter(self.db,self.callback,False,False)
xmlwrite = GrampsDbUtils.XmlWriter(self.db,self.callback,False,False)
xmlwrite.write_handle(proc.tochild)
else:
pass
@ -314,7 +314,7 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow):
if checkin:
# At this point, we have an existing archive file
xmlwrite = GrampsDb.XmlWriter(self.db,self.callback,False,False)
xmlwrite = GrampsDbUtils.XmlWriter(self.db,self.callback,False,False)
xmlwrite.write(archive_base)
proc = popen2.Popen3("ci %s" % archive_base,True)

View File

@ -53,7 +53,7 @@ import gtk
#
#-------------------------------------------------------------------------
import const
from GrampsDb import gramps_db_reader_factory
from GrampsDbUtils import gramps_db_reader_factory
from QuestionDialog import ErrorDialog
from PluginUtils import register_import

View File

@ -66,7 +66,7 @@ except:
# GRAMPS modules
#
#-------------------------------------------------------------------------
from GrampsDb import XmlWriter
from GrampsDbUtils import XmlWriter
import Mime
import const
import QuestionDialog

View File

@ -55,7 +55,7 @@ import gtk.glade
# GRAMPS modules
#
#-------------------------------------------------------------------------
from GrampsDb import XmlWriter
from GrampsDbUtils import XmlWriter
import Utils
from QuestionDialog import MissingMediaDialog
from PluginUtils import register_export