def _importData(database, filename, user): """ Imports the files corresponding to the specified Database, Filename & User. """ data = ProgenOptions(database, filename, user) if data.fail: # 'Cancel' button pressed return data = libprogen.ProgenParser(database, filename, user, data.option) try: info = libprogen.ProgenParser.parse_progen_file(data) except libprogen.ProgenError as msg: user.notify_error(_("Pro-Gen data error"), str(msg)) return except IOError as msg: user.notify_error(_("%s could not be opened") % filename, str(msg)) return if info: # successful import # display qualified/standard statistic window if user.uistate: InfoDialog(_('Import Statistics'), info.info_text(), parent=user.parent) else: return ImportInfo({_("Results"): _("done")})
def display(self): try: from bsddb3.db import DBError except: class DBError(Exception): """ Dummy. """ self.parent = self.top.get_toplevel() progress = ProgressMeter( _('Updating display...'), '', parent=self.parent, can_cancel=True) self.model.clear() self.junk = [] gc.collect(2) self.junk = gc.garbage self.label.set_text(_('Uncollected Objects: %s') % str(len(self.junk))) progress.set_pass(_('Updating display...'), len(self.junk)) for count in range(0, len(self.junk)): if progress.step(): break try: refs = [] referrers = gc.get_referrers(self.junk[count]) for referrer in referrers: try: if referrer is not self.junk: for indx in range(0, len(self.junk)): if referrer is self.junk[indx]: refs.append(str(indx) + ' ') break except: print(sys.exc_info()) if len(refs) > 3: ref = ' '.join(refs[0:2]) + "..." else: ref = ' '.join(refs) try: self.model.append((count, ref, str(self.junk[count]))) except DBError: self.model.append((count, ref, 'db.DB instance at %s' % id(self.junk[count]))) except ReferenceError: self.model.append(( count, ref, 'weakly-referenced object no longer exists %s' % type(self.junk[count]))) except TypeError: self.model.append(( count, ref, 'Object cannot be displayed %s' % type(self.junk[count]))) except: print(sys.exc_info()) except ReferenceError: InfoDialog(_('Reference Error'), "Refresh to correct", parent=self.parent) progress.close()
def refers_to(self): model, iter = self.selection.get_selected() if iter is not None: count = model.get_value(iter, 0) referents = gc.get_referents(self.modeldata[count]) text = "" for referent in referents: try: text += str(referent) + '\n' except ReferenceError: pass InfoDialog(_('%d refers to') % count, text, parent=self.uistate.window)
def referenced_in(self): model, iter = self.selection.get_selected() if iter is not None: count = model.get_value(iter, 0) referrers = gc.get_referrers(self.modeldata[count]) text = "" for referrer in referrers: try: text += str(referrer) + '\n' except ReferenceError: pass InfoDialog( _('Referrers of %d') % count, text, # parent-OK parent=self.uistate.window)
def refers_to(self): model, _iter = self.selection.get_selected() if _iter is not None: count = model.get_value(_iter, 0) referents = gc.get_referents(self.junk[count]) text = "" for referent in referents: match = "" try: match = "****: " for indx in range(len(self.junk)): if referent is self.junk[indx]: match = str(indx) + ': ' break match += str(referent) + '\n' except ReferenceError: match += '%s weakly-referenced object no longer'\ ' exists\n' % type(referent) except: print(sys.exc_info()) text += match InfoDialog(_('%d refers to') % count, text, parent=self.parent)
def referenced_in(self): model, _iter = self.selection.get_selected() if _iter is not None: count = model.get_value(_iter, 0) gc.collect(2) referrers = gc.get_referrers(self.junk[count]) text = "" for referrer in referrers: match = "" try: if referrer is not self.junk: match = "**** " for indx in range(len(self.junk)): if referrer is self.junk[indx]: match = str(indx) + ": " break match += str(referrer) + '\n' except ReferenceError: match += 'weakly-referenced object no longer exists %s'\ % type(referrer) except: print(sys.exc_info()) text += match InfoDialog(_('Referrers of %d') % count, text, parent=self.parent)