2007-06-03 Don Allingham <don@gramps-project.org>
* src/Simple/__init__.py: add svn: r8531
This commit is contained in:
@@ -46,7 +46,7 @@ class UpdateCallback:
|
||||
things during lenghty operations.
|
||||
"""
|
||||
|
||||
def __init__(self,callback,interval=1):
|
||||
def __init__(self, callback, interval=1):
|
||||
"""
|
||||
@param callback: a function with one arg to execute every so often
|
||||
@type callback: function
|
||||
|
||||
@@ -29,6 +29,15 @@ MOSTLYCLEANFILES = *pyc *pyo
|
||||
|
||||
GRAMPS_PY_MODPATH = ".."
|
||||
|
||||
docfiles=\
|
||||
_DateDisplay.py\
|
||||
_DateParser.py\
|
||||
_DateHandler.py\
|
||||
_DateUtils.py
|
||||
|
||||
docs:
|
||||
export PYTHONPATH='..'; epydoc --graph=umlclasstree -o ../html --url http://gramps-project.org --name GRAMPS --html $(docfiles)
|
||||
|
||||
pycheck:
|
||||
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
|
||||
pychecker $(pkgdata_PYTHON));
|
||||
|
||||
@@ -75,7 +75,7 @@ _KNOWN_FORMATS = {
|
||||
const.app_gedcom : _('GEDCOM'),
|
||||
}
|
||||
|
||||
_OPEN_FORMATS = [const.app_gramps_xml, const.app_gedcom]
|
||||
OPEN_FORMATS = [const.app_gramps_xml, const.app_gedcom]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -101,7 +101,7 @@ class DbLoader:
|
||||
add_xml_filter(choose)
|
||||
add_gedcom_filter(choose)
|
||||
|
||||
(box, type_selector) = format_maker(_OPEN_FORMATS)
|
||||
(box, type_selector) = format_maker(OPEN_FORMATS)
|
||||
choose.set_extra_widget(box)
|
||||
|
||||
choose.set_current_folder(get_default_dir())
|
||||
@@ -117,7 +117,7 @@ class DbLoader:
|
||||
filetype = Mime.get_type(filename)
|
||||
(the_path, the_file) = os.path.split(filename)
|
||||
choose.destroy()
|
||||
if filetype in _OPEN_FORMATS:
|
||||
if filetype in OPEN_FORMATS:
|
||||
self.read_file(filename, filetype)
|
||||
try:
|
||||
os.chdir(os.path.dirname(filename))
|
||||
@@ -213,7 +213,7 @@ class DbLoader:
|
||||
add_xml_filter(choose)
|
||||
add_gedcom_filter(choose)
|
||||
|
||||
(box, type_selector) = format_maker(_OPEN_FORMATS)
|
||||
(box, type_selector) = format_maker(OPEN_FORMATS)
|
||||
choose.set_extra_widget(box)
|
||||
|
||||
default_dir = get_default_dir()
|
||||
@@ -246,7 +246,7 @@ class DbLoader:
|
||||
str(msg))
|
||||
return ('','')
|
||||
# First we try our best formats
|
||||
if filetype not in _OPEN_FORMATS:
|
||||
if filetype not in OPEN_FORMATS:
|
||||
QuestionDialog.ErrorDialog(
|
||||
_("Could not open file: %s") % filename,
|
||||
_("Unknown type: %s") % filetype
|
||||
@@ -290,7 +290,7 @@ class DbLoader:
|
||||
add_xml_filter(choose)
|
||||
add_gedcom_filter(choose)
|
||||
|
||||
format_list = _OPEN_FORMATS[:]
|
||||
format_list = OPEN_FORMATS
|
||||
|
||||
# Add more data type selections if opening existing db
|
||||
for data in import_list:
|
||||
@@ -336,7 +336,7 @@ class DbLoader:
|
||||
return False
|
||||
|
||||
# First we try our best formats
|
||||
if filetype in _OPEN_FORMATS:
|
||||
if filetype in OPEN_FORMATS:
|
||||
importer = GrampsDbUtils.gramps_db_reader_factory(filetype)
|
||||
self.do_import(choose, importer, filename)
|
||||
return True
|
||||
@@ -549,7 +549,7 @@ def add_gramps_files_filter(chooser):
|
||||
"""
|
||||
mime_filter = gtk.FileFilter()
|
||||
mime_filter.set_name(_('All GRAMPS files'))
|
||||
for fmt in _OPEN_FORMATS:
|
||||
for fmt in OPEN_FORMATS:
|
||||
mime_filter.add_mime_type(fmt)
|
||||
chooser.add_filter(mime_filter)
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ pkgdata_PYTHON = \
|
||||
_DbUtils.py \
|
||||
_GrampsBSDDB.py\
|
||||
_GrampsDbBase.py\
|
||||
_GrampsCursor.py\
|
||||
_GrampsDBCallback.py\
|
||||
_GrampsDbExceptions.py\
|
||||
_GrampsDbFactories.py\
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,7 @@ from _DbUtils import db_copy
|
||||
import _GrampsDbConst as const
|
||||
from _GrampsDbExceptions import FileVersionError
|
||||
from BasicUtils import UpdateCallback
|
||||
from _GrampsCursor import GrampsCursor
|
||||
|
||||
_MINVERSION = 9
|
||||
_DBVERSION = 13
|
||||
@@ -1168,42 +1169,42 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
||||
transaction.add(key,handle,old_data,None)
|
||||
del_list.append(handle)
|
||||
|
||||
def _del_person(self,handle):
|
||||
def __del_person(self,handle):
|
||||
self.person_map.delete(str(handle),txn=self.txn)
|
||||
if not self.UseTXN:
|
||||
self.person_map.sync()
|
||||
|
||||
def _del_source(self,handle):
|
||||
def __del_source(self,handle):
|
||||
self.source_map.delete(str(handle),txn=self.txn)
|
||||
if not self.UseTXN:
|
||||
self.source_map.sync()
|
||||
|
||||
def _del_repository(self,handle):
|
||||
def __del_repository(self,handle):
|
||||
self.repository_map.delete(str(handle),txn=self.txn)
|
||||
if not self.UseTXN:
|
||||
self.repository_map.sync()
|
||||
|
||||
def _del_note(self,handle):
|
||||
def __del_note(self,handle):
|
||||
self.note_map.delete(str(handle),txn=self.txn)
|
||||
if not self.UseTXN:
|
||||
self.note_map.sync()
|
||||
|
||||
def _del_place(self,handle):
|
||||
def __del_place(self,handle):
|
||||
self.place_map.delete(str(handle),txn=self.txn)
|
||||
if not self.UseTXN:
|
||||
self.place_map.sync()
|
||||
|
||||
def _del_media(self,handle):
|
||||
def __del_media(self,handle):
|
||||
self.media_map.delete(str(handle),txn=self.txn)
|
||||
if not self.UseTXN:
|
||||
self.media_map.sync()
|
||||
|
||||
def _del_family(self,handle):
|
||||
def __del_family(self,handle):
|
||||
self.family_map.delete(str(handle),txn=self.txn)
|
||||
if not self.UseTXN:
|
||||
self.family_map.sync()
|
||||
|
||||
def _del_event(self,handle):
|
||||
def __del_event(self,handle):
|
||||
self.event_map.delete(str(handle),txn=self.txn)
|
||||
if not self.UseTXN:
|
||||
self.event_map.sync()
|
||||
@@ -1325,7 +1326,7 @@ class GrampsDBDir(GrampsDbBase,UpdateCallback):
|
||||
return self._get_obj_from_gramps_id(val,self.nid_trans,Note,
|
||||
self.note_map)
|
||||
|
||||
def _commit_base(self, obj, data_map, key, update_list, add_list,
|
||||
def __commit_base(self, obj, data_map, key, update_list, add_list,
|
||||
transaction, change_time):
|
||||
"""
|
||||
Commits the specified object to the database, storing the changes
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,6 +39,7 @@ import time
|
||||
#-------------------------------------------------------------------------
|
||||
from RelLib import *
|
||||
from _GrampsDbBase import *
|
||||
from _GrampsCursor import GrampsCursor
|
||||
|
||||
class GrampsInMemCursor(GrampsCursor):
|
||||
"""
|
||||
@@ -81,26 +82,7 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
def __init__(self):
|
||||
"""creates a new GrampsDB"""
|
||||
GrampsDbBase.__init__(self)
|
||||
self.person_map = {}
|
||||
self.name_group = {}
|
||||
self.family_map = {}
|
||||
self.place_map = {}
|
||||
self.source_map = {}
|
||||
self.repository_map = {}
|
||||
self.note_map = {}
|
||||
self.media_map = {}
|
||||
self.event_map = {}
|
||||
self.metadata = {}
|
||||
self.filename = ""
|
||||
self.id_trans = {}
|
||||
self.pid_trans = {}
|
||||
self.fid_trans = {}
|
||||
self.eid_trans = {}
|
||||
self.sid_trans = {}
|
||||
self.rid_trans = {}
|
||||
self.nid_trans = {}
|
||||
self.oid_trans = {}
|
||||
self.undodb = []
|
||||
|
||||
def load(self,name,callback,mode="w"):
|
||||
self.full_name = name
|
||||
@@ -181,42 +163,42 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
if do_remove:
|
||||
self.surname_list.remove(unicode(name))
|
||||
|
||||
def _del_person(self,handle):
|
||||
def __del_person(self,handle):
|
||||
person = self.get_person_from_handle(str(handle))
|
||||
del self.id_trans[person.get_gramps_id()]
|
||||
del self.person_map[str(handle)]
|
||||
|
||||
def _del_source(self,handle):
|
||||
def __del_source(self,handle):
|
||||
source = self.get_source_from_handle(str(handle))
|
||||
del self.sid_trans[source.get_gramps_id()]
|
||||
del self.source_map[str(handle)]
|
||||
|
||||
def _del_repository(self,handle):
|
||||
def __del_repository(self,handle):
|
||||
repository = self.get_repository_from_handle(str(handle))
|
||||
del self.rid_trans[repository.get_gramps_id()]
|
||||
del self.repository_map[str(handle)]
|
||||
|
||||
def _del_note(self,handle):
|
||||
def __del_note(self,handle):
|
||||
note = self.get_note_from_handle(str(handle))
|
||||
del self.nid_trans[note.get_gramps_id()]
|
||||
del self.note_map[str(handle)]
|
||||
|
||||
def _del_place(self,handle):
|
||||
def __del_place(self,handle):
|
||||
place = self.get_place_from_handle(str(handle))
|
||||
del self.pid_trans[place.get_gramps_id()]
|
||||
del self.place_map[str(handle)]
|
||||
|
||||
def _del_media(self,handle):
|
||||
def __del_media(self,handle):
|
||||
obj = self.get_object_from_handle(str(handle))
|
||||
del self.oid_trans[obj.get_gramps_id()]
|
||||
del self.media_map[str(handle)]
|
||||
|
||||
def _del_family(self,handle):
|
||||
def __del_family(self,handle):
|
||||
family = self.get_family_from_handle(str(handle))
|
||||
del self.fid_trans[family.get_gramps_id()]
|
||||
del self.family_map[str(handle)]
|
||||
|
||||
def _del_event(self,handle):
|
||||
def __del_event(self,handle):
|
||||
event = self.get_event_from_handle(str(handle))
|
||||
del self.eid_trans[event.get_gramps_id()]
|
||||
del self.event_map[str(handle)]
|
||||
@@ -263,7 +245,7 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
trans_map[data[self.ID_INDEX]] = str(handle)
|
||||
self.emit(signal, ([handle], ))
|
||||
|
||||
def _commit_inmem_base(self,obj,db_map,trans_map):
|
||||
def __commit_inmem_base(self,obj,db_map,trans_map):
|
||||
if self.readonly or not obj or not obj.get_handle():
|
||||
return False
|
||||
gid = obj.gramps_id
|
||||
@@ -276,44 +258,44 @@ class GrampsInMemDB(GrampsDbBase):
|
||||
return True
|
||||
|
||||
def commit_person(self,person,transaction,change_time=None):
|
||||
if not self._commit_inmem_base(person,self.person_map,self.id_trans):
|
||||
if not self.__commit_inmem_base(person,self.person_map,self.id_trans):
|
||||
return
|
||||
GrampsDbBase.commit_person(self,person,transaction,change_time)
|
||||
|
||||
def commit_place(self,place,transaction,change_time=None):
|
||||
if not self._commit_inmem_base(place,self.place_map,self.pid_trans):
|
||||
if not self.__commit_inmem_base(place,self.place_map,self.pid_trans):
|
||||
return
|
||||
GrampsDbBase.commit_place(self,place,transaction,change_time)
|
||||
|
||||
def commit_family(self,family,transaction,change_time=None):
|
||||
if not self._commit_inmem_base(family,self.family_map,self.fid_trans):
|
||||
if not self.__commit_inmem_base(family,self.family_map,self.fid_trans):
|
||||
return
|
||||
GrampsDbBase.commit_family(self,family,transaction,change_time)
|
||||
|
||||
def commit_event(self,event,transaction,change_time=None):
|
||||
if not self._commit_inmem_base(event,self.event_map,self.eid_trans):
|
||||
if not self.__commit_inmem_base(event,self.event_map,self.eid_trans):
|
||||
return
|
||||
GrampsDbBase.commit_event(self,event,transaction,change_time)
|
||||
|
||||
def commit_media_object(self,obj,transaction,change_time=None):
|
||||
if not self._commit_inmem_base(obj,self.media_map,self.oid_trans):
|
||||
if not self.__commit_inmem_base(obj,self.media_map,self.oid_trans):
|
||||
return
|
||||
GrampsDbBase.commit_media_object(self,obj,transaction,change_time)
|
||||
|
||||
def commit_source(self,source,transaction,change_time=None):
|
||||
if not self._commit_inmem_base(source,self.source_map,self.sid_trans):
|
||||
if not self.__commit_inmem_base(source,self.source_map,self.sid_trans):
|
||||
return
|
||||
GrampsDbBase.commit_source(self,source,transaction,change_time)
|
||||
|
||||
def commit_repository(self,repository,transaction,change_time=None):
|
||||
if not self._commit_inmem_base(repository,self.repository_map,
|
||||
if not self.__commit_inmem_base(repository,self.repository_map,
|
||||
self.rid_trans):
|
||||
return
|
||||
GrampsDbBase.commit_repository(self,repository,transaction,change_time)
|
||||
|
||||
def commit_note(self,note,transaction,change_time=None):
|
||||
if not self._commit_inmem_base(note, self.note_map,
|
||||
self.nid_trans):
|
||||
if not self.__commit_inmem_base(note, self.note_map,
|
||||
self.nid_trans):
|
||||
return
|
||||
GrampsDbBase.commit_note(self,note,transaction,change_time)
|
||||
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2007 Richard Taylor
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
"""
|
||||
This module provides a progess dialog for displaying the status of
|
||||
long running operations.
|
||||
@@ -45,7 +65,7 @@ class ProgressMonitor(object):
|
||||
popup_time = None):
|
||||
"""
|
||||
@param dialog_class: A class used to display the progress dialog.
|
||||
@type dialog_class: L{_GtkProgressDialog} or the same interface.
|
||||
@type dialog_class: _GtkProgressDialog or the same interface.
|
||||
|
||||
@param dialog_class_params: A tuple that will be used as the initial
|
||||
arguments to the dialog_class, this might be used for passing in
|
||||
@@ -138,4 +158,4 @@ class ProgressMonitor(object):
|
||||
facade.status_obj.disconnect(facade.end_cb_id)
|
||||
del self._status_stack[idx]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ gdir_PYTHON = \
|
||||
MOSTLYCLEANFILES = *pyc *pyo
|
||||
|
||||
# Which modules to document
|
||||
docmodules = RelLib DateHandler GrampsDb Filters ReportBase GrampsDbUtils
|
||||
docmodules = RelLib DateHandler GrampsDb Simple #Filters ReportBase GrampsDbUtils
|
||||
|
||||
pycheck:
|
||||
for d in $(SUBDIRS) ; do \
|
||||
@@ -93,8 +93,7 @@ pycheck:
|
||||
pychecker $(gdir_PYTHON)
|
||||
|
||||
docs:
|
||||
epydoc -o doc --url http://gramps-project.org --name GRAMPS --html $(docmodules)
|
||||
epydoc --pdf $(docmodules)
|
||||
epydoc -v -o html --html --exclude gtk --no-private --show-imports --url=http://gramps-project.org --graph=umlclasstree $(docmodules)
|
||||
|
||||
cmdplug:
|
||||
./build_cmdplug
|
||||
|
||||
@@ -542,9 +542,6 @@ class SimpleAccess:
|
||||
|
||||
@param obj: Person or Family
|
||||
@type obj: L{RelLib.Person} or L{RelLib.Family}
|
||||
@param restrict: Optional list of strings that will limit the types
|
||||
of events to those of the specfied types.
|
||||
@type restrict: list
|
||||
@return: list of events assocated with the object
|
||||
@rtype: list
|
||||
"""
|
||||
|
||||
31
src/Simple/__init__.py
Normal file
31
src/Simple/__init__.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2001 David R. Hampton
|
||||
# Copyright (C) 2001-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: __init__.py 7972 2007-01-24 19:45:57Z pez4brian $
|
||||
|
||||
"Simple access routines"
|
||||
|
||||
__author__ = "Donald N. Allingham"
|
||||
__version__ = "$Revision: 7972 $"
|
||||
|
||||
from _SimpleAccess import *
|
||||
from _SimpleDoc import *
|
||||
|
||||
Reference in New Issue
Block a user