* src/GrampsInMemDB.py: handle null handle

* src/GrampsXMLDB.py: disable undo during normal read of database
* src/ReadGedcom.py: handle lines shorter than 50 lines, disable undo during
normal reads of the database
* src/ReadXML.py: disable undo during normal read of databas
* src/RelLib.py: revert Name.__cmp__ to Name.is_equal
* src/docgen/HTMLDoc.py: drop deprecated gnome.ui dialogs


svn: r3617
This commit is contained in:
Don Allingham 2004-10-10 21:16:44 +00:00
parent e1d90f4178
commit e6783320cb
11 changed files with 67 additions and 48 deletions

View File

@ -1,3 +1,12 @@
2004-10-10 Don Allingham <dallingham@users.sourceforge.net>
* src/GrampsInMemDB.py: handle null handle
* src/GrampsXMLDB.py: disable undo during normal read of database
* src/ReadGedcom.py: handle lines shorter than 50 lines, disable undo during
normal reads of the database
* src/ReadXML.py: disable undo during normal read of databas
* src/RelLib.py: revert Name.__cmp__ to Name.is_equal
* src/docgen/HTMLDoc.py: drop deprecated gnome.ui dialogs
2004-10-10 Eero Tamminen <eerot@sf>
* TestPlan.txt: Add test for reports like in stable version

View File

@ -41,14 +41,15 @@ class GrampsGEDDB(GrampsInMemDB):
def load(self,name,callback):
self.filename = name
ReadGedcom.importData(self,name)
ReadGedcom.importData(self,name,use_trans=False)
self.bookmarks = self.metadata.get('bookmarks')
if self.bookmarks == None:
self.bookmarks = []
return 1
def close(self):
writer = WriteGedcom.GedcomWriter(self,self.get_default_person())
writer.export_data(self.filename)
if len(self.undodb) > 0:
writer = WriteGedcom.GedcomWriter(self,self.get_default_person())
writer.export_data(self.filename)

View File

@ -138,7 +138,10 @@ class GrampsInMemDB(GrampsDbBase):
def get_person_from_gramps_id(self,val):
handle = self.id_trans.get(str(val))
return self.person_map[handle]
if handle:
return self.person_map[handle]
else:
return None
def get_family_from_gramps_id(self,val):
handle = self.fid_trans.get(str(val))

View File

@ -40,9 +40,10 @@ class GrampsXMLDB(GrampsInMemDB):
GrampsInMemDB.__init__(self)
def load(self,name,callback):
self.filename = name
self.id_trans = {}
ReadXML.importData(self,name)
ReadXML.importData(self,name,use_trans=False)
self.bookmarks = self.metadata.get('bookmarks')
if self.bookmarks == None:
@ -50,5 +51,6 @@ class GrampsXMLDB(GrampsInMemDB):
return 1
def close(self):
WriteXML.quick_write(self,self.filename)
if len(self.undodb) > 0:
WriteXML.quick_write(self,self.filename)

View File

@ -121,7 +121,7 @@ spanRegexp = re.compile(r"\s*FROM\s+@#D([^@]+)@\s*(.*)\s+TO\s+@#D([^@]+)@\s*(.*)
#
#
#-------------------------------------------------------------------------
def importData(database, filename, cb=None):
def importData(database, filename, cb=None, use_trans=True):
global callback
@ -131,6 +131,8 @@ def importData(database, filename, cb=None):
gramps = False
for index in range(0,50):
line = f.readline().split()
if len(line) == 0:
break
if line[1] == 'CHAR' and line[2] == "ANSEL":
ansel = True
if line[1] == 'SOUR' and line[2] == "GRAMPS":
@ -148,10 +150,10 @@ def importData(database, filename, cb=None):
dialog.destroy()
else:
codeset = None
import2(database, filename, cb, codeset)
import2(database, filename, cb, codeset, use_trans)
def import2(database, filename, cb, codeset):
def import2(database, filename, cb, codeset, use_trans):
# add some checking here
glade_file = "%s/gedcomimport.glade" % os.path.dirname(__file__)
@ -181,7 +183,7 @@ def import2(database, filename, cb, codeset):
return
try:
close = g.parse_gedcom_file()
close = g.parse_gedcom_file(use_trans)
g.resolve_refns()
except IOError,msg:
Utils.destroy_passed_object(statusWindow)
@ -422,9 +424,12 @@ class GedcomParser:
def backup(self):
self.backoff = 1
def parse_gedcom_file(self):
self.trans = self.db.transaction_begin()
def parse_gedcom_file(self,use_trans=True):
if use_trans:
self.trans = self.db.transaction_begin()
else:
self.trans = None
t = time.time()
self.index = 0
self.fam_count = 0
@ -445,7 +450,8 @@ class GedcomParser:
t = time.time() - t
msg = _('Import Complete: %d seconds') % t
self.db.transaction_commit(self.trans,_("GEDCOM import"))
if use_trans:
self.db.transaction_commit(self.trans,_("GEDCOM import"))
if self.window:
self.infomsg("\n%s" % msg)

View File

@ -67,7 +67,7 @@ _FAMILY_TRANS = {
# Must takes care of renaming media files according to their new IDs.
#
#-------------------------------------------------------------------------
def importData(database, filename, callback=None,cl=0):
def importData(database, filename, callback=None,cl=0,use_trans=True):
filename = os.path.normpath(filename)
basefile = os.path.dirname(filename)
@ -112,7 +112,7 @@ def importData(database, filename, callback=None,cl=0):
ErrorDialog(_("%s could not be opened") % filename)
return
try:
parser.parse(xml_file)
parser.parse(xml_file,use_trans)
except IOError,msg:
if cl:
print "Error reading %s" % filename
@ -435,7 +435,7 @@ class GrampsParser:
person = RelLib.Person()
person.set_handle(intid)
person.set_gramps_id(gramps_id)
self.db.add_person(person,self.trans)
self.db.add_person(person,None)
self.gid2id[gramps_id] = intid
return person
@ -448,7 +448,7 @@ class GrampsParser:
family = RelLib.Family()
family.set_handle(intid)
family.set_gramps_id(gramps_id)
self.db.add_family(family,self.trans)
self.db.add_family(family,None)
self.gid2fid[gramps_id] = intid
return family
@ -461,7 +461,7 @@ class GrampsParser:
place = RelLib.Place()
place.set_handle(intid)
place.set_gramps_id(gramps_id)
self.db.add_place(place,self.trans)
self.db.add_place(place,None)
self.gid2pid[gramps_id] = intid
return place
@ -474,7 +474,7 @@ class GrampsParser:
source = RelLib.Source()
source.set_handle(intid)
source.set_gramps_id(gramps_id)
self.db.add_source(source,self.trans)
self.db.add_source(source,None)
self.gid2sid[gramps_id] = intid
return source
@ -487,7 +487,7 @@ class GrampsParser:
obj = RelLib.MediaObject()
obj.set_handle(intid)
obj.set_gramps_id(gramps_id)
self.db.add_object(obj,self.trans)
self.db.add_object(obj,None)
self.gid2oid[gramps_id] = intid
return obj
@ -531,8 +531,11 @@ class GrampsParser:
self.oidswap[handle] = handle
return self.oidswap[handle]
def parse(self,file):
self.trans = self.db.transaction_begin()
def parse(self,file,use_trans=True):
if use_trans:
self.trans = self.db.transaction_begin()
else:
self.trans = None
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = self.startElement
p.EndElementHandler = self.endElement
@ -554,7 +557,8 @@ class GrampsParser:
del self.func_map
del self.func_list
del p
self.db.transaction_commit(self.trans,_("GRAMPS XML import"))
if use_trans:
self.db.transaction_commit(self.trans,_("GRAMPS XML import"))
def start_lds_ord(self,attrs):
atype = attrs['type']
@ -702,17 +706,13 @@ class GrampsParser:
self.db.bookmarks.append(person.get_handle())
def start_person(self,attrs):
if self.callback != None and self.count % self.increment == 0:
self.callback(float(self.count)/float(self.entries))
self.count = self.count + 1
new_id = self.map_gid(attrs['id'])
try:
self.person = self.db.find_person_from_handle(attrs['handle'],self.trans)
self.person.set_gramps_id(new_id)
except KeyError:
self.person = self.find_person_by_gramps_id(new_id)
try:
self.person.set_complete_flag(int(attrs['complete']))
except KeyError:

View File

@ -1958,38 +1958,38 @@ class Name(DataObj):
else:
return "%s %s, %s" % (first, self.surname.upper(), self.suffix)
def __cmp__(self,other):
def is_equal(self,other):
"""
compares to names to see if they are equal, return 0 if they
are not
"""
if self.first_name != other.first_name:
return 1
return False
if self.surname != other.surname:
return 1
return False
if self.patronymic != other.patronymic:
return 1
return False
if self.prefix != other.prefix:
return 1
return False
if self.suffix != other.suffix:
return 1
return False
if self.title != other.title:
return 1
return False
if self.type != other.type:
return 1
return False
if self.private != other.private:
return 1
return False
if self.get_note() != other.get_note():
return 1
return False
if len(self.get_source_references()) != len(other.get_source_references()):
return 1
return False
index = 0
olist = other.get_source_references()
for a in self.get_source_references():
if not a.are_equal(olist[index]):
return True
index += 1
return 0
return True
class Url:
"""Contains information related to internet Uniform Resource Locators,

View File

@ -137,7 +137,6 @@ class XmlWriter:
"""
Write the database to the specified file.
"""
base = os.path.dirname(filename)
if os.path.isdir(base):
if not os.access(base,os.W_OK) or not os.access(base,os.R_OK):

View File

@ -25,7 +25,6 @@ import string
import re
import time
import gnome.ui
import Plugins
import ImgManip
import TarFile
@ -157,7 +156,7 @@ class HtmlDoc(BaseDoc.BaseDoc):
if top_add == 1:
mymsg = _("The marker '<!-- START -->' was not in the template")
gnome.ui.GnomeErrorDialog(mymsg)
QuestionDialog.ErrorDialog(_("Template Error"),mymsg)
def load_html(self):
start = re.compile(r"<!--\s*START\s*-->")
@ -182,7 +181,7 @@ class HtmlDoc(BaseDoc.BaseDoc):
if top_add == 1:
mymsg = _("The marker '<!-- START -->' was not in the template")
gnome.ui.GnomeErrorDialog(mymsg)
QuestionDilaog.ErrorDialog(_("Template Error"),mymsg)
def load_template(self):
if self.template:

View File

@ -29,7 +29,6 @@
#-------------------------------------------------------------------------
import os
import cStringIO
import shutil
from gettext import gettext as _
#-------------------------------------------------------------------------
@ -186,6 +185,8 @@ class CheckIntegrity:
self.bad_photo.append(ObjectId)
def fs_ok_clicked(obj):
import shutil
name = fs_top.get_filename()
if os.path.isfile(name):
shutil.copyfile(name,photo_name)

View File

@ -38,7 +38,6 @@ from cStringIO import StringIO
#-------------------------------------------------------------------------
import gtk
import gtk.glade
import gnome
#-------------------------------------------------------------------------
#