[Spambayes-checkins] spambayes/scripts sb_dbexpimp.py,1.15,1.16

Tony Meyer anadelonbrin at users.sourceforge.net
Mon Nov 15 07:22:07 CET 2004


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

Modified Files:
	sb_dbexpimp.py 
Log Message:
Unittest is paying for itself already!  (I really didn't expect to actually find a
 bug!).

Because wordinfo might be just a cache with dbm classifiers, a merged import would
 lose data for any 'singletons'.  Need to use _wordinfoget() instead.

Also fail if the csv file doesn't exist that we are trying to import from rather than
 keeping going, which made no sense.

And while I'm here, also stop bothering to remove the .dat and .dir files that dumbdbm
 create (long time since they were supported), and remove the verbose flag, which
 doesn't actually do anything.

Index: sb_dbexpimp.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_dbexpimp.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** sb_dbexpimp.py	3 Nov 2004 02:49:30 -0000	1.15
--- sb_dbexpimp.py	15 Nov 2004 06:22:05 -0000	1.16
***************
*** 47,51 ****
              -e     : export
              -i     : import
-             -v     : verbose mode (some additional diagnostic messages)
              -f: FN : flat file to export to or import from
              -p: FN : name of pickled database file to use
--- 47,50 ----
***************
*** 177,198 ****
              pass
  
-         try:
-             os.unlink(dbFN+".dat")
-         except OSError:
-             pass
- 
-         try:
-             os.unlink(dbFN+".dir")
-         except OSError:
-             pass
- 
      bayes = spambayes.storage.open_storage(dbFN, useDBM)
  
!     try:
!         fp = open(inFN, 'rb')
!     except IOError, e:
!         if e.errno != errno.ENOENT:
!             raise
! 
      rdr = csv.reader(fp)
      (nham, nspam) = rdr.next()
--- 176,182 ----
              pass
  
      bayes = spambayes.storage.open_storage(dbFN, useDBM)
  
!     fp = open(inFN, 'rb')
      rdr = csv.reader(fp)
      (nham, nspam) = rdr.next()
***************
*** 215,221 ****
          word = uunquote(word)
  
!         try:
!             wi = bayes.wordinfo[word]
!         except KeyError:
              wi = bayes.WordInfoClass()
  
--- 199,206 ----
          word = uunquote(word)
  
!         # Can't use wordinfo[word] here, because wordinfo
!         # is only a cache with dbm!  Need to use _wordinfoget instead.
!         wi = bayes._wordinfoget(word)
!         if wi is None:
              wi = bayes.WordInfoClass()
  
***************
*** 269,274 ****
          elif opt == '-m':
              newDBM = False
-         elif opt == '-v':
-             options["globals", "verbose"] = True
          elif opt in ('-o', '--option'):
              options.set_from_cmdline(arg, sys.stderr)
--- 254,257 ----



More information about the Spambayes-checkins mailing list