2008-02-22 Raphael Ackermann <raphael.ackermann@gmail.com>
* ViewManager.py * gen/db/iterator.py * gen/db/base.py * gen/db/dbconst.py * gen/db/cursor.py * gen/db/__init__.py * gen/db/exceptions.py * gen/db/dbdir.py * gen/lib/srcbase.py * gen/callback: deleted unused directory * plugins/ReorderIds.py: pylint and pep8 doc fixes svn: r10099
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
||||
2008-02-22 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||
* ViewManager.py
|
||||
* gen/db/iterator.py
|
||||
* gen/db/base.py
|
||||
* gen/db/dbconst.py
|
||||
* gen/db/cursor.py
|
||||
* gen/db/__init__.py
|
||||
* gen/db/exceptions.py
|
||||
* gen/db/dbdir.py
|
||||
* gen/lib/srcbase.py
|
||||
* gen/callback: deleted unused directory
|
||||
* plugins/ReorderIds.py:
|
||||
pylint and pep8 doc fixes
|
||||
|
||||
2008-02-23 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||
* src/date_test.py: removed file; moved tests to:
|
||||
* src/gen/lib/test/date_test.py (suite3): new tests
|
||||
|
@@ -19,7 +19,6 @@
|
||||
#
|
||||
|
||||
from base import *
|
||||
#from callback import *
|
||||
from cursor import *
|
||||
from dbconst import *
|
||||
from dbdir import *
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -21,9 +21,10 @@
|
||||
class GrampsCursor:
|
||||
"""
|
||||
Provides a basic iterator that allows the user to cycle through
|
||||
the elements in a particular map. A cursor should never be
|
||||
directly instantiated. Instead, in should be created by the
|
||||
database class.
|
||||
the elements in a particular map.
|
||||
|
||||
A cursor should never be directly instantiated. Instead, in should be
|
||||
created by the database class.
|
||||
|
||||
A cursor should only be used for a single pass through the
|
||||
database. If multiple passes are needed, multiple cursors
|
||||
@@ -32,12 +33,12 @@ class GrampsCursor:
|
||||
|
||||
def first(self):
|
||||
"""
|
||||
Returns the first (index, data) pair in the database. This
|
||||
should be called before the first call to next(). Note that
|
||||
the data return is in the format of the serialized format
|
||||
stored in the database, not in the more usable class object.
|
||||
The data should be converted to a class using the class's
|
||||
unserialize method.
|
||||
Return the first (index, data) pair in the database.
|
||||
|
||||
This should be called before the first call to next(). Note that the
|
||||
data return is in the format of the serialized format stored in the
|
||||
database, not in the more usable class object. The data should be
|
||||
converted to a class using the class's unserialize method.
|
||||
|
||||
If no data is available, None is returned.
|
||||
"""
|
||||
@@ -45,11 +46,12 @@ class GrampsCursor:
|
||||
|
||||
def next(self):
|
||||
"""
|
||||
Returns the next (index, data) pair in the database. Like
|
||||
the first() method, the data return is in the format of the
|
||||
serialized format stored in the database, not in the more
|
||||
usable class object. The data should be converted to a class
|
||||
using the class's unserialize method.
|
||||
Return the next (index, data) pair in the database.
|
||||
|
||||
Like the first() method, the data return is in the format of the
|
||||
serialized format stored in the database, not in the more usable class
|
||||
object. The data should be converted to a class using the class's
|
||||
unserialize method.
|
||||
|
||||
None is returned when no more data is available.
|
||||
"""
|
||||
@@ -57,15 +59,16 @@ class GrampsCursor:
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Closes the cursor. This should be called when the user is
|
||||
finished using the cursor, freeing up the cursor's resources.
|
||||
Close the cursor.
|
||||
|
||||
This should be called when the user is finished using the cursor,
|
||||
freeing up the cursor's resources.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_length(self):
|
||||
"""
|
||||
Returns the number of records in the table referenced by the
|
||||
cursor
|
||||
Return the number of records in the table referenced by the cursor.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
@@ -21,9 +21,8 @@
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Provides the Berkeley DB (DBDir) database backend for GRAMPS
|
||||
Provides the Berkeley DB (DBDir) database backend for GRAMPS.
|
||||
This is used since GRAMPS version 3.0
|
||||
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -51,9 +50,9 @@ from gen.lib import (GenderStats, Person, Family, Event, Place, Source,
|
||||
MediaObject, Repository, Note)
|
||||
from gen.db import (GrampsDbBase, KEY_TO_CLASS_MAP, CLASS_TO_KEY_MAP,
|
||||
REFERENCE_KEY, Transaction)
|
||||
from exceptions import FileVersionError
|
||||
from gen.db.exceptions import FileVersionError
|
||||
from BasicUtils import UpdateCallback
|
||||
from cursor import GrampsCursor
|
||||
from gen.db.cursor import GrampsCursor
|
||||
import Errors
|
||||
|
||||
_MINVERSION = 9
|
||||
@@ -84,7 +83,8 @@ REF_MAP = "reference_map"
|
||||
REF_PRI = "primary_map"
|
||||
REF_REF = "referenced_map"
|
||||
|
||||
DBERRS = (db.DBRunRecoveryError, db.DBAccessError, db.DBPageNotFoundError, db.DBInvalidArgError)
|
||||
DBERRS = (db.DBRunRecoveryError, db.DBAccessError,
|
||||
db.DBPageNotFoundError, db.DBInvalidArgError)
|
||||
|
||||
|
||||
def find_surname(key, data):
|
||||
@@ -159,7 +159,7 @@ class GrampsDBDirAssocCursor(GrampsCursor):
|
||||
return self.source.stat()['ndata']
|
||||
|
||||
class GrampsDBDirDupCursor(GrampsDBDirAssocCursor):
|
||||
"""Cursor that includes handling for duplicate keys"""
|
||||
"""Cursor that includes handling for duplicate keys."""
|
||||
|
||||
def set(self, key):
|
||||
return self.cursor.set(str(key))
|
||||
@@ -173,11 +173,14 @@ class GrampsDBDirDupCursor(GrampsDBDirAssocCursor):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
"""GRAMPS database object. This object is a base class for other
|
||||
objects."""
|
||||
"""
|
||||
GRAMPS database object.
|
||||
|
||||
This object is a base class for other objects.
|
||||
"""
|
||||
|
||||
def __init__(self, use_txn = True):
|
||||
"""creates a new GrampsDB"""
|
||||
"""Create a new GrampsDB."""
|
||||
|
||||
GrampsDbBase.__init__(self)
|
||||
self.txn = None
|
||||
@@ -254,49 +257,49 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def has_person_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Person database.
|
||||
Return True if the handle exists in the current Person database.
|
||||
"""
|
||||
return self.__has_handle(self.person_map, handle)
|
||||
|
||||
def has_family_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Family database.
|
||||
Return True if the handle exists in the current Family database.
|
||||
"""
|
||||
return self.__has_handle(self.family_map, handle)
|
||||
|
||||
def has_object_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current MediaObjectdatabase.
|
||||
Return True if the handle exists in the current MediaObjectdatabase.
|
||||
"""
|
||||
return self.__has_handle(self.media_map, handle)
|
||||
|
||||
def has_repository_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Repository database.
|
||||
Return True if the handle exists in the current Repository database.
|
||||
"""
|
||||
return self.__has_handle(self.repository_map, handle)
|
||||
|
||||
def has_note_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Note database.
|
||||
Return True if the handle exists in the current Note database.
|
||||
"""
|
||||
return self.__has_handle(self.note_map, handle)
|
||||
|
||||
def has_event_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Repository database.
|
||||
Return True if the handle exists in the current Event database.
|
||||
"""
|
||||
return self.__has_handle(self.event_map, handle)
|
||||
|
||||
def has_place_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Repository database.
|
||||
Return True if the handle exists in the current Place database.
|
||||
"""
|
||||
return self.__has_handle(self.place_map, handle)
|
||||
|
||||
def has_source_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current Repository database.
|
||||
Return True if the handle exists in the current Source database.
|
||||
"""
|
||||
return self.__has_handle(self.source_map, handle)
|
||||
|
||||
@@ -347,14 +350,16 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_reference_map_primary_cursor(self):
|
||||
try:
|
||||
return GrampsDBDirDupCursor(self.reference_map_primary_map, self.txn)
|
||||
return GrampsDBDirDupCursor(self.reference_map_primary_map,
|
||||
self.txn)
|
||||
except DBERRS, msg:
|
||||
self.__log_error()
|
||||
raise Errors.DbError(msg)
|
||||
|
||||
def get_reference_map_referenced_cursor(self):
|
||||
try:
|
||||
return GrampsDBDirDupCursor(self.reference_map_referenced_map, self.txn)
|
||||
return GrampsDBDirDupCursor(self.reference_map_referenced_map,
|
||||
self.txn)
|
||||
except DBERRS, msg:
|
||||
self.__log_error()
|
||||
raise Errors.DbError(msg)
|
||||
@@ -369,7 +374,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
raise Errors.DbError(msg)
|
||||
|
||||
def __set_default_person_handle(self, handle):
|
||||
"""sets the default Person to the passed instance"""
|
||||
"""Set the default Person to the passed instance."""
|
||||
if not self.readonly:
|
||||
if self.UseTXN:
|
||||
# Start transaction if needed
|
||||
@@ -390,7 +395,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
raise Errors.DbError(msg)
|
||||
|
||||
def __get_default_person(self):
|
||||
"""returns the default Person of the database"""
|
||||
"""Return the default Person of the database."""
|
||||
person = self.get_person_from_handle(self.get_default_handle())
|
||||
if person:
|
||||
return person
|
||||
@@ -408,7 +413,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
return None
|
||||
|
||||
def set_mediapath(self, path):
|
||||
"""sets the default media path for database, path should be utf-8"""
|
||||
"""Set the default media path for database, path should be utf-8."""
|
||||
if self.metadata and not self.readonly:
|
||||
if self.UseTXN:
|
||||
# Start transaction if needed
|
||||
@@ -461,8 +466,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
raise Errors.DbError(msg)
|
||||
|
||||
def __check_readonly(self, name):
|
||||
for base in [ FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, EVENTS_TBL,
|
||||
PERSON_TBL, REPO_TBL, NOTE_TBL, REF_MAP, META ]:
|
||||
for base in [FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL,
|
||||
EVENTS_TBL, PERSON_TBL, REPO_TBL, NOTE_TBL, REF_MAP, META]:
|
||||
path = os.path.join(name, base + ".db")
|
||||
if os.path.isfile(path) and not os.access(path, os.W_OK):
|
||||
return True
|
||||
@@ -537,11 +542,12 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
self.name_group = db.DB(self.env)
|
||||
self.name_group.set_flags(db.DB_DUP)
|
||||
if self.readonly:
|
||||
self.name_group.open(_mkname(self.full_name, NAME_GROUP), NAME_GROUP,
|
||||
db.DB_HASH, flags=db.DB_RDONLY)
|
||||
self.name_group.open(_mkname(self.full_name, NAME_GROUP),
|
||||
NAME_GROUP, db.DB_HASH, flags=db.DB_RDONLY)
|
||||
else:
|
||||
self.name_group.open(_mkname(self.full_name, NAME_GROUP), NAME_GROUP,
|
||||
db.DB_HASH, flags=self.__open_flags())
|
||||
self.name_group.open(_mkname(self.full_name, NAME_GROUP),
|
||||
NAME_GROUP, db.DB_HASH,
|
||||
flags=self.__open_flags())
|
||||
self.__load_metadata()
|
||||
|
||||
gstats = self.metadata.get('gender_stats', default=None)
|
||||
@@ -601,8 +607,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def open_undodb(self):
|
||||
"""
|
||||
Override method from GrampsDbBase because in DIR setup we want
|
||||
the undo database to be inside the dir.
|
||||
Override method from GrampsDbBase because in DIR setup we want the
|
||||
undo database to be inside the dir.
|
||||
"""
|
||||
if not self.readonly:
|
||||
self.undolog = os.path.join(self.full_name, "undo.db")
|
||||
@@ -686,7 +692,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def __connect_secondary(self):
|
||||
"""
|
||||
This method connects or creates secondary index tables.
|
||||
Connect or creates secondary index tables.
|
||||
|
||||
It assumes that the tables either exist and are in the right
|
||||
format or do not exist (in which case they get created).
|
||||
|
||||
@@ -843,6 +850,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
def __find_backlink_handles(self, handle, include_classes=None):
|
||||
"""
|
||||
Find all objects that hold a reference to the object handle.
|
||||
|
||||
Returns an interator over a list of (class_name, handle) tuples.
|
||||
|
||||
@param handle: handle of the object to search for.
|
||||
@@ -1007,8 +1015,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def __remove_reference(self, key, transaction, txn=None):
|
||||
"""
|
||||
Removes the reference specified by the key,
|
||||
preserving the change in the passed transaction.
|
||||
Remove the reference specified by the key, preserving the change in
|
||||
the passed transaction.
|
||||
"""
|
||||
if not self.readonly:
|
||||
if transaction.batch:
|
||||
@@ -1022,8 +1030,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def __add_reference(self, key, data, transaction, txn=None):
|
||||
"""
|
||||
Adds the reference specified by the key and the data,
|
||||
preserving the change in the passed transaction.
|
||||
Add the reference specified by the key and the data, preserving the
|
||||
change in the passed transaction.
|
||||
"""
|
||||
|
||||
if self.readonly or not key:
|
||||
@@ -1047,6 +1055,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
def __reindex_reference_map(self, callback):
|
||||
"""
|
||||
Reindex all primary records in the database.
|
||||
|
||||
This will be a slow process for large databases.
|
||||
"""
|
||||
|
||||
@@ -1074,11 +1083,11 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
self.reference_map_primary_map = db.DB(self.env)
|
||||
self.reference_map_primary_map.set_flags(db.DB_DUP)
|
||||
self.reference_map_primary_map.open(
|
||||
_mkname(self.full_name, REF_PRI), REF_PRI, db.DB_BTREE, flags=open_flags)
|
||||
_mkname(self.full_name, REF_PRI), REF_PRI, db.DB_BTREE,
|
||||
flags=open_flags)
|
||||
|
||||
self.reference_map.associate(self.reference_map_primary_map,
|
||||
find_primary_handle,
|
||||
open_flags)
|
||||
find_primary_handle, open_flags)
|
||||
|
||||
# Make a dictionary of the functions and classes that we need for
|
||||
# each of the primary object tables.
|
||||
@@ -1362,8 +1371,10 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
self.event_map.sync()
|
||||
|
||||
def set_name_group_mapping(self, name, group):
|
||||
"""Make name group under the value of group.
|
||||
If group =None, the old grouping is deleted
|
||||
"""
|
||||
Make name group under the value of group.
|
||||
|
||||
If group =None, the old grouping is deleted.
|
||||
"""
|
||||
try:
|
||||
self.__set_name_group_mapping(name, group)
|
||||
@@ -1401,7 +1412,9 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
def remove_from_surname_list(self, person):
|
||||
"""
|
||||
Check whether there are persons with the same surname left in
|
||||
the database. If not then we need to remove the name from the list.
|
||||
the database.
|
||||
|
||||
If not then we need to remove the name from the list.
|
||||
The function must be overridden in the derived class.
|
||||
"""
|
||||
name = str(person.get_primary_name().get_surname())
|
||||
@@ -1437,7 +1450,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_person_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Person in the database from the passed gramps' ID.
|
||||
Find a Person in the database from the passed gramps' ID.
|
||||
|
||||
If no such Person exists, None is returned.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.id_trans, Person,
|
||||
@@ -1445,7 +1459,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_family_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Family in the database from the passed gramps' ID.
|
||||
Find a Family in the database from the passed gramps' ID.
|
||||
|
||||
If no such Family exists, None is return.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.fid_trans, Family,
|
||||
@@ -1453,7 +1468,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_event_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds an Event in the database from the passed gramps' ID.
|
||||
Find an Event in the database from the passed gramps' ID.
|
||||
|
||||
If no such Family exists, None is returned.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.eid_trans, Event,
|
||||
@@ -1461,7 +1477,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_place_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Place in the database from the passed gramps' ID.
|
||||
Find a Place in the database from the passed gramps' ID.
|
||||
|
||||
If no such Place exists, None is returned.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.pid_trans, Place,
|
||||
@@ -1469,7 +1486,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_source_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Source in the database from the passed gramps' ID.
|
||||
Find a Source in the database from the passed gramps' ID.
|
||||
|
||||
If no such Source exists, None is returned.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.sid_trans, Source,
|
||||
@@ -1477,7 +1495,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_object_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a MediaObject in the database from the passed gramps' ID.
|
||||
Find a MediaObject in the database from the passed gramps' ID.
|
||||
|
||||
If no such MediaObject exists, None is returned.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.oid_trans, MediaObject,
|
||||
@@ -1485,7 +1504,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_repository_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Repository in the database from the passed gramps' ID.
|
||||
Find a Repository in the database from the passed gramps' ID.
|
||||
|
||||
If no such Repository exists, None is returned.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.rid_trans, Repository,
|
||||
@@ -1493,7 +1513,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def get_note_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a Note in the database from the passed gramps' ID.
|
||||
Find a Note in the database from the passed gramps' ID.
|
||||
|
||||
If no such Note exists, None is returned.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.nid_trans, Note,
|
||||
@@ -1502,8 +1523,8 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
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
|
||||
as part of the transaction.
|
||||
Commit the specified object to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
if self.readonly or not obj or not obj.handle:
|
||||
return
|
||||
@@ -1581,8 +1602,9 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
||||
|
||||
def __transaction_begin(self, msg="", batch=False, no_magic=False):
|
||||
"""
|
||||
Creates a new Transaction tied to the current UNDO database. The
|
||||
transaction has no effect until it is committed using the
|
||||
Create a new Transaction tied to the current UNDO database.
|
||||
|
||||
The transaction has no effect until it is committed using the
|
||||
transaction_commit function of the this database object.
|
||||
"""
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
# $Id:exceptions.py 9912 2008-01-22 09:17:46Z acraphae $
|
||||
|
||||
"""Exceptions generated by the GrampsDb package."""
|
||||
|
||||
@@ -49,8 +49,8 @@ class GrampsDbWriteFailure(Exception):
|
||||
|
||||
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.
|
||||
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)
|
||||
|
@@ -1,11 +1,34 @@
|
||||
from ..utils import LongOpStatus
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# $Id:iterator.py 9912 2008-01-22 09:17:46Z acraphae $
|
||||
|
||||
from gen.utils import LongOpStatus
|
||||
|
||||
class CursorIterator(object):
|
||||
|
||||
def __init__(self, db, cursor, msg=""):
|
||||
self._db = db
|
||||
self._cursor = cursor
|
||||
self._status = LongOpStatus(total_steps=cursor.get_length(), interval=10)
|
||||
self._status = LongOpStatus(total_steps=cursor.get_length(),
|
||||
interval=10)
|
||||
#self._status = LongOpStatus(msg=msg)
|
||||
|
||||
def __iter__(self):
|
||||
|
@@ -80,7 +80,7 @@ class SourceBase:
|
||||
|
||||
def get_source_references(self) :
|
||||
"""
|
||||
Returns the list of source references associated with the object.
|
||||
Return the list of source references associated with the object.
|
||||
|
||||
@return: Returns the list of L{SourceRef} objects assocated with
|
||||
the object.
|
||||
|
@@ -18,7 +18,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
# $Id:ReorderIds.py 9912 2008-01-22 09:17:46Z acraphae $
|
||||
|
||||
"""
|
||||
Change id IDs of all the elements in the database to conform to the
|
||||
@@ -74,7 +74,7 @@ class ReorderIds(Tool.BatchTool):
|
||||
db.find_next_person_gramps_id,
|
||||
db.person_map,
|
||||
db.commit_person,
|
||||
db.iprefix)
|
||||
db.person_prefix)
|
||||
|
||||
if uistate:
|
||||
self.progress.set_pass(_('Reordering Family IDs'),
|
||||
@@ -85,7 +85,7 @@ class ReorderIds(Tool.BatchTool):
|
||||
db.find_next_family_gramps_id,
|
||||
db.family_map,
|
||||
db.commit_family,
|
||||
db.fprefix)
|
||||
db.family_prefix)
|
||||
if uistate:
|
||||
self.progress.set_pass(_('Reordering Event IDs'),
|
||||
db.get_number_of_events())
|
||||
@@ -95,7 +95,7 @@ class ReorderIds(Tool.BatchTool):
|
||||
db.find_next_event_gramps_id,
|
||||
db.event_map,
|
||||
db.commit_event,
|
||||
db.eprefix)
|
||||
db.event_prefix)
|
||||
if uistate:
|
||||
self.progress.set_pass(_('Reordering Media Object IDs'),
|
||||
db.get_number_of_media_objects())
|
||||
@@ -105,7 +105,7 @@ class ReorderIds(Tool.BatchTool):
|
||||
db.find_next_object_gramps_id,
|
||||
db.media_map,
|
||||
db.commit_media_object,
|
||||
db.oprefix)
|
||||
db.mediaobject_prefix)
|
||||
if uistate:
|
||||
self.progress.set_pass(_('Reordering Source IDs'),
|
||||
db.get_number_of_sources())
|
||||
@@ -115,7 +115,7 @@ class ReorderIds(Tool.BatchTool):
|
||||
db.find_next_source_gramps_id,
|
||||
db.source_map,
|
||||
db.commit_source,
|
||||
db.sprefix)
|
||||
db.source_prefix)
|
||||
if uistate:
|
||||
self.progress.set_pass(_('Reordering Place IDs'),
|
||||
db.get_number_of_places())
|
||||
@@ -125,7 +125,7 @@ class ReorderIds(Tool.BatchTool):
|
||||
db.find_next_place_gramps_id,
|
||||
db.place_map,
|
||||
db.commit_place,
|
||||
db.pprefix)
|
||||
db.place_prefix)
|
||||
if uistate:
|
||||
self.progress.set_pass(_('Reordering Repository IDs'),
|
||||
db.get_number_of_repositories())
|
||||
@@ -135,7 +135,7 @@ class ReorderIds(Tool.BatchTool):
|
||||
db.find_next_repository_gramps_id,
|
||||
db.repository_map,
|
||||
db.commit_repository,
|
||||
db.rprefix)
|
||||
db.repository_prefix)
|
||||
#add reorder notes ID
|
||||
if uistate:
|
||||
self.progress.set_pass(_('Reordering Note IDs'),
|
||||
@@ -146,7 +146,7 @@ class ReorderIds(Tool.BatchTool):
|
||||
db.find_next_note_gramps_id,
|
||||
db.note_map,
|
||||
db.commit_note,
|
||||
db.nprefix)
|
||||
db.note_prefix)
|
||||
if uistate:
|
||||
self.progress.close()
|
||||
else:
|
||||
|
Reference in New Issue
Block a user