[Spambayes-checkins] spambayes/Outlook2000/dialogs RuleDialog.py,1.4,1.5

Tim Peters tim_one@users.sourceforge.net
Fri, 25 Oct 2002 10:47:39 -0700


Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs
In directory usw-pr-cvs1:/tmp/cvs-serv21808/Outlook2000/dialogs

Modified Files:
	RuleDialog.py 
Log Message:
Attempting to switch the scores from floats in 0.-1. to ints in 0-100.

YOU MAY NEED TO CHANGE YOUR FILTER RULES ACCORDINGLY.

The Rule dialog appears to have gotten partly broken before this --
referenced a _GetFolder method that doesn't exist.  Repaired that.

PROBLEM:  While the Rule dialog seems to work fine now, trying to write
a score to the SpamProb (Hammie, whatever) custom field doesn't appear
to do anything anymore.  But I didn't touch that part of the code, so
I'm baffled.  Perhaps it has to do with that the *type* changed from
double to int, and that _MapiTypeMap can't tell the difference between
an int and a bool before Python 2.3 (I'm using 2.2)?  But commenting
out the PT_BOOLEAN entry there didn't make any difference for me, so I
doubt that's it.


Index: RuleDialog.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/RuleDialog.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RuleDialog.py	25 Oct 2002 06:58:20 -0000	1.4
--- RuleDialog.py	25 Oct 2002 17:47:37 -0000	1.5
***************
*** 65,70 ****
          rule = self.rule
          self.SetDlgItemText(IDC_RULE_NAME, rule.name)
!         self.SetDlgItemText(IDC_EDIT_LOW, "%.2f" % rule.min)
!         self.SetDlgItemText(IDC_EDIT_HIGH, "%.2f" % rule.max)
          self.GetDlgItem(IDC_FLAG).SetCheck(rule.flag_message)
          self.GetDlgItem(IDC_WRITE_FIELD).SetCheck(rule.write_field)
--- 65,70 ----
          rule = self.rule
          self.SetDlgItemText(IDC_RULE_NAME, rule.name)
!         self.SetDlgItemText(IDC_EDIT_LOW, "%d" % rule.min)
!         self.SetDlgItemText(IDC_EDIT_HIGH, "%d" % rule.max)
          self.GetDlgItem(IDC_FLAG).SetCheck(rule.flag_message)
          self.GetDlgItem(IDC_WRITE_FIELD).SetCheck(rule.write_field)
***************
*** 137,141 ****
              assert slider.GetSafeHwnd() == lParam
              idc_edit = IDC_EDIT_LOW
!         self.SetDlgItemText(idc_edit, "%.2f" % (slider.GetPos() / 100.0))
  
      def _InitSlider(self, idc_slider, idc_edit):
--- 137,141 ----
              assert slider.GetSafeHwnd() == lParam
              idc_edit = IDC_EDIT_LOW
!         self.SetDlgItemText(idc_edit, "%d" % slider.GetPos())
  
      def _InitSlider(self, idc_slider, idc_edit):
***************
*** 153,165 ****
          except ValueError:
              return
!         slider.SetPos(int(fval*100))
  
      def _CheckEdit(self, idc, rule, attr):
          try:
              val = float(self.GetDlgItemText(idc))
!             if val < 0 or val > 1.0:
                  raise ValueError
          except ValueError:
!             self.MessageBox("Please enter a number between 0 and 1")
              self.GetDlgItem(idc).SetFocus()
              return False
--- 153,165 ----
          except ValueError:
              return
!         slider.SetPos(int(fval))
  
      def _CheckEdit(self, idc, rule, attr):
          try:
              val = float(self.GetDlgItemText(idc))
!             if val < 0 or val > 100:
                  raise ValueError
          except ValueError:
!             self.MessageBox("Please enter a number between 0 and 100")
              self.GetDlgItem(idc).SetFocus()
              return False
***************
*** 193,198 ****
          def __init__(self):
              self.name = "My Rule"
!             self.min = 0.1
!             self.max = 0.9
              self.action = "Move"
              self.flag_message = True
--- 193,198 ----
          def __init__(self):
              self.name = "My Rule"
!             self.min = 10
!             self.max = 90
              self.action = "Move"
              self.flag_message = True