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:
Raphael Ackermann
2008-02-23 08:38:55 +00:00
parent c0fd2f8b39
commit 5f375b106f
10 changed files with 994 additions and 836 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -36,7 +36,7 @@ APP_GRAMPS_XML = "application/x-gramps-xml"
APP_GEDCOM = "application/x-gedcom"
APP_GRAMPS_PKG = "application/x-gramps-package"
APP_GENEWEB = "application/x-geneweb"
APP_VCARD = ["text/x-vcard","text/x-vcalendar"]
APP_VCARD = ["text/x-vcard", "text/x-vcalendar"]
PERSON_KEY = 0
FAMILY_KEY = 1

File diff suppressed because it is too large Load Diff

View File

@@ -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,10 +49,10 @@ 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):
def __init__(self, value):
Exception.__init__(self)
self.value = value

View File

@@ -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):

View File

@@ -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.

View File

@@ -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
@@ -50,8 +50,8 @@ _findint = re.compile('^[^\d]*(\d+)[^\d]*')
#
#-------------------------------------------------------------------------
class ReorderIds(Tool.BatchTool):
def __init__(self,dbstate,uistate,options_class,name,callback=None):
Tool.BatchTool.__init__(self,dbstate,options_class,name)
def __init__(self, dbstate, uistate, options_class, name, callback=None):
Tool.BatchTool.__init__(self, dbstate, options_class, name)
if self.fail:
return
@@ -62,7 +62,7 @@ class ReorderIds(Tool.BatchTool):
else:
print "Reordering GRAMPS IDs..."
self.trans = db.transaction_begin("",batch=True)
self.trans = db.transaction_begin("", batch=True)
db.disable_signals()
if uistate:
@@ -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,13 +146,13 @@ 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:
print "Done."
db.transaction_commit(self.trans,_("Reorder GRAMPS IDs"))
db.transaction_commit(self.trans, _("Reorder GRAMPS IDs"))
db.enable_signals()
db.request_rebuild()
@@ -189,7 +189,7 @@ class ReorderIds(Tool.BatchTool):
dups.append(obj.get_handle())
else:
obj.set_gramps_id(newgramps_id)
commit(obj,self.trans)
commit(obj, self.trans)
newids[newgramps_id] = gramps_id
except:
dups.append(handle)
@@ -207,7 +207,7 @@ class ReorderIds(Tool.BatchTool):
self.progress.step()
obj = find_from_handle(handle)
obj.set_gramps_id(find_next_id())
commit(obj,self.trans)
commit(obj, self.trans)
#------------------------------------------------------------------------
#
@@ -219,8 +219,8 @@ class ReorderIdsOptions(Tool.ToolOptions):
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
Tool.ToolOptions.__init__(self,name,person_id)
def __init__(self, name, person_id=None):
Tool.ToolOptions.__init__(self, name, person_id)
#-------------------------------------------------------------------------
#