[Spambayes-checkins] spambayes hammiefilter.py,1.8,1.9

Neale Pickett npickett at users.sourceforge.net
Mon Jan 20 16:17:59 EST 2003


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

Modified Files:
	hammiefilter.py 
Log Message:
* hammiefilter now supports -D and -d options like hammiebulk


Index: hammiefilter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/hammiefilter.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** hammiefilter.py	15 Jan 2003 22:41:15 -0000	1.8
--- hammiefilter.py	21 Jan 2003 00:17:57 -0000	1.9
***************
*** 35,38 ****
--- 35,42 ----
      -s
          train on stdin as a bad (spam) message
+     -d DBFILE
+         use database in DBFILE
+     -D PICKLEFILE
+         use pickle (instead of database) in PICKLEFILE
      -G
          untrain ham on stdin -- only use if you've already trained this
***************
*** 56,59 ****
--- 60,68 ----
  # Options
  options = Options.options
+ options.mergefiles(['/etc/hammierc',
+                     os.path.expanduser('~/.hammierc')])
+ DBNAME = options.hammiefilter_persistent_storage_file
+ DBNAME = os.path.expanduser(DBNAME)
+ USEDB = options.hammiefilter_persistent_use_database
  
  def usage(code, msg=''):
***************
*** 68,78 ****
      def __init__(self):
          options = Options.options
!         options.mergefiles(['/etc/hammierc',
!                             os.path.expanduser('~/.hammierc')])
!         
!         self.dbname = options.hammiefilter_persistent_storage_file
!         self.dbname = os.path.expanduser(self.dbname)
!         self.usedb = options.hammiefilter_persistent_use_database
!         
  
      def newdb(self):
--- 77,82 ----
      def __init__(self):
          options = Options.options
!         self.dbname = DBNAME
!         self.usedb = USEDB
  
      def newdb(self):
***************
*** 111,120 ****
  
  def main():
      h = HammieFilter()
      action = h.filter
!     opts, args = getopt.getopt(sys.argv[1:], 'hngsGS', ['help'])
      for opt, arg in opts:
          if opt in ('-h', '--help'):
              usage(0)
          elif opt == '-g':
              action = h.train_ham
--- 115,132 ----
  
  def main():
+     global DBNAME, USEDB
+     
      h = HammieFilter()
      action = h.filter
!     opts, args = getopt.getopt(sys.argv[1:], 'hngsGSd:D:', ['help'])
      for opt, arg in opts:
          if opt in ('-h', '--help'):
              usage(0)
+         elif opt == '-d':
+             USEDB = True
+             DBNAME = arg
+         elif opt == '-D':
+             USEDB = False
+             DBNAME = arg
          elif opt == '-g':
              action = h.train_ham





More information about the Spambayes-checkins mailing list