* src/ViewManger.py: progressbar callbacks

* src/GrampsDb/_GrampsBSDDB.py: progressbar callbacks
* src/GrampsDb/_GrampsGEDDB.py: progressbar callbacks
* src/GrampsDb/_ReadXML.py: progressbar callbacks
* src/GrampsDb/_ReadGedcom.py: progressbar callbacks


svn: r5783
This commit is contained in:
Don Allingham 2006-01-18 04:08:28 +00:00
parent d169d9c949
commit 572a8a5724
6 changed files with 483 additions and 506 deletions

View File

@ -1,3 +1,10 @@
2006-01-17 Don Allingham <don@gramps-project.org>
* src/ViewManger.py: progressbar callbacks
* src/GrampsDb/_GrampsBSDDB.py: progressbar callbacks
* src/GrampsDb/_GrampsGEDDB.py: progressbar callbacks
* src/GrampsDb/_ReadXML.py: progressbar callbacks
* src/GrampsDb/_ReadGedcom.py: progressbar callbacks
2006-01-17 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsDb/_GrampsBSDDB.py: make ref update optional

View File

@ -252,7 +252,7 @@ class GrampsBSDDB(GrampsDbBase):
self.readonly = mode == "r"
callback(0.25)
callback(12)
self.env = db.DBEnv()
self.env.set_cachesize(0,0x2000000) # 2MB
@ -269,6 +269,8 @@ class GrampsBSDDB(GrampsDbBase):
self.env.open(env_name,env_flags)
self.env.txn_checkpoint()
callback(25)
self.full_name = os.path.abspath(name)
self.brief_name = os.path.basename(name)
@ -282,6 +284,8 @@ class GrampsBSDDB(GrampsDbBase):
self.repository_map = self.open_table(self.full_name, "repository")
self.reference_map = self.open_table(self.full_name, "reference_map")
callback(37)
# index tables used just for speeding up searches
if self.readonly:
table_flags = db.DB_RDONLY
@ -333,6 +337,7 @@ class GrampsBSDDB(GrampsDbBase):
self.rid_trans.open(self.full_name, "ridtrans",
db.DB_HASH, flags=table_flags)
callback(50)
self.eventnames = db.DB(self.env)
self.eventnames.set_flags(db.DB_DUP)
@ -356,6 +361,7 @@ class GrampsBSDDB(GrampsDbBase):
"reference_map_referenced_map",
db.DB_BTREE, flags=table_flags)
callback(62)
if not self.readonly:
self.person_map.associate(self.surnames, find_surname, table_flags)
self.person_map.associate(self.id_trans, find_idmap, table_flags)
@ -377,14 +383,14 @@ class GrampsBSDDB(GrampsDbBase):
self.undodb = db.DB()
self.undodb.open(self.undolog, db.DB_RECNO, db.DB_CREATE)
callback(0.5)
callback(75)
self.metadata = self.open_table(self.full_name, "meta", no_txn=True)
self.bookmarks = self.metadata.get('bookmarks')
self.family_event_names = sets.Set(self.metadata.get('fevent_names',[]))
self.individual_event_names = sets.Set(self.metadata.get('pevent_names',[]))
self.family_attributes = sets.Set(self.metadata.get('fattr_names',[]))
self.individual_attributes = sets.Set(self.metadata.get('pattr_names',[]))
self.family_event_names = set(self.metadata.get('fevent_names',[]))
self.individual_event_names = set(self.metadata.get('pevent_names',[]))
self.family_attributes = set(self.metadata.get('fattr_names',[]))
self.individual_attributes = set(self.metadata.get('pattr_names',[]))
gstats = self.metadata.get('gender_stats')
@ -399,6 +405,7 @@ class GrampsBSDDB(GrampsDbBase):
self.genderStats = GenderStats(gstats)
self.db_is_open = True
callback(87)
return 1
def rebuild_secondary(self,callback=None):

View File

@ -48,7 +48,7 @@ class GrampsGEDDB(GrampsInMemDB):
if self.db_is_open:
self.close()
GrampsInMemDB.load(self,name,callback,mode)
ReadGedcom.importData(self,name,use_trans=False)
ReadGedcom.importData(self,name,callback,use_trans=False)
self.bookmarks = self.metadata.get('bookmarks')
if self.bookmarks == None:

File diff suppressed because it is too large Load Diff

View File

@ -255,6 +255,7 @@ class GrampsParser:
self.stext_list = []
self.scomments_list = []
self.note_list = []
self.oldval = 0
self.tlist = []
self.conf = 2
self.gid2id = {}
@ -320,7 +321,6 @@ class GrampsParser:
self.media_file_map = {}
self.callback = callback
self.count = 0
self.increment = 100
self.event = None
self.name = None
@ -676,10 +676,8 @@ class GrampsParser:
self.placeobj.set_title(title)
self.locations = 0
if self.callback != None and self.count % self.increment == 0:
if self.linecount:
self.callback(float(self.p.CurrentLineNumber)/float(self.linecount))
self.count += 1
self.update()
def start_location(self,attrs):
"""Bypass the function calls for this one, since it appears to
@ -788,10 +786,7 @@ class GrampsParser:
self.db.bookmarks.append(person.get_handle())
def start_person(self,attrs):
if self.callback != None and self.count % self.increment == 0:
if self.linecount:
self.callback(float(self.p.CurrentLineNumber)/float(self.linecount))
self.count += 1
self.update()
new_id = self.map_gid(attrs['id'])
try:
self.person = self.db.find_person_from_handle(
@ -859,10 +854,7 @@ class GrampsParser:
return
def start_family(self,attrs):
if self.callback != None and self.count % self.increment == 0:
if self.linecount:
self.callback(float(self.p.CurrentLineNumber)/float(self.linecount))
self.count = self.count + 1
self.update()
handle = self.map_fid(attrs["id"])
try:
self.family = self.db.find_family_from_handle(
@ -987,10 +979,7 @@ class GrampsParser:
self.person.add_source_reference(self.source_ref)
def start_source(self,attrs):
if self.callback != None and self.count % self.increment == 0:
if self.linecount:
self.callback(float(self.p.CurrentLineNumber)/float(self.linecount))
self.count += 1
self.update()
handle = self.map_sid(attrs["id"])
try:
self.source = self.db.find_source_from_handle(
@ -1044,8 +1033,7 @@ class GrampsParser:
pass
def stop_database(self,*tag):
if self.callback:
self.callback(1.0)
self.update()
def stop_object(self,*tag):
self.db.commit_media_object(self.object,self.trans,self.change)
@ -1589,7 +1577,6 @@ class GrampsParser:
self.func = None
def endElement(self,tag):
if self.func:
self.func(''.join(self.tlist))
self.func_index = self.func_index - 1
@ -1599,6 +1586,13 @@ class GrampsParser:
if self.func:
self.tlist.append(data)
def update(self):
line = self.p.CurrentLineNumber
newval = int(100*line/self.linecount)
if newval != self.oldval:
self.callback(newval)
self.oldval = newval
def append_value(orig,val):
if orig:
return "%s, %s" % (orig,val)

View File

@ -855,7 +855,7 @@ class ViewManager:
ScratchPad.ScratchPadWindow(self.state, self)
def pulse_progressbar(self,value):
self.progress.set_fraction(value)
self.progress.set_fraction(value/100.0)
while gtk.events_pending():
gtk.main_iteration()
@ -933,16 +933,12 @@ class ViewManager:
self.parent.import_tool_callback()
self.progress.hide()
return True
elif filetype == const.app_gramps_xml:
elif filetype == const.app_gramps_xml or filetype == const.app_gedcom:
choose.destroy()
self.progress.show()
GrampsDb.gramps_db_reader_factory(filetype)(self.state.db,filename,self.pulse_progressbar)
self.progress.hide()
return True
elif filetype == const.app_gedcom:
choose.destroy()
GrampsDb.gramps_db_reader_factory(filetype)(self.state.db,filename)
return True
(the_path,the_file) = os.path.split(filename)
GrampsKeys.save_last_import_dir(the_path)