[POS-commit] r177 - in Kiwi2: . Kiwi2 Kiwi2/WidgetProxies Kiwi2/Widgets

Johan Dahlin jdahlin at async.com.br
Tue Mar 22 18:22:06 BRT 2005


Author: jdahlin
Date: 2005-03-22 18:22:05 -0300 (Tue, 22 Mar 2005)
New Revision: 177

Modified:
   Kiwi2/ChangeLog
   Kiwi2/Kiwi2/Controllers.py
   Kiwi2/Kiwi2/Delegates.py
   Kiwi2/Kiwi2/Proxies.py
   Kiwi2/Kiwi2/Views.py
   Kiwi2/Kiwi2/WidgetProxies/Base.py
   Kiwi2/Kiwi2/WidgetProxies/CheckButton.py
   Kiwi2/Kiwi2/WidgetProxies/Entry.py
   Kiwi2/Kiwi2/WidgetProxies/OptionMenu.py
   Kiwi2/Kiwi2/Widgets/List.py
   Kiwi2/Kiwi2/Widgets/WidgetProxy.py
   Kiwi2/Kiwi2/accessors.py
   Kiwi2/Kiwi2/initgtk.py
Log:
	* Kiwi2/Controllers.py:
	* Kiwi2/Delegates.py:
	* Kiwi2/Proxies.py:
	* Kiwi2/Views.py:
	* Kiwi2/WidgetProxies/Base.py:
	* Kiwi2/WidgetProxies/CheckButton.py:
	* Kiwi2/WidgetProxies/Entry.py:
	* Kiwi2/WidgetProxies/OptionMenu.py:
	* Kiwi2/Widgets/List.py:
	* Kiwi2/Widgets/WidgetProxy.py:
	* Kiwi2/accessors.py:
	* Kiwi2/initgtk.py:
	
	Convert exceptions to use raise(x) instead of raise, x



Modified: Kiwi2/ChangeLog
===================================================================
--- Kiwi2/ChangeLog	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/ChangeLog	2005-03-22 21:22:05 UTC (rev 177)
@@ -1,3 +1,20 @@
+2005-03-22  Johan Dahlin  <johan at async.com.br>
+
+	* Kiwi2/Controllers.py:
+	* Kiwi2/Delegates.py:
+	* Kiwi2/Proxies.py:
+	* Kiwi2/Views.py:
+	* Kiwi2/WidgetProxies/Base.py:
+	* Kiwi2/WidgetProxies/CheckButton.py:
+	* Kiwi2/WidgetProxies/Entry.py:
+	* Kiwi2/WidgetProxies/OptionMenu.py:
+	* Kiwi2/Widgets/List.py:
+	* Kiwi2/Widgets/WidgetProxy.py:
+	* Kiwi2/accessors.py:
+	* Kiwi2/initgtk.py:
+	
+	Convert exceptions to use raise(x) instead of raise, x
+
 2005-03-22  Johan Dahlin  <jdahlin at async.com.br>
 
 	* Kiwi2/Widgets/ComboBox.py (ComboProxyMixin.__len__): Add

Modified: Kiwi2/Kiwi2/Controllers.py
===================================================================
--- Kiwi2/Kiwi2/Controllers.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/Controllers.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -50,8 +50,8 @@
         """
 
         if not view and not self.view:
-            raise AssertionError, \
-                "Need a view to create controller, found None" 
+            raise AssertionError(
+                "Need a view to create controller, found None" )
         else:
             self.set_view(view)
 
@@ -98,7 +98,7 @@
         """view: the correspondent view for the controller"""
         if self.view:
             msg = "This controller already has a view: %s"
-            raise AssertionError, msg % self.view
+            raise AssertionError(msg % self.view)
         self.view = view
         view.set_controller(self)
     

Modified: Kiwi2/Kiwi2/Delegates.py
===================================================================
--- Kiwi2/Kiwi2/Delegates.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/Delegates.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -214,8 +214,8 @@
         clist = self.clist
         row = clist.find_row_from_data(instance)
         if row < 0:
-            raise KeyError, "Instance %s not in list %s; it contains %s" \
-                             % (instance, self, self._list)
+            raise KeyError("Instance %s not in list %s; it contains %s"
+                           % (instance, self, self._list))
         clist.remove(row)
         self._list.remove(instance)
 
@@ -226,8 +226,8 @@
 """
         row = self.clist.find_row_from_data(instance)
         if row < 0:
-            raise KeyError, "Instance %s not in list %s; it contains %s" \
-                             % (instance, self, self._list)
+            raise KeyError("Instance %s not in list %s; it contains %s"
+                           % (instance, self, self._list))
         self._select_and_focus_row(row) 
 
     def update_instance(self, instance, select=False):
@@ -238,8 +238,8 @@
         clist = self.clist
         row = clist.find_row_from_data(instance)
         if row < 0:
-            raise KeyError, "Instance %s not in list %s; it contains %s" \
-                             % (instance, self, self._list)
+            raise KeyError("Instance %s not in list %s; it contains %s"
+                           % (instance, self, self._list))
         text = self._get_instance_text(instance)
         clist.set_row(row, text)
         if select:
@@ -307,8 +307,8 @@
         for c in columns:
             value = kgetattr(instance, c.attribute, ValueUnset)
             if value is ValueUnset:
-                msg = "Failed to get attribute '%s' for %s"
-                raise TypeError, msg % (c.attribute, instance)
+                raise TypeError("Failed to get attribute '%s' for %s"
+                                % (c.attribute, instance))
             if value is None:
                 value = ""
             elif type(value) is BooleanType:
@@ -326,8 +326,8 @@
                     else:                    
                         value = c.format % value
                 except TypeError: 
-                    raise TypeError, "Failed to convert %s to format %s" \
-                                  % (repr(value), c.format)
+                    raise TypeError("Failed to convert %s to format %s"
+                                    % (repr(value), c.format))
             else:
                 value = str(value)
             # Swap if special decimal_separator is set
@@ -345,8 +345,8 @@
         for c in columns:
             value = kgetattr(instance, c.attribute, ValueUnset)
             if value is ValueUnset:
-                msg = "Failed to get attribute '%s' for %s"
-                raise TypeError, msg % (c.attribute, instance)
+                raise TypeError("Failed to get attribute '%s' for %s"
+                                % (c.attribute, instance))
             attributes.append(value)
         return tuple(attributes)
 

Modified: Kiwi2/Kiwi2/Proxies.py
===================================================================
--- Kiwi2/Kiwi2/Proxies.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/Proxies.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -143,10 +143,10 @@
               the default in the new optionmenu list.
         """
         if not isinstance(attr_name, basestring):
-            msg = "Expected the attribute name (a string), got %s instead"
-            raise TypeError, msg % attr_name
+            raise TypeError("Expected the attribute name (a string), "
+                            "got %s instead" % attr_name)
         if not hasattr(self, "_attr_map"):
-            raise ValueError, "Don't call this before Proxy.__init__()"
+            raise ValueError("Don't call this before Proxy.__init__()")
         optionmenu = self._attr_map[attr_name]
         optionmenu.setup()
         data = optionmenu.read()
@@ -174,8 +174,8 @@
               button label.
         """
         if hasattr(self, "_attr_map"):
-            raise AssertionError, ("group_radiobuttons() must be called "
-                                   "before the constructor for *Proxy")
+            raise AssertionError("group_radiobuttons() must be called "
+                                 "before the constructor for *Proxy")
         if isinstance(group, (list, tuple)):
             tmp = {}
             for widget_name in group:
@@ -183,8 +183,8 @@
                 tmp[widget_name] = ValueUnset
             group = tmp
         elif not isinstance(group, dict):
-            msg = "group must be a Dictionary or Sequence, found %s"
-            raise TypeError, msg % type(group)
+            raise TypeError("group must be a Dictionary or Sequence, "
+                            "found %s" % type(group))
         # Finally initialize radiogroups. This is done here because it
         # has to be done before __init__(), and I'm not sure if doing it
         # in the class declaration is without its risks
@@ -193,14 +193,14 @@
 
     def set_datetime(self, widget_names):
         if hasattr(self, "_attr_map"):
-            raise AssertionError, ("set_datetime() must be called before "
-                                   "the constructor for the base Proxy class")
+            raise AssertionError("set_datetime() must be called before "
+                                 "the constructor for the base Proxy class")
         if isinstance(widget_names, basestring):
             widget_names = [widget_names]
         elif not isinstance(widget_names, (tuple, list)):
-           raise TypeError, ("widget_names parameter to set_datetime "
-                             "should be a string or a list of strings, "
-                             "found '%s'" % (widget_names))
+           raise TypeError("widget_names parameter to set_datetime "
+                           "should be a string or a list of strings, "
+                           "found '%s'" % (widget_names))
         self._pre_datetime = getattr(self, "_pre_datetime", [])
         self._pre_datetime.extend(widget_names)
 
@@ -224,16 +224,16 @@
         if isinstance(widget_names, basestring):
             widget_names = [widget_names]
         elif not isinstance(widget_names, (tuple, list)):
-            raise TypeError, ("widget_names parameter to set_format should "
-                             "be a string or a list of strings, found %r" 
-                              % (widget_names))
+            raise TypeError("widget_names parameter to set_format should "
+                            "be a string or a list of strings, found %r" 
+                            % (widget_names))
         if not isinstance(format, basestring):
-            raise TypeError, ("format parameter to set_format should "
-                              "be a string, found %r" % (format))
+            raise TypeError("format parameter to set_format should "
+                            "be a string, found %r" % (format))
         # Check if setup_widgets has run
         if hasattr(self, "_attr_map"):
-            raise AssertionError, ("set_format() must be called before "
-                                   "the constructor for *Proxy")
+            raise AssertionError("set_format() must be called before "
+                                 "the constructor for *Proxy")
         self._pre_formats = getattr(self, "_pre_formats", {})
         # process list of names
         # XXX: we could be smarter about format strings and their
@@ -247,7 +247,7 @@
         (.) to another character.
         """
         if not isinstance(char, basestring) or len(char) != 1:
-            raise ValueError, "Must be a single char, got %s" % char
+            raise ValueError("Must be a single char, got %s" % char)
         self._decimal_separator = char
         self._decimal_translator = string.maketrans(".%s" % char, 
                                                     "%s." % char)
@@ -263,14 +263,14 @@
         """
         # XXX: only realy makes sense for Editables
         if hasattr(self, "_attr_map"):
-            raise AssertionError, ("set_format() must be called before "
-                                   "the constructor for the base Proxy class")
+            raise AssertionError("set_format() must be called before "
+                                 "the constructor for the base Proxy class")
         if isinstance(widget_names, basestring):
             widget_names = [widget_names]
         elif not isinstance(widget_names, (tuple, list)):
-           raise TypeError, ("widget_names parameter to set_format "
-                             "should be a string or a list of strings, "
-                             "found '%s'""" % (widget_names))
+           raise TypeError("widget_names parameter to set_format "
+                           "should be a string or a list of strings, "
+                           "found '%s'""" % (widget_names))
         self._pre_numeric = getattr(self, "_pre_numeric", [])
         # process list of names
         self._pre_numeric.extend(widget_names)
@@ -294,16 +294,16 @@
             name = widgets[i]
             if name[0] == ":":
                 if name[0:2] == "::":
-                    raise SyntaxError, ("Specify attributes with a single "
-                                        "colon before the name; multiple "
-                                        "colons are not allowed.")
+                    raise SyntaxError("Specify attributes with a single "
+                                      "colon before the name; multiple "
+                                      "colons are not allowed.")
                 name = name[1:]
                 widget_name = name
                 if string.find(widget_name, '.') != -1:
                     widget_name = string.replace(name, ".","_")
                 if widget_name in widgets:
-                    raise ValueError, ("widgets list for %s already contains "
-                                       "a %r widget" % (self, widget_name))
+                    raise ValueError("widgets list for %s already contains "
+                                     "a %r widget" % (self, widget_name))
                 attrs.append(name)   
                 widgets[i] = widget_name
 
@@ -347,8 +347,8 @@
                 try:
                     wpklass = standard_widgets[widget.__class__]
                 except KeyError:
-                    raise TypeError, "No proxy widget defined for %r %s\n" \
-                        % (attr_name, widget)
+                    raise TypeError("No proxy widget defined for %r %s\n"
+                                    % (attr_name, widget))
                 widgetproxy = wpklass(self, widget, attr_name)
 
             # XXX: move these out when Widget() is implemented
@@ -381,17 +381,17 @@
     def _check_radiobutton(self, widget_name):
         radiogroups = getattr(self, "_radiogroups", None)
         if not radiogroups:
-            raise AttributeError, ("No radiobutton groups have been "
-                                   "defined. You *must* group *all* "
-                                   "radiobuttons using group_radiobuttons() "
-                                   "before calling __init__()")
+            raise AttributeError("No radiobutton groups have been "
+                                 "defined. You *must* group *all* "
+                                 "radiobuttons using group_radiobuttons() "
+                                 "before calling __init__()")
         # build list of all grouped radiobuttons
         radiobuttons = []
         for group in radiogroups.keys():
             radiobuttons.extend(radiogroups[group].keys())
         if widget_name not in radiobuttons:
-            raise AttributeError, \
-                "Radiobutton '%s' is not a part of any group" % widget_name
+            raise AttributeError("Radiobutton '%s' is not " 
+                                 "a part of any group" % widget_name)
 
     # Utility methods used by callbacks and setup methods
 
@@ -406,8 +406,8 @@
         #
         # XXX: this will need to be changed for composition
         if not hasattr(self, name):
-            raise ValueError, "The widget %s doesn't belong to %s" % \
-                              (repr(name), self)
+            raise ValueError("The widget %s doesn't belong to %s" %
+                             (repr(name), self))
         return getattr(self, name)
 
 
@@ -497,18 +497,18 @@
                 return
             value = kgetattr(self.model, attribute, ValueUnset)
             if value is ValueUnset:
-                raise ValueError, "Tried to update %s to unset value" % \
-                      attribute
+                raise ValueError("Tried to update %s to unset value" %
+                                 attribute)
 
         widget = self._attr_map.get(attribute, None)
 
         if widget is None:
-            raise AttributeError, ("Called update for `%s', which isn't "
-                                   "attached to the proxy %s. Valid "
-                                   "attributes are: %s (you may have "
-                                   "forgetten to add `:' to the name in "
-                                   "the widgets list)" 
-                                   % (attribute, self, self._attr_map.keys()))
+            raise AttributeError("Called update for `%s', which isn't "
+                                 "attached to the proxy %s. Valid "
+                                 "attributes are: %s (you may have "
+                                 "forgetten to add `:' to the name in "
+                                 "the widgets list)" 
+                                 % (attribute, self, self._attr_map.keys()))
 
         if block:
             block_widget(widget)
@@ -534,7 +534,7 @@
             if value is ValueUnset:
                 value = kgetattr(self.model, attribute, ValueUnset)
                 if value is ValueUnset:
-                    raise ValueError, "model value for %s was unset" % name
+                    raise ValueError("model value for %s was unset" % name)
             func(attribute, value)
         else:
             self.update(attribute, value, block=True)
@@ -557,8 +557,8 @@
             assert self.model.__class__
             if not relax_type and type(new_model) != type(self.model) and \
                 not isinstance(new_model, self.model.__class__):
-                raise TypeError, "New model has wrong type %s, expected %s" \
-                                 % (type(new_model), type(self.model))
+                raise TypeError("New model has wrong type %s, expected %s"
+                                % (type(new_model), type(self.model)))
 
         self.model = new_model
 
@@ -580,8 +580,8 @@
         for widget_name in widgets:
             widget = getattr(self.view, widget_name, None)
             if widget is None:
-                msg = "The widget %s was not found in the view %s"
-                raise AttributeError, msg % (widget_name, self.view)
+                raise AttributeError("The widget %s was not "
+                                     "found in the view %s" % (widget_name, self.view))
             
             if not isinstance(widget, WidgetProxyMixin):
                 continue
@@ -612,8 +612,8 @@
 
         attr_name = widget.get_property('model-attribute')
         if not attr_name:
-            raise AssertionError, \
-                "The model-attribute is empty for widgett %s" % widget.name
+            raise AssertionError("The model-attribute is empty "
+                                 "for widgett %s" % widget.name)
 
 #        if widgetproxy.converted:
 #            value = widgetproxy.read_converted(value)
@@ -680,7 +680,7 @@
                    "should call Model.__init__() (and "
                    "Persistent.__setstate__() of course) to reinitialize "
                    "things properly.)")
-            raise TypeError, msg % ( model, self )
+            raise TypeError(msg % (model, self))
 
     def _unregister_proxy_in_model(self):
         if self.model and hasattr(self.model, "unregister_proxy"):

Modified: Kiwi2/Kiwi2/Views.py
===================================================================
--- Kiwi2/Kiwi2/Views.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/Views.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -46,13 +46,13 @@
     # check to see if gladepath is a list or tuple
     if not isinstance(gladepath, (tuple, list)):
         msg ="gladepath should be a list or tuple, found %s"
-        raise ValueError, msg % type(gladepath)
+        raise ValueError(msg % type(gladepath))
 
     if os.sep in filename or not gladepath:
         if os.path.isfile(filename):
             return filename
         else:
-            raise IOError, "%s not found" % filename
+            raise IOError("%s not found" % filename)
 
     for path in gladepath:
         # append slash to dirname
@@ -63,9 +63,8 @@
         if os.path.isfile(fname):
             return fname
 
-    raise IOError, \
-    """%s not found in path %s.  You probably need to
-Kiwi.set_gladepath() correctly""" % ( filename, gladepath )
+    raise IOError("%s not found in path %s.  You probably need to "
+                  "Kiwi.set_gladepath() correctly" % (filename, gladepath))
 
 #
 # Signal brokers
@@ -124,12 +123,12 @@
                 continue
             widget = getattr(view, w_name, None)
             if not widget:
-                raise AttributeError, \
-                    "couldn't find widget %s in %s" % (w_name, view)
+                raise AttributeError("couldn't find widget %s in %s"
+                                     % (w_name, view))
             if not isinstance(widget, (gtk.Widget, gtk.Action)):
-                raise AttributeError, \
-                    "%s (%s) is not a widget or an action and can't be connected to" \
-                        % (w_name, widget)
+                raise AttributeError("%s (%s) is not a widget or an action "
+                                     "and can't be connected to"
+                                     % (w_name, widget))
             # Must use getattr; using the class method ends up with it
             # being called unbound and lacking, thus, "self".
             try:
@@ -138,8 +137,8 @@
                 else:
                    widget.connect(signal, methods[fname])
             except TypeError, e:
-                raise AttributeError, "Widget %s doesn't provide a signal %s" \
-                                       % (widget.__class__, signal)
+                raise AttributeError("Widget %s doesn't provide a signal %s"
+                                     % (widget.__class__, signal))
             if not self._autoconnected.has_key(widget):
                 self._autoconnected[widget] = []
             self._autoconnected[widget].append(id)
@@ -160,7 +159,7 @@
         # called by framework.basecontroller. takes a controller, and
         # creates the dictionary to attach to the signals in the tree.
         if not methods:
-            raise assertionerror, "controller must be provided"
+            raise assertionerror("controller must be provided")
 
         dict = {}
         for name, method in methods.items():
@@ -212,9 +211,9 @@
                          "gladename", "tree", "model", "controller"]:
             # XXX: take into account widget constructor?
             if reserved in self.widgets:
-                raise AttributeError, ("The widgets list for %s contains "
-                                       "a widget named `%s', which is "
-                                       "a reserved. name""" % (self, reserved))
+                raise AttributeError("The widgets list for %s contains "
+                                     "a widget named `%s', which is "
+                                     "a reserved. name""" % (self, reserved))
 
 
         self.glade_adaptor = None
@@ -225,9 +224,9 @@
             self.toplevel = getattr(self, self.toplevel_name, None)
         
         if not self.toplevel:
-            raise TypeError, \
-                ("A View requires an instance variable called toplevel "
-                 "that specifies the toplevel widget in it")
+            raise TypeError("A View requires an instance variable "
+                            "called toplevel that specifies the "
+                            "toplevel widget in it")
 
 
         self.proxies = []
@@ -245,7 +244,7 @@
         if container_name is None:
             msg = ("You provided a gladefile %s to grab the widgets from "
                    "but you didn't give me a toplevel/container name!")
-            raise ValueError, msg % self.gladefile
+            raise ValueError(msg % self.gladefile)
 
         # a SlaveView inside a glade file needs to come inside a toplevel
         # window, so we pull our slave out from it, grab its groups and
@@ -253,7 +252,7 @@
         shell = self.glade_adaptor.get_widget(container_name)
         if not isinstance(shell, gtk.Window):
             msg = "Container %s should be a Window, found %s"
-            raise TypeError, msg % (container_name, type(shell))
+            raise TypeError(msg % (container_name, type(shell)))
 
         # XXX grab the accel groups
 
@@ -292,11 +291,11 @@
         name = string.replace(name,'.','_')
         widget = getattr(self, name, None)
         if not widget:
-            raise AttributeError, \
-                "Widget %s not found in view %s" % (name, self)
+            raise AttributeError("Widget %s not found in view %s"
+                                 % (name, self))
         if not isinstance(widget, gtk.Widget):
-            raise TypeError, \
-                "%s in view %s is not a Widget" % (name, self)
+            raise TypeError("%s in view %s is not a Widget"
+                            % (name, self))
         return widget
 
     def set_controller(self, controller):
@@ -305,8 +304,8 @@
         been set before."""
         # Only one controller per view, please
         if self.controller:
-            raise AssertionError, \
-                "This view already has a controller: %s" % self.controller
+            raise AssertionError("This view already has a controller: %s"
+                                 % self.controller)
         self.controller = controller
 
     #
@@ -320,8 +319,8 @@
     def show_all(self, *args):
         """Shows all widgets attached to the toplevel widget"""
         if self.glade_adaptor is not None:
-            raise AssertionError, ("You don't want to call show_all on a "
-                                   "GazpachoView. Use show() instead.")
+            raise AssertionError("You don't want to call show_all on a "
+                                 "GazpachoView. Use show() instead.")
         self.toplevel.show_all()
 
     def focus_toplevel(self):
@@ -421,7 +420,7 @@
         if self.glade_adaptor is None:
             msg = ("You can't attach slaves if you are not using a glade file "
                    "in your View")
-            raise ValueError, msg
+            raise ValueError(msg)
         
         else:
             self.glade_adaptor.attach_slave(name, slave) # delegation powered
@@ -441,11 +440,11 @@
             - after: a boolean; if TRUE, we use connect_after(), otherwise, connect()
         """
         if not isinstance(widgets, (list, tuple)):
-            raise TypeError, "widgets must be a list, found %s" % widgets
+            raise TypeError("widgets must be a list, found %s" % widgets)
         for widget in widgets:
             if not isinstance(widget, gtk.Widget):
-                raise TypeError, \
-                "Only Gtk widgets may be passed in list, found\n%s" % widget
+                raise TypeError(
+                "Only Gtk widgets may be passed in list, found\n%s" % widget)
             if after:
                 widget.connect_after(signal, handler)
             else:
@@ -498,21 +497,21 @@
             SlaveView.__init__(self, toplevel, widgets, gladefile, gladename,
                                toplevel_name)
         except KeyError:
-            raise KeyError, ("Some widgets were defined in self.widgets "
-                             "but not found in the glade tree (see previous "
-                             "messages to see which ones).")
+            raise KeyError("Some widgets were defined in self.widgets "
+                           "but not found in the glade tree (see previous "
+                           "messages to see which ones).")
             
 
         if not isinstance(self.toplevel, gtk.Window):
-            raise TypeError, ("toplevel widget must be a Window "
-                              "(or inherit from it),\nfound `%s' %s" 
-                              % (toplevel, self.toplevel))
+            raise TypeError("toplevel widget must be a Window "
+                            "(or inherit from it),\nfound `%s' %s" 
+                            % (toplevel, self.toplevel))
 
         if delete_handler:
             id = self.toplevel.connect("delete_event", delete_handler)
             if not id:
-                raise ValueError, \
-                    "Invalid delete handler provided: %s" % delete_handler
+                raise ValueError(
+                    "Invalid delete handler provided: %s" % delete_handler)
 
     def _init_glade_adaptor(self):
         self.glade_adaptor = GazpachoWidgetTree(self, self.gladefile,
@@ -554,8 +553,8 @@
         elif isinstance(view, gtk.Window):
             self.toplevel.set_transient_for(view)
         else:
-            raise TypeError, ("Parameter to set_transient_for should "
-                              "be View (found %s)" % view)
+            raise TypeError("Parameter to set_transient_for should "
+                            "be View (found %s)" % view)
 
     def set_title(self, title):
         """Sets the view's window title"""
@@ -658,10 +657,10 @@
         widgets = (widgets or self.view.widgets or [])[:]
         
         if not gladefile:
-            raise ValueError, "A gladefile wasn't provided."
+            raise ValueError("A gladefile wasn't provided.")
         elif not isinstance(gladefile, basestring):
-            raise TypeError, \
-                  "gladefile should be a string, found %s" % type(gladefile)
+            raise TypeError(
+                  "gladefile should be a string, found %s" % type(gladefile))
         
         # get base name of glade file
         basename = os.path.basename(gladefile)
@@ -687,13 +686,13 @@
     def get_widget(self, name):
         """Retrieves the named widget from the View (or glade tree)"""
         if self.tree is None:
-            raise TypeError, \
-                  "No tree defined for %s, did you call the constructor?" % self.view
+            raise TypeError(
+                  "No tree defined for %s, did you call the constructor?" % self.view)
         name = name.replace('.', '_')
         widget = self.tree.get_widget(name)
         if widget is None:
-            raise AttributeError, \
-                  "Widget %s not found in view %s" % (name, self.view)
+            raise AttributeError(
+                  "Widget %s not found in view %s" % (name, self.view))
         return widget
 
     def get_widgets(self):
@@ -726,7 +725,7 @@
             _warn("slave specified must be a SlaveView, found %s" % slave)
 
         if not hasattr(slave, "get_toplevel"):
-            raise TypeError, "Slave does not have a get_toplevel method"
+            raise TypeError("Slave does not have a get_toplevel method")
 
         shell = slave.get_toplevel()
 
@@ -738,8 +737,8 @@
 
         placeholder  = self.get_widget(name)
         if not placeholder:
-            raise attributeerror, \
-                  "slave container widget `%s' not found" % name
+            raise attributeerror(
+                  "slave container widget `%s' not found" % name)
         parent = placeholder.get_parent()
 
         if slave._accel_groups:
@@ -771,8 +770,8 @@
             parent.remove(placeholder)
             parent.add(new_widget)
         else:
-            raise typeerror, \
-                "widget to be replaced must be wrapped in eventbox"
+            raise typeerror(
+                "widget to be replaced must be wrapped in eventbox")
      
         # call slave's callback
         slave.on_attach(self)

Modified: Kiwi2/Kiwi2/WidgetProxies/Base.py
===================================================================
--- Kiwi2/Kiwi2/WidgetProxies/Base.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/WidgetProxies/Base.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -141,7 +141,7 @@
                 value = self._get_datetime(value)
             except DateTimeError:
                 if self.proxy._conversion_errors:
-                    raise ConversionError, "Unconvertible value %r" % value
+                    raise ConversionError("Unconvertible value %r" % value)
                 # If we got an invalid date, set the model value to
                 # None. This is harsh, but more correct (the other
                 # option would be not updating it at all, leaving
@@ -154,7 +154,7 @@
                 value = self._get_numeric(value)
             except ValueError:
                 if self.proxy._conversion_errors:
-                    raise ConversionError, "Unconvertible value %r" % value
+                    raise ConversionError("Unconvertible value %r" % value)
                 value = None
             return value
         
@@ -214,17 +214,17 @@
                 if self.datetime:
                     valid_type = 1
                 else: 
-                    raise TypeError, ("%s needs to be set_datetime(); "
-                                      "an unexpected DateTime value %s "
-                                      "was found""" % (self.name, value))
+                    raise TypeError("%s needs to be set_datetime(); "
+                                    "an unexpected DateTime value %s "
+                                    "was found""" % (self.name, value))
             elif self.datetime:
-                raise TypeError, ("%s set as DateTime, but has non-datetime "
-                                  "value %r" % (self.name, value))
+                raise TypeError("%s set as DateTime, but has non-datetime "
+                                "value %r" % (self.name, value))
 
         if not valid_type:
-            raise TypeError, ("failed converting %s '%s' to string. Only "
-                              "None, DateTime, string, ints and float are "
-                              "allowed""" % (valuetype, str(value)))
+            raise TypeError("failed converting %s '%s' to string. Only "
+                            "None, DateTime, string, ints and float are "
+                            "allowed""" % (valuetype, str(value)))
 
         if self.format:
             try:
@@ -233,12 +233,14 @@
                 else:
                     value = self.format % value
             except TypeError, e:
-                raise TypeError, ("Failed to convert the contents of %r: "
-                                  "The format string %r can't convert "
-                                  "the data %r %r.  Did you forget to call "
-                                  "set_numeric(), or are the arguments to "
-                                  "set_format() incorrect?" % (self.name, 
-                                  self.format, repr(value), type(value)))
+                raise TypeError("Failed to convert the contents of %r: "
+                                "The format string %r can't convert "
+                                "the data %r %r.  Did you forget to call "
+                                "set_numeric(), or are the arguments to "
+                                "set_format() incorrect?" % (self.name, 
+                                                             self.format,
+                                                             repr(value),
+                                                             type(value)))
 
         # if using a decimal separator, convert all numbers, whether
         # numeric or not

Modified: Kiwi2/Kiwi2/WidgetProxies/CheckButton.py
===================================================================
--- Kiwi2/Kiwi2/WidgetProxies/CheckButton.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/WidgetProxies/CheckButton.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -34,7 +34,7 @@
             value = False
         if value not in (True, False):
             msg = "bad value %s for widget %s:\nexpected integer/boolean"
-            raise TypeError, msg % (repr(value), self.name)
+            raise TypeError(msg % (repr(value), self.name))
         self._block_handlers()
         # set_active does *not* emit any signal, which is why we need to
         # call toggled() right after it.

Modified: Kiwi2/Kiwi2/WidgetProxies/Entry.py
===================================================================
--- Kiwi2/Kiwi2/WidgetProxies/Entry.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/WidgetProxies/Entry.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -121,8 +121,8 @@
             print "OINK", value
             self.widget.set_text(value)
         else:
-            raise TypeError, \
-                "Value %s for %s is of invalid type" % (value, self.name)
+            raise TypeError(
+                "Value %s for %s is of invalid type" % (value, self.name))
         if old_text == value:
             # XXX GTK+ change from 1.2 to 2.x
             self.widget.emit("changed")

Modified: Kiwi2/Kiwi2/WidgetProxies/OptionMenu.py
===================================================================
--- Kiwi2/Kiwi2/WidgetProxies/OptionMenu.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/WidgetProxies/OptionMenu.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -92,7 +92,7 @@
         for item in menu.get_children():
             data = item.get_data("_kiwi_data") 
             valid.append(data)
-        raise ValueError, """Couldn't set value `%s' for widget %s
+        raise ValueError("""Couldn't set value `%s' for widget %s
 Valid values: %s\n
 (Hint: this can happen if you are using an OptionMenu with some items
 created in glade but doing a prefill() afterwards. If you are using
@@ -101,7 +101,7 @@
 
 Note also that you can *not* use an empty string or 0 (zero) to indicate
 you want the default selection; None is the *only* value that the Proxy
-interprets as "unset" or "use default".)""" % (value, self.name, valid)
+interprets as "unset" or "use default".)""" % (value, self.name, valid))
 
     def read(self, item=None):
         menu = self.widget.get_menu()

Modified: Kiwi2/Kiwi2/Widgets/List.py
===================================================================
--- Kiwi2/Kiwi2/Widgets/List.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/Widgets/List.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -105,7 +105,7 @@
             if ' ' in attribute:
                 msg = ("The attribute can not contain spaces, otherwise I can"
                        " not find the value in the instances: %s" % attribute)
-                raise AttributeError, msg
+                raise AttributeError(msg)
             self.attribute = attribute
         if title is not None:
             self.title = title
@@ -206,7 +206,7 @@
         fields = data_string.split('|')
         if len(fields) != 10:
             msg = 'every column should have 10 fields: %s' % col
-            raise ValueError, msg
+            raise ValueError(msg)
 
         # the attribute is mandatory
         if not fields[0]:
@@ -350,14 +350,14 @@
             value = kgetattr(instance, c.attribute, ValueUnset)
             if value is ValueUnset:
                 msg = "Failed to get attribute '%s' for %s"
-                raise TypeError, msg % (c.attribute, instance)
+                raise TypeError(msg % (c.attribute, instance))
             
             tp = type(value)
             c.data_type = tp
             if tp is type(None):
-                raise TypeError, \
+                raise TypeError(
                       """Detected invalid type None for column `%s'; please
-                      specify type in Column constructor.""" % c.attribute
+                      specify type in Column constructor.""" % c.attribute)
 
     def _create_columns(self):
         """Create the treeview columns"""
@@ -467,7 +467,7 @@
 #            renderer.set_property('editable', True)
 #            renderer.connect('edited', self._on_renderer__edited, column_index)
         else:
-            raise ValueError, "the type %s is not supported yet" % data_type
+            raise ValueError("the type %s is not supported yet" % data_type)
         
         return renderer
 
@@ -627,7 +627,7 @@
         elif isinstance(arg, gtk.TreeIter):
             item = self.model.get_value(arg, 0)
         else:
-            raise ValueError, "the index is not an intenger neither a iter"
+            raise ValueError("the index is not an intenger neither a iter")
         
         return item
 
@@ -637,7 +637,7 @@
         elif isinstance(arg, gtk.TreeIter):
             self.model.set_value(arg, 0, item)
         else:
-            raise ValueError, "the index is not an intenger neither a iter"
+            raise ValueError("the index is not an intenger neither a iter")
             
     def __len__(self):
         return len(self.model)
@@ -781,7 +781,7 @@
                 cols.append(str(col))
             self._column_definitions_string = '^'.join(cols)
         else:
-            raise ValueError, "value should be a string of a list of columns"
+            raise ValueError("value should be a string of a list of columns")
 
         self._clear_columns()
         self._create_columns()
@@ -792,13 +792,13 @@
         if pspec.name == 'column-definitions':
             return self.get_column_definitions()
         else:
-            raise AttributeError, 'Unknown property %s' % pspec.name
+            raise AttributeError('Unknown property %s' % pspec.name)
 
     def do_set_property(self, pspec, value):
         if pspec.name == 'column-definitions':
             self.set_column_definitions(value)
         else:
-            raise AttributeError, 'Unknown property %s' % pspec.name
+            raise AttributeError('Unknown property %s' % pspec.name)
     
     def add_instance(self, instance, select=False):
         """Adds an instance to the list.
@@ -846,13 +846,13 @@
         if not self._has_enough_type_information():
             msg = ("There is no columns neither data on the list yet so you "
                    "can not remove any instance")
-            raise RuntimeError, msg
+            raise RuntimeError(msg)
 
         # linear search for the instance to remove
         instance_iter = self._get_iter_from_instance(instance)
         if instance_iter is None:
             msg = "The instance %s is not in the list so I can not remove it"
-            raise ValueError, msg % instance
+            raise ValueError(msg % instance)
 
         # now is safe to remove it
         self.model.remove(instance_iter)
@@ -861,7 +861,7 @@
         iter = self._get_iter_from_instance(new_instance)
         if iter is None: 
             msg = "The instance %s is not in the list so I can not update it"
-            raise ValueError, msg % new_instance
+            raise ValueError(msg % new_instance)
         self.model.row_changed(self.model.get_path(iter), iter)
         
     def set_column_visibility(self, column_index, visibility):

Modified: Kiwi2/Kiwi2/Widgets/WidgetProxy.py
===================================================================
--- Kiwi2/Kiwi2/Widgets/WidgetProxy.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/Widgets/WidgetProxy.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -49,12 +49,12 @@
         """
         if self._data_type is None:
             msg = "You must set the data type before updating a Kiwi widget"
-            raise TypeError, msg
+            raise TypeError(msg)
 
         dt = supported_types_names.index(self._data_type)
         if not isinstance(data, supported_types[dt]):
-            raise TypeError, "Data is supposed to be a %s but it is %s: %s" % \
-                  (self._data_type, type(data), data)
+            raise TypeError("Data is supposed to be a %s but it is %s: %s" % \
+                            (self._data_type, type(data), data))
 
     def read(self):
         """Get the content of the widget.
@@ -67,14 +67,14 @@
         try:
             return getattr(self, "get_%s" % prop_name)()
         except AttributeError:
-            raise AttributeError, "Invalid property name: %s" % pspec.name
+            raise AttributeError("Invalid property name: %s" % pspec.name)
 
     def do_set_property(self, pspec, value):
         prop_name = pspec.name.replace("-", "_")
         try:
             getattr(self, "set_%s" % prop_name)(value)
         except AttributeError:
-            raise AttributeError, "Invalid property name: %s" % pspec.name
+            raise AttributeError("Invalid property name: %s" % pspec.name)
         
     def get_data_type(self):
         return self._data_type
@@ -85,8 +85,8 @@
             return
         
         if data_type not in supported_types_names:
-            raise TypeError, "%s is not supported. Supported types are: %s" % \
-                  (data_type, ','.join(supported_types_names))
+            raise TypeError("%s is not supported. Supported types are: %s" %
+                            (data_type, ','.join(supported_types_names)))
         self._data_type = data_type
 
         # if we don't have a default value, get one from the default table
@@ -109,7 +109,7 @@
         """
         if self._data_type is None:
             msg = "You must set the data type before converting a string"
-            raise TypeError, msg
+            raise TypeError(msg)
         assert isinstance(data, basestring)
         # if the user clear the widget we should not raise a conversion error
         if data == '':
@@ -120,7 +120,7 @@
         """Convert a value to a string"""
         if self._data_type is None:
             msg = "You must set the data type before converting a type"
-            raise TypeError, msg
+            raise TypeError(msg)
         dt = supported_types_names.index(self._data_type)
         assert isinstance(data, supported_types[dt])
         return converters[TO_STR][self._data_type](data)

Modified: Kiwi2/Kiwi2/accessors.py
===================================================================
--- Kiwi2/Kiwi2/accessors.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/accessors.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -116,13 +116,13 @@
             pass
 
         def __getitem__(self, k):
-            raise KeyError, "DummyObject"
+            raise KeyError("DummyObject")
 
         def __delitem__(self, k):
-            raise KeyError, "DummyObject"
+            raise KeyError("DummyObject")
 
         def get(self, *args):
-            raise KeyError, "DummyObject"
+            raise KeyError("DummyObject")
     
     weakref=WeakRef()
     _kgetattr_cache = weakref
@@ -329,7 +329,7 @@
             elif icode == LAMBDA_ACCESS:
                 obj = data1()
             else:
-                raise AssertionError, "Unknown tuple type in _kgetattr_cache"
+                raise AssertionError("Unknown tuple type in _kgetattr_cache")
 
         # 2.4. Value wasn't found, return default or raise ValueError
         except AttributeError:
@@ -479,7 +479,7 @@
     elif icode == LAMBDA_ACCESS:
         data1(value)
     else:
-        raise AssertionError, "Unknown tuple type in _ksetattr_cache"
+        raise AssertionError("Unknown tuple type in _ksetattr_cache")
     
 def enable_attr_cache():
     """Enables the use of the kgetattr cache when using Python

Modified: Kiwi2/Kiwi2/initgtk.py
===================================================================
--- Kiwi2/Kiwi2/initgtk.py	2005-03-22 20:57:23 UTC (rev 176)
+++ Kiwi2/Kiwi2/initgtk.py	2005-03-22 21:22:05 UTC (rev 177)
@@ -34,7 +34,7 @@
     import pygtk
     pygtk.require('2.0')
 except ImportError:
-    raise ImportError, "Couldn't import required package PyGTK+ 2.x"
+    raise ImportError("Couldn't import required package PyGTK+ 2.x")
 
 import gtk
 import gobject



More information about the POS-commit mailing list