Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29992/spambayes

Modified Files:
        Options.py storage.py 
Log Message:
To make the conversion from dbm to ZODB easier for users:

  (a) change the names to hammie.fs and messageinfo.fs

  (b) add a conversion utility to automatically convert the database.

Index: Options.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Options.py,v
retrieving revision 1.128
retrieving revision 1.129
diff -C2 -d -r1.128 -r1.129
*** Options.py  26 Nov 2005 05:35:10 -0000      1.128
--- Options.py  26 Nov 2005 06:44:15 -0000      1.129
***************
*** 523,527 ****
       ("zeo", "zodb", "cdb", "mysql", "pgsql", "dbm", "pickle"), RESTORE),
  
!     ("persistent_storage_file", _("Storage file name"), "hammie.db",
       _("""Spambayes builds a database of information that it gathers
       from incoming emails and from you, the user, to get better and
--- 523,527 ----
       ("zeo", "zodb", "cdb", "mysql", "pgsql", "dbm", "pickle"), RESTORE),
  
!     ("persistent_storage_file", _("Storage file name"), "hammie.fs",
       _("""Spambayes builds a database of information that it gathers
       from incoming emails and from you, the user, to get better and
***************
*** 532,536 ****
       FILE_WITH_PATH, DO_NOT_RESTORE),
  
!     ("messageinfo_storage_file", _("Message information file name"), 
"spambayes.messageinfo.db",
       _("""Spambayes builds a database of information about messages
       that it has already seen and trained or classified.  This
--- 532,536 ----
       FILE_WITH_PATH, DO_NOT_RESTORE),
  
!     ("messageinfo_storage_file", _("Message information file name"), 
"messageinfo.fs",
       _("""Spambayes builds a database of information about messages
       that it has already seen and trained or classified.  This

Index: storage.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/storage.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** storage.py  26 Nov 2005 05:33:03 -0000      1.54
--- storage.py  26 Nov 2005 06:44:15 -0000      1.55
***************
*** 1002,1005 ****
--- 1002,1038 ----
      return nm, typ
  
+ def convert(old_name=None, old_type=None, new_name=None, new_type=None):
+     # The expected need is to convert the existing hammie.db dbm
+     # database to a hammie.fs ZODB database.
+     if old_name is None:
+         old_name = "hammie.db"
+     if old_type is None:
+         old_type = "dbm"
+     if new_name is None or new_type is None:
+         auto_name, auto_type = database_type({})
+         if new_name is None:
+             new_name = auto_name
+         if new_type is None:
+             new_type = auto_type
+ 
+     old_bayes = open_storage(old_name, old_type)
+     new_bayes = open_storage(new_name, new_type)
+     words = old_bayes._wordinfokeys()
+ 
+     new_bayes.nham = old_bayes.nham
+     new_bayes.nspam = old_bayes.nspam
+ 
+     print >> sys.stderr, "Converting %s (%s database) to " \
+           "%s (%s database)." % (old_name, old_type, new_name, new_type)
+     print >> sys.stderr, "Database has %s ham, %s spam, and %s words." % \
+           (new_bayes.nham, new_bayes.nspam, len(words))
+ 
+     for word in words:
+         new_bayes._wordinfoset(word, old_bayes._wordinfoget(word))
+ 
+     print "Storing database, please be patient..."
+     new_bayes.store()
+     print "Conversion complete."
+ 
  def ensureDir(dirname):
      """Ensure that the given directory exists - in other words, if it

_______________________________________________
Spambayes-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/spambayes-checkins

Reply via email to