def load(self): '''Load state from database''' if options["globals", "verbose"]: print >> sys.stderr, 'Loading state from',self.db_name,'database' self.dbm = dbmstorage.open(self.db_name, self.mode) self.db = shelve.Shelf(self.dbm) if self.db.has_key(self.statekey): t = self.db[self.statekey] if t[0] != classifier.PICKLE_VERSION: raise ValueError("Can't unpickle -- version %s unknown" % t[0]) (self.nspam, self.nham) = t[1:] if options["globals", "verbose"]: print >> sys.stderr, ('%s is an existing database,' ' with %d spam and %d ham') \ % (self.db_name, self.nspam, self.nham) else: # new database if options["globals", "verbose"]: print >> sys.stderr, self.db_name,'is a new database' self.nspam = 0 self.nham = 0 self.wordinfo = {} self.changed_words = {} # value may be one of the WORD_ constants
def load(self): try: self.dbm = dbmstorage.open(self.db_name, self.mode) self.db = shelve.Shelf(self.dbm) except dbmstorage.error: if options["globals", "verbose"]: print "Warning: no dbm modules available for MessageInfoDB" self.dbm = self.db = None
def load(self): try: self.dbm = dbmstorage.open(self.db_name, self.mode) self.db = shelve.Shelf(self.dbm) except dbmstorage.error: # This probably means that we don't have a dbm module # available. Print out a warning, and continue on # (not persisting any of this data). if options["globals", "verbose"]: print "Warning: no dbm modules available for MessageInfoDB" self.dbm = self.db = None
def load(self): """Load state from database""" if options["globals", "verbose"]: print("Loading state from", self.db_name, "database", file=sys.stderr) self.dbm = dbmstorage.open(self.db_name, self.mode) self.db = shelve.Shelf(self.dbm) if self.statekey in self.db: t = self.db[self.statekey] if t[0] != classifier.PICKLE_VERSION: raise ValueError("Can't unpickle -- version %s unknown" % t[0]) (self.nspam, self.nham) = t[1:] if options["globals", "verbose"]: print( ("%s is an existing database," " with %d spam and %d ham") % (self.db_name, self.nspam, self.nham), file=sys.stderr, ) else: if options["globals", "verbose"]: print(self.db_name, "is a new database", file=sys.stderr) self.nspam = 0 self.nham = 0 self.wordinfo = {} self.changed_words = {} # value may be one of the WORD_ constants