* various: cleanup
2007-10-08 Don Allingham <don@gramps-project.org> svn: r9109
This commit is contained in:
parent
78fbf6b6bf
commit
99febc759f
@ -1,3 +1,6 @@
|
||||
2007-10-08 Don Allingham <don@gramps-project.org>
|
||||
* various: cleanup
|
||||
|
||||
2007-10-08 Don Allingham <don@gramps-project.org>
|
||||
* src/gen/lib/note.py: make independent of MarkupText.py
|
||||
|
||||
|
@ -65,7 +65,7 @@ import DateHandler
|
||||
import ToolTips
|
||||
import GrampsLocale
|
||||
import Config
|
||||
from gen.db.longop import LongOpStatus
|
||||
from gen.utils.longop import LongOpStatus
|
||||
from Filters import SearchFilter, ExactSearchFilter
|
||||
from Lru import LRU
|
||||
|
||||
|
@ -6,22 +6,12 @@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/GrampsDb
|
||||
|
||||
pkgdata_PYTHON = \
|
||||
_CursorIterator.py \
|
||||
_DbUtils.py \
|
||||
_GrampsBSDDB.py\
|
||||
_GrampsCursor.py\
|
||||
_GrampsDbBase.py\
|
||||
_GrampsDBCallback.py\
|
||||
_GrampsDbConst.py\
|
||||
_GrampsDBDir.py \
|
||||
_GrampsDbExceptions.py\
|
||||
_GrampsDbFactories.py\
|
||||
_GrampsDbWriteXML.py \
|
||||
_GrampsGEDDB.py\
|
||||
_GrampsInMemDB.py\
|
||||
__init__.py\
|
||||
_LongOpStatus.py\
|
||||
_ProgressMonitor.py
|
||||
__init__.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/GrampsDb
|
||||
pkgpythondir = @pkgpythondir@/GrampsDb
|
||||
|
@ -38,21 +38,9 @@ the database objects. Read the comments in _GrampsDBCallback.py for more
|
||||
information.
|
||||
"""
|
||||
|
||||
#from _GrampsDbBase import GrampsDbBase
|
||||
|
||||
from _GrampsDbFactories import gramps_db_factory
|
||||
|
||||
#from _GrampsDbExceptions import *
|
||||
|
||||
#from _GrampsDBCallback import GrampsDBCallback
|
||||
|
||||
#from _DbUtils import *
|
||||
|
||||
#import _GrampsDbConst as GrampsDbConst
|
||||
|
||||
from _GrampsDbWriteXML import GrampsDbXmlWriter, \
|
||||
exportData, quick_write
|
||||
|
||||
#from _LongOpStatus import LongOpStatus
|
||||
from _ProgressMonitor import ProgressMonitor
|
||||
|
||||
|
@ -45,7 +45,7 @@ import const
|
||||
import Utils
|
||||
import DateHandler
|
||||
from BasicUtils import name_displayer
|
||||
from GrampsDb._GrampsDbConst import \
|
||||
from gen.db.dbconst import \
|
||||
PERSON_KEY, FAMILY_KEY, SOURCE_KEY, EVENT_KEY, \
|
||||
MEDIA_KEY, PLACE_KEY, REPOSITORY_KEY, NOTE_KEY
|
||||
from BasicUtils import UpdateCallback
|
||||
|
@ -12,7 +12,7 @@ class _GtkProgressBar(gtk.VBox):
|
||||
|
||||
def __init__(self, long_op_status):
|
||||
"""@param long_op_status: the status of the operation.
|
||||
@type long_op_status: L{GrampsDb.LongOpStatus}
|
||||
@type long_op_status: L{gen.utils.LongOpStatus}
|
||||
"""
|
||||
gtk.VBox.__init__(self)
|
||||
|
||||
@ -91,7 +91,7 @@ class GtkProgressDialog(gtk.Dialog):
|
||||
"""Add a new status object to the progress dialog.
|
||||
|
||||
@param long_op_status: the status object.
|
||||
@type long_op_status: L{GrampsDb.LongOpStatus}
|
||||
@type long_op_status: L{gen.utils.LongOpStatus}
|
||||
@return: a key that can be used as the L{pbar_idx}
|
||||
to the other methods.
|
||||
@rtype: int
|
||||
@ -153,7 +153,7 @@ class GtkProgressDialog(gtk.Dialog):
|
||||
|
||||
if __name__ == '__main__':
|
||||
import time
|
||||
from GrampsDb import LongOpStatus, ProgressMonitor
|
||||
from gen.utils import LongOpStatus, ProgressMonitor
|
||||
|
||||
def test(a, b):
|
||||
d = ProgressMonitor(GtkProgressDialog)
|
||||
|
@ -76,7 +76,7 @@ import GrampsWidgets
|
||||
import UndoHistory
|
||||
from DbLoader import DbLoader
|
||||
import GrampsDisplay
|
||||
from GrampsDb import ProgressMonitor
|
||||
from gen.utils import ProgressMonitor
|
||||
import gen.db
|
||||
|
||||
import ProgressDialog
|
||||
|
@ -8,7 +8,6 @@ pkgdatadir = $(datadir)/@PACKAGE@/db
|
||||
pkgdata_PYTHON = \
|
||||
__init__.py\
|
||||
base.py \
|
||||
callback.py \
|
||||
cursor.py \
|
||||
dbconst.py \
|
||||
dbdir.py \
|
||||
|
@ -438,25 +438,17 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
|
||||
self.update_reference_map(obj, transaction)
|
||||
|
||||
try:
|
||||
if transaction.batch:
|
||||
data_map[handle] = obj.serialize()
|
||||
old_data = None
|
||||
if transaction.batch:
|
||||
data_map[handle] = obj.serialize()
|
||||
old_data = None
|
||||
else:
|
||||
old_data = data_map.get(handle)
|
||||
new_data = obj.serialize()
|
||||
transaction.add(key, handle, old_data, new_data)
|
||||
if old_data:
|
||||
update_list.append((handle, new_data))
|
||||
else:
|
||||
old_data = data_map.get(handle)
|
||||
new_data = obj.serialize()
|
||||
transaction.add(key, handle, old_data, new_data)
|
||||
if old_data:
|
||||
update_list.append((handle, new_data))
|
||||
else:
|
||||
add_list.append((handle, new_data))
|
||||
except db.DBNoSpaceError, msg:
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
ErrorDialog(_("Out of disk space"),
|
||||
_("Your data cannot be saved because you are out "
|
||||
"of disk space. Please free up some disk space "
|
||||
"and try again.\n\n%s") % msg[1])
|
||||
add_list.append((handle, new_data))
|
||||
return old_data
|
||||
|
||||
def commit_person(self, person, transaction, change_time=None):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from longop import LongOpStatus
|
||||
from ..utils import LongOpStatus
|
||||
|
||||
class CursorIterator(object):
|
||||
|
||||
|
@ -759,114 +759,114 @@ class Date:
|
||||
and self.get_year_valid() and self.get_month_valid() \
|
||||
and self.get_day_valid()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Test function. Call it as follows from the command line (so as to find
|
||||
# imported modules):
|
||||
# export PYTHONPATH=/path/to/gramps/src python src/gen.lib/_Date.py
|
||||
#
|
||||
from DateHandler import _DateParser
|
||||
df = _DateParser.DateParser() # date factory
|
||||
def test_date(d1, d2, expected1, expected2 = None):
|
||||
if expected2 == None:
|
||||
expected2 = expected1
|
||||
pos1 = 1
|
||||
if expected1 :
|
||||
pos1 = 0
|
||||
pos2 = 1
|
||||
if expected2 :
|
||||
pos2 = 0
|
||||
date1 = df.parse(d1)
|
||||
date2 = df.parse(d2)
|
||||
wrong = 0
|
||||
print "Testing '%s' and '%s'" % (d1, d2)
|
||||
val = date2.match(date1)
|
||||
try:
|
||||
assert(val == expected1)
|
||||
print [" correct: they match!"
|
||||
," correct: they do not match!"][pos1]
|
||||
except:
|
||||
print " Wrong! got %s" % (not expected1)
|
||||
wrong += 1
|
||||
val = date1.match(date2)
|
||||
try:
|
||||
assert(val == expected2)
|
||||
print [" correct: they match!"
|
||||
," correct: they do not match!"][pos2]
|
||||
except:
|
||||
print " Wrong! got %s" % (not expected2)
|
||||
wrong += 1
|
||||
return {"incorrect": wrong, "correct": 2 - wrong }
|
||||
# if __name__ == "__main__":
|
||||
# # Test function. Call it as follows from the command line (so as to find
|
||||
# # imported modules):
|
||||
# # export PYTHONPATH=/path/to/gramps/src python src/gen.lib/_Date.py
|
||||
# #
|
||||
# from DateHandler import _DateParser
|
||||
# df = _DateParser.DateParser() # date factory
|
||||
# def test_date(d1, d2, expected1, expected2 = None):
|
||||
# if expected2 == None:
|
||||
# expected2 = expected1
|
||||
# pos1 = 1
|
||||
# if expected1 :
|
||||
# pos1 = 0
|
||||
# pos2 = 1
|
||||
# if expected2 :
|
||||
# pos2 = 0
|
||||
# date1 = df.parse(d1)
|
||||
# date2 = df.parse(d2)
|
||||
# wrong = 0
|
||||
# print "Testing '%s' and '%s'" % (d1, d2)
|
||||
# val = date2.match(date1)
|
||||
# try:
|
||||
# assert(val == expected1)
|
||||
# print [" correct: they match!"
|
||||
# ," correct: they do not match!"][pos1]
|
||||
# except:
|
||||
# print " Wrong! got %s" % (not expected1)
|
||||
# wrong += 1
|
||||
# val = date1.match(date2)
|
||||
# try:
|
||||
# assert(val == expected2)
|
||||
# print [" correct: they match!"
|
||||
# ," correct: they do not match!"][pos2]
|
||||
# except:
|
||||
# print " Wrong! got %s" % (not expected2)
|
||||
# wrong += 1
|
||||
# return {"incorrect": wrong, "correct": 2 - wrong }
|
||||
|
||||
stats = {'incorrect':0, 'correct':0}
|
||||
# create a bunch of tests:
|
||||
# most are symmetric: #date1, date2, does d1 match d2? does d2 match d1?
|
||||
tests = [("before 1960", "before 1961", True),
|
||||
("before 1960", "before 1960", True),
|
||||
("before 1961", "before 1961", True),
|
||||
("jan 1, 1960", "jan 1, 1960", True),
|
||||
("dec 31, 1959", "dec 31, 1959", True),
|
||||
("before 1960", "jan 1, 1960", False),
|
||||
("before 1960", "dec 31, 1959", True),
|
||||
("abt 1960", "1960", True),
|
||||
("abt 1960", "before 1960", True),
|
||||
("1960", "1960", True),
|
||||
("1960", "after 1960", False),
|
||||
("1960", "before 1960", False),
|
||||
("abt 1960", "abt 1960", True),
|
||||
("before 1960", "after 1960", False),
|
||||
("after jan 1, 1900", "jan 2, 1900", True),
|
||||
("abt jan 1, 1900", "jan 1, 1900", True),
|
||||
("from 1950 to 1955", "1950", True),
|
||||
("from 1950 to 1955", "1951", True),
|
||||
("from 1950 to 1955", "1952", True),
|
||||
("from 1950 to 1955", "1953", True),
|
||||
("from 1950 to 1955", "1954", True),
|
||||
("from 1950 to 1955", "1955", True),
|
||||
("from 1950 to 1955", "1956", False),
|
||||
("from 1950 to 1955", "dec 31, 1955", True),
|
||||
("from 1950 to 1955", "jan 1, 1955", True),
|
||||
("from 1950 to 1955", "dec 31, 1949", False),
|
||||
("from 1950 to 1955", "jan 1, 1956", False),
|
||||
("after jul 4, 1980", "jul 4, 1980", False),
|
||||
("after jul 4, 1980", "before jul 4, 1980", False),
|
||||
("after jul 4, 1980", "about jul 4, 1980", True),
|
||||
("after jul 4, 1980", "after jul 4, 1980", True),
|
||||
("between 1750 and 1752", "1750", True),
|
||||
("between 1750 and 1752", "about 1750", True),
|
||||
("between 1750 and 1752", "between 1749 and 1750", True),
|
||||
("between 1750 and 1752", "1749", False),
|
||||
("invalid date", "invalid date", True),
|
||||
("invalid date", "invalid", False, True),
|
||||
("invalid date 1", "invalid date 2", False),
|
||||
("abt jan 1, 2000", "dec 31, 1999", True),
|
||||
("jan 1, 2000", "dec 31, 1999", False),
|
||||
("aft jan 1, 2000", "dec 31, 1999", False),
|
||||
("after jan 1, 2000", "after dec 31, 1999", True),
|
||||
("after dec 31, 1999", "after jan 1, 2000", True),
|
||||
("1 31, 2000", "jan 1, 2000", False),
|
||||
("dec 31, 1999", "jan 1, 2000", False),
|
||||
("jan 1, 2000", "before dec 31, 1999", False),
|
||||
("aft jan 1, 2000", "before dec 31, 1999", False),
|
||||
("before jan 1, 2000", "after dec 31, 1999", False),
|
||||
("jan 1, 2000/1", "jan 1, 2000", False),
|
||||
("jan 1, 2000/1", "jan 1, 2001", True),
|
||||
("about 1984", "about 2005", False),
|
||||
("about 1990", "about 2005", True),
|
||||
("about 2007", "about 2006", True),
|
||||
("about 1995", "after 2000", True),
|
||||
("about 1995", "after 2005", False),
|
||||
("about 2007", "about 2003", True),
|
||||
("before 2007", "2000", True),
|
||||
# different calendar, same date
|
||||
("Aug 3, 1982", "14 Thermidor 190 (French Republican)", True),
|
||||
("after Aug 3, 1982",
|
||||
"before 14 Thermidor 190 (French Republican)", False),
|
||||
("ab cd", "54 ab cd 2000", True, False),
|
||||
]
|
||||
# test them:
|
||||
for testdata in tests:
|
||||
results = test_date(*testdata)
|
||||
for result in results:
|
||||
stats[result] += results[result]
|
||||
for result in stats:
|
||||
print result, stats[result]
|
||||
# stats = {'incorrect':0, 'correct':0}
|
||||
# # create a bunch of tests:
|
||||
# # most are symmetric: #date1, date2, does d1 match d2? does d2 match d1?
|
||||
# tests = [("before 1960", "before 1961", True),
|
||||
# ("before 1960", "before 1960", True),
|
||||
# ("before 1961", "before 1961", True),
|
||||
# ("jan 1, 1960", "jan 1, 1960", True),
|
||||
# ("dec 31, 1959", "dec 31, 1959", True),
|
||||
# ("before 1960", "jan 1, 1960", False),
|
||||
# ("before 1960", "dec 31, 1959", True),
|
||||
# ("abt 1960", "1960", True),
|
||||
# ("abt 1960", "before 1960", True),
|
||||
# ("1960", "1960", True),
|
||||
# ("1960", "after 1960", False),
|
||||
# ("1960", "before 1960", False),
|
||||
# ("abt 1960", "abt 1960", True),
|
||||
# ("before 1960", "after 1960", False),
|
||||
# ("after jan 1, 1900", "jan 2, 1900", True),
|
||||
# ("abt jan 1, 1900", "jan 1, 1900", True),
|
||||
# ("from 1950 to 1955", "1950", True),
|
||||
# ("from 1950 to 1955", "1951", True),
|
||||
# ("from 1950 to 1955", "1952", True),
|
||||
# ("from 1950 to 1955", "1953", True),
|
||||
# ("from 1950 to 1955", "1954", True),
|
||||
# ("from 1950 to 1955", "1955", True),
|
||||
# ("from 1950 to 1955", "1956", False),
|
||||
# ("from 1950 to 1955", "dec 31, 1955", True),
|
||||
# ("from 1950 to 1955", "jan 1, 1955", True),
|
||||
# ("from 1950 to 1955", "dec 31, 1949", False),
|
||||
# ("from 1950 to 1955", "jan 1, 1956", False),
|
||||
# ("after jul 4, 1980", "jul 4, 1980", False),
|
||||
# ("after jul 4, 1980", "before jul 4, 1980", False),
|
||||
# ("after jul 4, 1980", "about jul 4, 1980", True),
|
||||
# ("after jul 4, 1980", "after jul 4, 1980", True),
|
||||
# ("between 1750 and 1752", "1750", True),
|
||||
# ("between 1750 and 1752", "about 1750", True),
|
||||
# ("between 1750 and 1752", "between 1749 and 1750", True),
|
||||
# ("between 1750 and 1752", "1749", False),
|
||||
# ("invalid date", "invalid date", True),
|
||||
# ("invalid date", "invalid", False, True),
|
||||
# ("invalid date 1", "invalid date 2", False),
|
||||
# ("abt jan 1, 2000", "dec 31, 1999", True),
|
||||
# ("jan 1, 2000", "dec 31, 1999", False),
|
||||
# ("aft jan 1, 2000", "dec 31, 1999", False),
|
||||
# ("after jan 1, 2000", "after dec 31, 1999", True),
|
||||
# ("after dec 31, 1999", "after jan 1, 2000", True),
|
||||
# ("1 31, 2000", "jan 1, 2000", False),
|
||||
# ("dec 31, 1999", "jan 1, 2000", False),
|
||||
# ("jan 1, 2000", "before dec 31, 1999", False),
|
||||
# ("aft jan 1, 2000", "before dec 31, 1999", False),
|
||||
# ("before jan 1, 2000", "after dec 31, 1999", False),
|
||||
# ("jan 1, 2000/1", "jan 1, 2000", False),
|
||||
# ("jan 1, 2000/1", "jan 1, 2001", True),
|
||||
# ("about 1984", "about 2005", False),
|
||||
# ("about 1990", "about 2005", True),
|
||||
# ("about 2007", "about 2006", True),
|
||||
# ("about 1995", "after 2000", True),
|
||||
# ("about 1995", "after 2005", False),
|
||||
# ("about 2007", "about 2003", True),
|
||||
# ("before 2007", "2000", True),
|
||||
# # different calendar, same date
|
||||
# ("Aug 3, 1982", "14 Thermidor 190 (French Republican)", True),
|
||||
# ("after Aug 3, 1982",
|
||||
# "before 14 Thermidor 190 (French Republican)", False),
|
||||
# ("ab cd", "54 ab cd 2000", True, False),
|
||||
# ]
|
||||
# # test them:
|
||||
# for testdata in tests:
|
||||
# results = test_date(*testdata)
|
||||
# for result in results:
|
||||
# stats[result] += results[result]
|
||||
# for result in stats:
|
||||
# print result, stats[result]
|
||||
|
@ -7,8 +7,10 @@ pkgdatadir = $(datadir)/@PACKAGE@/utils
|
||||
|
||||
pkgdata_PYTHON = \
|
||||
__init__.py \
|
||||
dbutils.py
|
||||
|
||||
dbutils.py \
|
||||
callback.py \
|
||||
progressmon.py \
|
||||
longop.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/utils
|
||||
pkgpythondir = @pkgpythondir@/utils
|
||||
|
@ -21,4 +21,7 @@
|
||||
__version__ = "$Revision: $"
|
||||
|
||||
from dbutils import *
|
||||
from progressmon import ProgressMonitor
|
||||
from longop import LongOpStatus
|
||||
from callback import GrampsDBCallback
|
||||
|
||||
|
@ -412,10 +412,11 @@ class GrampsDBCallback(object):
|
||||
cb[0](fn[1],*args)
|
||||
elif type(fn) == types.FunctionType or \
|
||||
type(fn) == types.MethodType: # call func
|
||||
try:
|
||||
fn(*args)
|
||||
except Errors.DbError:
|
||||
display_error()
|
||||
fn(*args)
|
||||
# try:
|
||||
# fn(*args)
|
||||
# except Errors.DbError:
|
||||
# display_error()
|
||||
else:
|
||||
self._warn("Badly formed entry in callback map.\n")
|
||||
except:
|
||||
@ -464,15 +465,15 @@ class GrampsDBCallback(object):
|
||||
enable_all_signals = classmethod(__enable_all_signals)
|
||||
|
||||
|
||||
def display_error():
|
||||
from QuestionDialog import ErrorDialog
|
||||
ErrorDialog(
|
||||
_('Database error'),
|
||||
_('A problem as been detected in your database. '
|
||||
'This is probably caused by opening a database that was '
|
||||
'created with one transaction setting when the database was '
|
||||
'created with another, or by moving a non-portable database '
|
||||
'to a different machine.'))
|
||||
# def display_error():
|
||||
# from QuestionDialog import ErrorDialog
|
||||
# ErrorDialog(
|
||||
# _('Database error'),
|
||||
# _('A problem as been detected in your database. '
|
||||
# 'This is probably caused by opening a database that was '
|
||||
# 'created with one transaction setting when the database was '
|
||||
# 'created with another, or by moving a non-portable database '
|
||||
# 'to a different machine.'))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
@ -23,7 +23,7 @@ This module provides a progess dialog for displaying the status of
|
||||
long running operations.
|
||||
"""
|
||||
import logging
|
||||
log = logging.getLogger(".GrampsDb")
|
||||
log = logging.getLogger(".gen")
|
||||
|
||||
from gettext import gettext as _
|
||||
|
||||
@ -34,7 +34,7 @@ class _StatusObjectFacade(object):
|
||||
def __init__(self, status_obj, heartbeat_cb_id=None, end_cb_id=None):
|
||||
"""
|
||||
@param status_obj:
|
||||
@type status_obj: L{GrampsDb.LongOpStatus}
|
||||
@type status_obj: L{gen.utils.LongOpStatus}
|
||||
|
||||
@param heartbeat_cb_id: (default: None)
|
||||
@type heartbeat_cb_id: int
|
||||
@ -51,7 +51,7 @@ class _StatusObjectFacade(object):
|
||||
class ProgressMonitor(object):
|
||||
"""A dialog for displaying the status of long running operations.
|
||||
|
||||
It will work with L{GrampsDb.LongOpStatus} objects to track the
|
||||
It will work with L{gen.utils.LongOpStatus} objects to track the
|
||||
progress of long running operations. If the operations is going to
|
||||
take longer than I{popup_time} it will pop up a dialog with a
|
||||
progress bar so that the user gets some feedback about what is
|
||||
@ -102,7 +102,7 @@ class ProgressMonitor(object):
|
||||
"""Add a new status object to the progress dialog.
|
||||
|
||||
@param op_status: the status object.
|
||||
@type op_status: L{GrampsDb.LongOpStatus}
|
||||
@type op_status: L{gen.utils.LongOpStatus}
|
||||
"""
|
||||
|
||||
log.debug("adding op to Progress Monitor")
|
Loading…
Reference in New Issue
Block a user