[Spambayes-checkins] spambayes/spambayes dbmstorage.py,1.8,1.9

Skip Montanaro montanaro at users.sourceforge.net
Tue Oct 28 11:19:11 EST 2003


Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv11478

Modified Files:
	dbmstorage.py 
Log Message:
if the db file already exists use whichdb to figure out how to load it
instead of relying on the dbm_type options setting.


Index: dbmstorage.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/dbmstorage.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** dbmstorage.py	5 Sep 2003 01:15:28 -0000	1.8
--- dbmstorage.py	28 Oct 2003 16:19:08 -0000	1.9
***************
*** 3,6 ****
--- 3,8 ----
  from spambayes.Options import options
  import sys
+ import whichdb
+ import os
  
  class error(Exception):
***************
*** 46,53 ****
      }
  
! def open(*args):
!     dbm_type = options["globals", "dbm_type"].lower()
      f = open_funcs.get(dbm_type)
!     if not f:
!         raise error("Unknown dbm type in options file")
!     return f(*args)
--- 48,60 ----
      }
  
! def open(db_name, mode):
!     if os.path.exists(db_name):
!         # let the file tell us what db to use
!         dbm_type = whichdb.whichdb(db_name)
!     else:
!         # fresh file - open with what the user specified
!         dbm_type = options["globals", "dbm_type"].lower()
      f = open_funcs.get(dbm_type)
!     if f is None:
!         raise error("Unknown dbm type: %s" % dbm_type)
!     return f(db_name, mode)





More information about the Spambayes-checkins mailing list