[Spambayes-checkins] spambayes/spambayes storage.py,1.30,1.31
Skip Montanaro
montanaro at users.sourceforge.net
Wed Sep 10 08:25:22 EDT 2003
Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv6711
Modified Files:
storage.py
Log Message:
indicate whether or not the classifier's __init__ function has a mode arg
and call appropriately
Index: storage.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/storage.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** storage.py 10 Sep 2003 04:12:20 -0000 1.30
--- storage.py 10 Sep 2003 14:25:19 -0000 1.31
***************
*** 631,638 ****
return repr(self.invalid_name)
! _storage_types = {"dbm" : DBDictClassifier,
! "pickle" : PickledClassifier,
! "pgsql" : PGClassifier,
! "mysql" : mySQLClassifier,
}
--- 631,640 ----
return repr(self.invalid_name)
! # values are classifier class and True if it accepts a mode
! # arg, False otherwise
! _storage_types = {"dbm" : (DBDictClassifier, True),
! "pickle" : (PickledClassifier, False),
! "pgsql" : (PGClassifier, False),
! "mysql" : (mySQLClassifier, False),
}
***************
*** 651,666 ****
db_type, rest = data_source_name.split('::', 1)
if _storage_types.has_key(db_type.lower()):
! klass = _storage_types[db_type.lower()]
data_source_name = rest
else:
raise NoSuchClassifierError(db_type)
else:
! klass = DBDictClassifier
else:
! klass = PickledClassifier
try:
! if mode is not None:
return klass(data_source_name, mode)
! return klass(data_source_name)
except dbmstorage.error, e:
if str(e) == "No dbm modules available!":
--- 653,669 ----
db_type, rest = data_source_name.split('::', 1)
if _storage_types.has_key(db_type.lower()):
! klass, supports_mode = _storage_types[db_type.lower()]
data_source_name = rest
else:
raise NoSuchClassifierError(db_type)
else:
! klass, supports_mode = _storage_types["dbm"]
else:
! klass, supports_mode = _storage_types["pickle"]
try:
! if supports_mode and mode is not None:
return klass(data_source_name, mode)
! else:
! return klass(data_source_name)
except dbmstorage.error, e:
if str(e) == "No dbm modules available!":
More information about the Spambayes-checkins
mailing list