dabo Commit
Revision 4186
Date: 2008-06-26 06:13:13 -0700 (Thu, 26 Jun 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4186
Changed:
U trunk/dabo/ui/__init__.py
U trunk/dabo/ui/uiwx/__init__.py
U trunk/dabo/ui/uiwx/concordance.py
U trunk/dabo/ui/uiwx/dBorderSizer.py
U trunk/dabo/ui/uiwx/dButton.py
U trunk/dabo/ui/uiwx/dCheckBox.py
U trunk/dabo/ui/uiwx/dColorDialog.py
U trunk/dabo/ui/uiwx/dControlItemMixin.py
U trunk/dabo/ui/uiwx/dControlMixin.py
U trunk/dabo/ui/uiwx/dDateTextBox.py
U trunk/dabo/ui/uiwx/dDialog.py
U trunk/dabo/ui/uiwx/dDockForm.py
U trunk/dabo/ui/uiwx/dEditor.py
U trunk/dabo/ui/uiwx/dFoldPanelBar.py
U trunk/dabo/ui/uiwx/dFont.py
U trunk/dabo/ui/uiwx/dForm.py
U trunk/dabo/ui/uiwx/dFormMixin.py
U trunk/dabo/ui/uiwx/dGrid.py
U trunk/dabo/ui/uiwx/dGridSizer.py
U trunk/dabo/ui/uiwx/dHtmlBox.py
U trunk/dabo/ui/uiwx/dHyperLink.py
U trunk/dabo/ui/uiwx/dImage.py
U trunk/dabo/ui/uiwx/dKeys.py
U trunk/dabo/ui/uiwx/dListControl.py
U trunk/dabo/ui/uiwx/dMenu.py
U trunk/dabo/ui/uiwx/dPage.py
U trunk/dabo/ui/uiwx/dPageFrameMixin.py
U trunk/dabo/ui/uiwx/dPageFrameNoTabs.py
U trunk/dabo/ui/uiwx/dPanel.py
U trunk/dabo/ui/uiwx/dPdfWindow.py
U trunk/dabo/ui/uiwx/dPemMixin.py
U trunk/dabo/ui/uiwx/dRadioList.py
U trunk/dabo/ui/uiwx/dSizerMixin.py
U trunk/dabo/ui/uiwx/dSpinner.py
U trunk/dabo/ui/uiwx/dSplitter.py
U trunk/dabo/ui/uiwx/dStatusBar.py
U trunk/dabo/ui/uiwx/dTextBoxMixin.py
U trunk/dabo/ui/uiwx/dTreeView.py
U trunk/dabo/ui/uiwx/uiApp.py
Log:
Removed bare 'except:' lines.
Diff:
Modified: trunk/dabo/ui/__init__.py
===================================================================
--- trunk/dabo/ui/__init__.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/__init__.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -174,18 +174,15 @@
def _resolveGet(self, nm):
ret = None
for att in self.__class__._proxyDict[nm]:
- try:
- if att == "self":
- base = getattr(self, "_baseClass",
self.__class__)
- obj = base.__bases__[0]
- prop = getattr(obj, nm)
- ret = prop.fget(self)
- else:
- obj = getattr(self, att)
- ret = getattr(obj, nm)
- break
- except:
- continue
+ if att == "self":
+ base = getattr(self, "_baseClass",
self.__class__)
+ obj = base.__bases__[0]
+ prop = getattr(obj, nm)
+ ret = prop.fget(self)
+ else:
+ obj = getattr(self, att)
+ ret = getattr(obj, nm)
+ break
return ret
def _resolveSet(self, nm, val):
Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/__init__.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -147,7 +147,7 @@
try:
from dLinePlot import dLinePlot
-except:
+except ImportError:
pass
# dDockForm is not available with wxPython < 2.7
@@ -333,26 +333,23 @@
# Cycle through all the attributes of the wx events,
and evaluate them
# for insertion into the dEvent.EventData dict.
d = dir(wxEvt)
- try:
- upPems = [p for p in d if p[0].isupper()]
- for pem in upPems:
- if pem in ("Skip", "Clone", "Destroy",
"Button", "ButtonIsDown",
- "GetLogicalPosition",
"ResumePropagation", "SetEventObject",
- "SetEventType",
"SetId", "SetExtraLong", "SetInt", "SetString",
- "SetTimestamp",
"StopPropagation"):
- continue
- try:
- pemName = pem[0].lower() +
pem[1:]
- ed[pemName] = eval("wxEvt.%s()"
% pem)
- except:
- pass
- except:
- pass
+ upPems = [p for p in d if p[0].isupper()]
+ for pem in upPems:
+ if pem in ("Skip", "Clone", "Destroy",
"Button", "ButtonIsDown",
+ "GetLogicalPosition",
"ResumePropagation", "SetEventObject",
+ "SetEventType", "SetId",
"SetExtraLong", "SetInt", "SetString",
+ "SetTimestamp",
"StopPropagation"):
+ continue
+ try:
+ pemName = pem[0].lower() + pem[1:]
+ ed[pemName] = eval("wxEvt.%s()" % pem)
+ except AttributeError:
+ pass
if isinstance(wxEvt, (wx.SplitterEvent,) ):
try:
ed["mousePosition"] = (wxEvt.GetX(), wxEvt.GetY())
- except:
+ except AttributeError:
ed["mousePosition"] = wx.GetMousePosition()
if isinstance(wxEvt, (wx.KeyEvent, wx.MouseEvent) ):
@@ -377,7 +374,7 @@
ed["listIndex"] = idx
try:
ed["col"] = wxEvt.GetColumn()
- except:
+ except AttributeError:
pass
if isinstance(wxEvt, wx.MenuEvent):
@@ -394,7 +391,8 @@
# It may have mouse information
try:
ed["mousePosition"] = wxEvt.GetPoint().Get()
- except: pass
+ except AttributeError:
+ pass
# See if it's a menu selection
obj = wxEvt.GetEventObject()
if isinstance(obj, dMenu):
@@ -449,18 +447,18 @@
try:
ed["itemID"] = wxEvt.GetItem()
ed["itemNode"] = tree.find(ed["itemID"])[0]
- except:
+ except (AttributeError, IndexError):
pass
if isinstance(wxEvt, wx.SplitterEvent):
try:
ed["sashPosition"] = wxEvt.GetSashPosition()
- except:
+ except AttributeError:
ed["sashPosition"] = wxEvt.GetEventObject().SashPosition
if wxEvt.GetEventType() == wx.EVT_SPLITTER_UNSPLIT.evtType[0]:
try:
ed["windowRemoved"] =
wxEvt.GetWindowBeingRemoved()
- except:
+ except AttributeError:
ed["windowRemoved"] = None
if hasattr(wxEvt, "GetId"):
@@ -484,7 +482,8 @@
try:
# Don't think this is implemented yet
ed["commandDown"] = wxEvt.CmdDown()
- except: pass
+ except AttributeError:
+ pass
if isinstance(wxEvt, wx.grid.GridSizeEvent):
#ed["rowOrCol"] = wxEvt.GetRowOrCol()
@@ -500,7 +499,8 @@
try:
# Don't think this is implemented yet
ed["commandDown"] = wxEvt.CmdDown()
- except: pass
+ except AttributeError:
+ pass
if isinstance(wxEvt, wx.calendar.CalendarEvent):
ed["date"] = wxEvt.PyGetDate()
@@ -516,7 +516,7 @@
try:
if isinstance(wxEvt, wx.html.HtmlLinkEvent):
ed["href"] = wxEvt.href
- except:
+ except AttributeError:
# wxPython 2.6 and earlier doesn't seem to have this event
pass
@@ -830,7 +830,7 @@
dt = datetime.date.today()
try:
mm, dd, yy = dt.month, dt.day, dt.year
- except:
+ except AttributeError:
dabo.errorLog.write(_("Invalid date value passed to getDate():
%s") % dt)
return None
dlg = wx.lib.calendar.CalenDlg(_getActiveForm(), mm, dd, yy)
@@ -1212,7 +1212,7 @@
dataSet = dataSource.getDataSet()
try:
cap = "Browse: %s" % dataSource.Table
- except:
+ except AttributeError:
cap = "Browse"
else:
raise TypeError, "Incorrect data source passed to
browse()"
@@ -1305,7 +1305,7 @@
if txt is None:
try:
txt = wind.Caption
- except:
+ except AttributeError:
raise ValueError, "No text supplied to fontMetric call"
fnt = wind.GetFont()
if face is not None:
@@ -1320,10 +1320,10 @@
if not isinstance(wind, (dabo.ui.dForm, wx.Frame)):
try:
wind = wind.Form
- except:
+ except AttributeError:
try:
wind = wind.Parent
- except:
+ except AttributeError:
pass
dc = wx.ClientDC(wind)
dc.SetFont(fnt)
Modified: trunk/dabo/ui/uiwx/concordance.py
===================================================================
--- trunk/dabo/ui/uiwx/concordance.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/concordance.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -14,15 +14,12 @@
if hasattr(daboClass, "__mro__"):
for mro in daboClass.__mro__:
if "<class 'wx." in str(mro):
- try:
- if "wx._" in str(mro):
- # normal wx class: don't
include the wx._controls. cruft
- dabo_to_wx[daboName] = "wx.%s"
% str(mro).split(".")[-1][:-2]
- else:
- # extra class: give the full
story:
- dabo_to_wx[daboName] =
str(mro)[8:-2]
- except:
- pass
+ if "wx._" in str(mro):
+ # normal wx class: don't include the
wx._controls. cruft
+ dabo_to_wx[daboName] = "wx.%s" %
str(mro).split(".")[-1][:-2]
+ else:
+ # extra class: give the full story:
+ dabo_to_wx[daboName] = str(mro)[8:-2]
break
daboNames = dabo_to_wx.items()
Modified: trunk/dabo/ui/uiwx/dBorderSizer.py
===================================================================
--- trunk/dabo/ui/uiwx/dBorderSizer.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dBorderSizer.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -23,12 +23,9 @@
if isinstance(box, basestring):
box, orientation = orientation, box
if not isinstance(box, dabo.ui.dBox):
- try:
- prnt = box
- box = dabo.ui.dBox(prnt)
- box.sendToBack()
- except:
- raise dException.dException, "Must pass an
instance of dBox or a parent object to dBorderSizer"
+ prnt = box
+ box = dabo.ui.dBox(prnt)
+ box.sendToBack()
# Convert Dabo orientation to wx orientation
orient = self._extractKey((kwargs, properties), "Orientation",
orientation)
if orient[0].lower() == "v":
Modified: trunk/dabo/ui/uiwx/dButton.py
===================================================================
--- trunk/dabo/ui/uiwx/dButton.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dButton.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -98,7 +98,7 @@
continue
try:
db = child.DefaultButton
- except:
+ except AttributeError:
db = False
if db:
child.DefaultButton = False
Modified: trunk/dabo/ui/uiwx/dCheckBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dCheckBox.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dCheckBox.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -92,7 +92,7 @@
else:
try:
state = self._ValueTo3State[val]
- except:
+ except KeyError:
state = False
self.Set3StateValue(state)
Modified: trunk/dabo/ui/uiwx/dColorDialog.py
===================================================================
--- trunk/dabo/ui/uiwx/dColorDialog.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dColorDialog.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -18,7 +18,8 @@
try:
color =
dColors.colorTupleFromName(color)
dat.SetColour(color)
- except: pass
+ except KeyError:
+ pass
elif isinstance(color, tuple):
dat.SetColour(color)
Modified: trunk/dabo/ui/uiwx/dControlItemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dControlItemMixin.py 2008-06-26 13:05:12 UTC (rev
4185)
+++ trunk/dabo/ui/uiwx/dControlItemMixin.py 2008-06-26 13:13:13 UTC (rev
4186)
@@ -221,7 +221,7 @@
# we are using a tuple/list of keys.
Find its position
try:
self.setSelection(self.Keys.index(key))
- except:
+ except IndexError:
# No such key; write an info
message, but otherwise ignore it.
dabo.infoLog.write(_("Key '%s'
not found") % key)
continue
@@ -258,7 +258,8 @@
continue
try:
self._setSelection(index)
- except: pass
+ except IndexError:
+ pass
self._afterValueChanged()
else:
self._properties["PositionValue"] = value
@@ -307,12 +308,12 @@
continue
try:
strings.append(self.GetString(index))
- except:
+ except IndexError:
# If this is a list control, there is no native
GetString.
# Use the Dabo-supplied replacement
try:
strings.append(self._GetString(index))
- except:
+ except IndexError:
# Invalid index; usually an empty list
pass
if not self._isMultiSelect():
Modified: trunk/dabo/ui/uiwx/dControlMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dControlMixin.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dControlMixin.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -21,9 +21,11 @@
# Hide a problem on Windows toolbars where a single command
event will
# be raised up to three separate times.
+# print "CONTROL WXHIT", self, evt
now = time.time()
if not hasattr(self, "_lastHitTime") or (now -
self._lastHitTime) > .001:
self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)
+# print "CONTROL RAISING HIT"
self._lastHitTime = time.time()
def __onWxNavKey(self, evt):
Modified: trunk/dabo/ui/uiwx/dDateTextBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dDateTextBox.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dDateTextBox.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -124,7 +124,7 @@
availHt = self.Parent.Bottom - self.Bottom
try:
self.calPanel.cal.Date = self.Value
- except:
+ except AttributeError:
self.calPanel = CalPanel(self.Parent, dt=self.Value,
ctrl=self)
cp = self.calPanel
cp.Position = (self.Left, self.Bottom)
@@ -158,7 +158,7 @@
key = {72: "h", 77: "m", 83:
"s"}[evt.keyCode]
else:
key = {8: "h", 13: "m", 19:
"s"}[evt.keyCode]
- except:
+ except KeyError:
# spurious key event; ignore
return
@@ -206,7 +206,8 @@
newVal = self.Value
if newVal != val:
self.Value = newVal
- except: pass
+ except ValueError:
+ pass
def adjustDate(self, key, ctrl=False, shift=False):
@@ -367,7 +368,7 @@
try:
self.Value = self.Value.replace(year=yr,
month=mn, day=dy)
ok = True
- except:
+ except ValueError:
dy -= 1
Modified: trunk/dabo/ui/uiwx/dDialog.py
===================================================================
--- trunk/dabo/ui/uiwx/dDialog.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dDialog.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -120,9 +120,7 @@
is removed from the app's forms collection.
"""
if self.Application is not None:
- try:
- self.Application.uiForms.remove(self)
- except: pass
+ self.Application.uiForms.remove(self)
super(dDialog, self).release()
Modified: trunk/dabo/ui/uiwx/dDockForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dDockForm.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dDockForm.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -253,7 +253,7 @@
def _getCaption(self):
try:
return self._caption
- except:
+ except AttributeError:
self._caption = ""
return self._caption
Modified: trunk/dabo/ui/uiwx/dEditor.py
===================================================================
--- trunk/dabo/ui/uiwx/dEditor.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dEditor.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -513,21 +513,13 @@
"""Given a position within the text, returns the corresponding
line
number. If the position is invalid, returns -1.
"""
- try:
- ret = self.LineFromPosition(pos)
- except:
- ret = -1
- return ret
-
-
+ return self.LineFromPosition(pos)
+
+
def getPositionFromLine(self, linenum):
"""Given a line number, returns the position of the start of
that line.
If the line number is invalid, returns -1."""
- try:
- ret = self.PositionFromLine(linenum)
- except:
- ret = -1
- return ret
+ return self.PositionFromLine(linenum)
def getPositionFromXY(self, x, y=None):
@@ -827,7 +819,7 @@
# a raw string was passed
try:
newSize = int(fontSize)
- except:
+ except ValueError:
dabo.errorLog.write(_("Invalid value
passed to changeFontSize: %s") % fontSize)
return
else:
@@ -1168,43 +1160,34 @@
if sarg is not None and sarg == "self":
del args[0][0]
args = inspect.formatargspec(args[0], args[1],
args[2], args[3])
- except:
+ except IndexError:
args = ""
- try:
- if inspect.ismethod(obj):
- funcType = "Method"
- elif inspect.isfunction(obj):
- funcType = "Function"
- elif inspect.isclass(obj):
- funcType = "Class"
- elif inspect.ismodule(obj):
- funcType = "Module"
- elif inspect.isbuiltin():
- funcType = "Built-In"
- else:
- funcType = ""
- except:
+ if inspect.ismethod(obj):
+ funcType = "Method"
+ elif inspect.isfunction(obj):
+ funcType = "Function"
+ elif inspect.isclass(obj):
+ funcType = "Class"
+ elif inspect.ismodule(obj):
+ funcType = "Module"
+ elif inspect.isbuiltin():
+ funcType = "Built-In"
+ else:
funcType = ""
doc = ""
- try:
- docLines = obj.__doc__.splitlines()
- for line in docLines:
- doc += line.strip() + "\n" ##
must be \n on all platforms
- doc = doc.strip() ## Remove trailing blank line
- except:
- pass
+ docLines = obj.__doc__.splitlines()
+ for line in docLines:
+ doc += line.strip() + "\n" ## must be \n
on all platforms
+ doc = doc.strip() ## Remove trailing blank line
try:
name = obj.__name__
- except:
+ except AttributeError:
name = ""
- shortDoc = "%s %s%s" % (funcType,
- name,
- args)
-
+ shortDoc = "%s %s%s" % (funcType, name, args)
longDoc = "%s\n\n%s" % (shortDoc, doc)
self.CallTipShow(pos, shortDoc)
@@ -1344,7 +1327,7 @@
def promptToSave(self):
try:
fname = self._fileName
- except:
+ except AttributeError:
fname = None
if fname is None or fname is "":
s = "Do you want to save your changes?"
@@ -1359,7 +1342,7 @@
if path is None:
try:
drct = self._curdir
- except:
+ except AttributeError:
drct = ""
else:
drct = path
@@ -1406,7 +1389,7 @@
if fname == None:
try:
fname = self._fileName
- except:
+ except AttributeError:
fname = self._newFileName
if not fname or (fname == self._newFileName):
@@ -1418,7 +1401,7 @@
try:
open(fname,
"wb").write(self.GetText().encode(self.Encoding))
- except:
+ except OSError:
dabo.ui.stop("Could not save %s. Please check your
write permissions." % fname)
return False
# set self._fileName, in case it was changed with a Save As
@@ -1516,7 +1499,7 @@
f = open(fileSpec, "rb")
text = f.read().decode(self.Encoding)
f.close()
- except:
+ except OSError:
if os.path.exists(fileSpec):
dabo.ui.stop("Could not open %s.
Please check that you have read permissions." % fileSpec)
return False
@@ -1632,21 +1615,19 @@
if obj:
for attr in dir(obj):
attr = '%s%s'%(word,attr)
- if attr not in words:
words.append(attr)
- except:
+ if attr not in words:
+
words.append(attr)
+ except IndexError:
pass
elif word[-1] in " ()[]{}":
self.AutoCompCancel()
return
if words:
words.sort(lambda a,b: cmp(a.upper(), b.upper()))
- try:
- # For some reason, the STC editor in Windows
likes to add icons
- # even if they aren't requested. This
explicitly removes them.
- wds = ["%s?0" % wd for wd in words]
- self.AutoCompShow(len(word), " ".join(wds))
- except:
- pass
+ # For some reason, the STC editor in Windows likes to
add icons
+ # even if they aren't requested. This explicitly
removes them.
+ wds = ["%s?0" % wd for wd in words]
+ self.AutoCompShow(len(word), " ".join(wds))
def getWord(self,whole=None):
@@ -1688,11 +1669,7 @@
def getWordObject(self,word=None,whole=None):
if not word: word=self.getWord(whole=whole)
- try:
- obj = self.evaluate(word)
- return obj
- except:
- return None
+ return self.evaluate(word)
# End of auto-completion code
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -1792,7 +1769,7 @@
if len(innerObjectNames) > 0:
try:
o = eval("o.%s" % innerObjectNames)
- except:
+ except AttributeError:
o = None
return o
@@ -2062,9 +2039,7 @@
if self._constructed():
self._selectionBackColor = val
if isinstance(val, basestring):
- try:
- val = dColors.colorTupleFromName(val)
- except: pass
+ val = dColors.colorTupleFromName(val)
self.SetSelBackground(1, val)
else:
self._properties["SelectionBackColor"] = val
@@ -2087,9 +2062,7 @@
if self._constructed():
self._selectionForeColor = val
if isinstance(val, basestring):
- try:
- val = dColors.colorTupleFromName(val)
- except: pass
+ val = dColors.colorTupleFromName(val)
self.SetSelForeground(1, val)
else:
self._properties["SelectionForeColor"] = val
Modified: trunk/dabo/ui/uiwx/dFoldPanelBar.py
===================================================================
--- trunk/dabo/ui/uiwx/dFoldPanelBar.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dFoldPanelBar.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -105,7 +105,7 @@
try:
# Call the Dabo version, if present
self.Sizer.layout()
- except:
+ except AttributeError:
pass
if self.Application.Platform == "Win":
self.refresh()
Modified: trunk/dabo/ui/uiwx/dFont.py
===================================================================
--- trunk/dabo/ui/uiwx/dFont.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dFont.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -55,7 +55,7 @@
if val in availableFonts:
try:
return self._nativeFont.SetFaceName(val)
- except:
+ except AttributeError:
return False
return False
@@ -109,7 +109,7 @@
val = val / .75
try:
self._nativeFont.SetPointSize(val)
- except:
+ except ValueError:
dabo.errorLog.write(_("Setting FontSize to %s failed")
% val)
self._propsChanged()
Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dForm.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -715,7 +715,7 @@
if dataSource is None and grid is not None:
# This is being called by a regular grid not tied to a
bizobj
rowCount = grid.RowCount
- rowNumber = grid.CurrentRow+1
+ rowNumber = grid.CurrentRow + 1
else:
bizobj = self.getBizobj(dataSource)
if bizobj is None:
@@ -723,8 +723,8 @@
# Some situations, such as form preview
mode, will
# store these directly, since they lack
bizobjs
rowCount = self.rowCount
- rowNumber = self.rowNumber+1
- except:
+ rowNumber = self.rowNumber + 1
+ except AttributeError:
rowCount = 1
rowNumber = 1
else:
Modified: trunk/dabo/ui/uiwx/dFormMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMixin.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dFormMixin.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -161,7 +161,7 @@
# in __init__ because we may not have our name
yet.
try:
restoredSP = self.restoredSP
- except:
+ except AttributeError:
restoredSP = False
if not restoredSP:
if self.SaveRestorePosition:
@@ -194,7 +194,7 @@
def __onMove(self, evt):
try:
restoredSP = self.restoredSP
- except:
+ except AttributeError:
restoredSP = False
if restoredSP:
dabo.ui.callAfterInterval(800, self.saveSizeAndPosition)
@@ -203,7 +203,7 @@
def __onResize(self, evt):
try:
restoredSP = self.restoredSP
- except:
+ except AttributeError:
restoredSP = False
if restoredSP:
dabo.ui.callAfterInterval(800, self.saveSizeAndPosition)
@@ -247,11 +247,9 @@
#self.SetFocus()
if app is not None:
- try:
- self.Application.uiForms.remove(self)
- except: pass
-
-
+ self.Application.uiForms.remove(self)
+
+
def activeControlValid(self):
""" Force the control-with-focus to fire its KillFocus code.
@@ -494,7 +492,8 @@
try:
# Call the Dabo version, if present
self.Sizer.layout()
- except: pass
+ except AttributeError:
+ pass
if self.Application.Platform == "Win":
self.refresh()
@@ -567,10 +566,13 @@
% self.getAbsoluteName(), 0)
- def pushStatusText(self, txt):
+ def pushStatusText(self, txt, duration=None):
"""Stores the current text of the StatusBar on a LIFO stack for
later retrieval."""
self._statusStack.append(self.StatusText)
self.StatusText = txt
+ if duration is not None:
+ # Pop it after 'duration' seconds
+ dabo.ui.callAfterInterval(1000*duration,
self.popStatusText)
def popStatusText(self):
@@ -857,7 +859,7 @@
if hasattr(self, "GetStatusBar"):
try:
ret = self.GetStatusBar()
- except:
+ except AttributeError:
# pkm: My client got a TypeError from the wx
layer, perhaps because the
# window is a dialog and not a form, but I
can't reproduce on my end.
# Just return None immediately if this
happens again.
Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dGrid.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -112,7 +112,7 @@
def GetRowLabelValue(self, row):
try:
return self.grid.RowLabels[row]
- except:
+ except IndexError:
return ""
@@ -159,12 +159,12 @@
typeDict[Decimal] = "decimal"
try:
col.DataType = typeDict[col.DataType]
- except:
+ except KeyError:
# Not one of the standard types.
Extract it from
# the string version of the type
try:
col.DataType =
str(col.DataType).split("'")[1].lower()
- except:
+ except IndexError:
# Something's odd. Print an
error message and move on.
dabo.errorLog.write("Unknown
data type found in setColumns(): %s"
% col.DataType)
@@ -321,7 +321,8 @@
if rec and rec.has_key(field):
ret = not self.grid.DataSet[row][field]
return ret
- except: pass
+ except (IndexError, KeyError):
+ pass
return ret
return True
@@ -342,7 +343,7 @@
else:
try:
ret = self.grid.DataSet[row][field]
- except:
+ except (IndexError, KeyError):
ret = ""
if ret is None:
ret = self.grid.NoneDisplay
@@ -569,7 +570,7 @@
args = ()
try:
oldVal = getattr(self, prop)
- except:
+ except AttributeError:
needRefresh = True
setattr(self, prop, func(*args, **kwargs))
if needRefresh or oldVal != getattr(self, prop):
@@ -602,10 +603,7 @@
"""Usually don't need this, but it helps to keep this in
line with other Dabo objects.
"""
- try:
- self.Parent.removeColumn(self)
- except:
- pass
+ self.Parent.removeColumn(self)
def _setAbsoluteFontZoom(self, newZoom):
@@ -750,7 +748,7 @@
gridCol = -1
try:
grid = self.Parent
- except:
+ except AttributeError:
grid = None
if grid is not None:
for idx, dCol in enumerate(grid.Columns):
@@ -1261,7 +1259,7 @@
def _getListEditorChoices(self):
try:
v = self._listEditorChoices
- except:
+ except AttributeError:
v = []
return v
@@ -1310,7 +1308,7 @@
def _getSearchable(self):
try:
v = self._searchable
- except:
+ except AttributeError:
v = self._searchable = True
return v
@@ -1324,7 +1322,7 @@
def _getSortable(self):
try:
v = self._sortable
- except:
+ except At:
v = self._sortable = True
return v
@@ -1384,7 +1382,7 @@
# Make sure the grid is in sync:
try:
self.Parent.SetColSize(idx, v)
- except:
+ except AttributeError:
# The grid may still be in the process of being
created, so pass.
pass
return v
@@ -1878,7 +1876,7 @@
def GetCellValue(self, row, col):
try:
ret = self._Table.GetValue(row, col)
- except:
+ except AttributeError:
ret = super(dGrid, self).GetCellValue(row, col)
return ret
@@ -1886,7 +1884,7 @@
def GetValue(self, row, col):
try:
ret = self._Table.GetValue(row, col)
- except:
+ except AttributeError:
ret = super(dGrid, self).GetValue(row, col)
return ret
@@ -2115,7 +2113,7 @@
# the grid. We can get enough info from
getDataStructureFromDescription():
try:
structure =
bizobj.getDataStructureFromDescription()
- except:
+ except TypeError:
# Well, that call failed... seems that
sqlite doesn't define a cursor
# description? I need to test this out.
For now, fall back to the old
# code that gets the data structure by
executing "select * from table
@@ -2139,7 +2137,7 @@
# Use the keyCaption values, if possible
try:
cap = keyCaption[colKey]
- except:
+ except KeyError:
cap = colKey
col = self.addColumn(inBatch=True)
col.Caption = cap
@@ -2265,7 +2263,7 @@
colObj._persist("Width")
try:
self.AutoSizeColumn(colNum, setAsMin=False)
- except:
+ except wx.PyAssertionError:
pass
_setColSize(colNum)
@@ -2935,7 +2933,7 @@
## it's been set as the property but because it
wasn't part of the grid
## yet it hasn't yet taken effect: force it.
col.Width = col.Width
- except:
+ except wx.PyAssertionError:
# If the underlying wx grid doesn't yet know about the
column, such
# as when adding columns with inBatch=True, this can
throw an error
if not inBatch:
@@ -3299,7 +3297,7 @@
newCol = evt.EventData["col"]
try:
col = self.Columns[newCol]
- except:
+ except IndexError:
col = None
if col:
@@ -3507,53 +3505,51 @@
left, right = evt.GetLeftCol(), evt.GetRightCol()
except AttributeError:
left = right = evt.GetCol()
- try:
- if mode == wx.grid.Grid.wxGridSelectRows:
- if (top != bott) or (top != origCol):
- # Attempting to select a range
- if top == origRow:
- row = bott
- else:
- row = top
- self.SetGridCursor(row, self._lastCol)
- self.SelectRow(row)
- elif mode == wx.grid.Grid.wxGridSelectColumns:
- if (left != right) or (left != origCol):
- # Attempting to select a range
- if left == origCol:
- col = right
- else:
- col = left
- self.SetGridCursor(self._lastRow, col)
- self.SelectCol(col)
- else:
- # Cells
- chg = False
- row, col = origRow, origCol
- if top != bott:
- chg = True
- if top == origRow:
- row = bott
- else:
- row = top
- elif top != origRow:
- # New row
- chg = True
+ if mode == wx.grid.Grid.wxGridSelectRows:
+ if (top != bott) or (top != origCol):
+ # Attempting to select a range
+ if top == origRow:
+ row = bott
+ else:
row = top
- if left != right:
- chg = True
- if left == origCol:
- col = right
- else:
- col = left
- elif left != origCol:
- # New col
- chg = True
+ self.SetGridCursor(row, self._lastCol)
+ self.SelectRow(row)
+ elif mode == wx.grid.Grid.wxGridSelectColumns:
+ if (left != right) or (left != origCol):
+ # Attempting to select a range
+ if left == origCol:
+ col = right
+ else:
col = left
- if chg:
- self.SetGridCursor(row, col)
- self.SelectBlock(row, col, row, col)
- except: pass
+ self.SetGridCursor(self._lastRow, col)
+ self.SelectCol(col)
+ else:
+ # Cells
+ chg = False
+ row, col = origRow, origCol
+ if top != bott:
+ chg = True
+ if top == origRow:
+ row = bott
+ else:
+ row = top
+ elif top != origRow:
+ # New row
+ chg = True
+ row = top
+ if left != right:
+ chg = True
+ if left == origCol:
+ col = right
+ else:
+ col = left
+ elif left != origCol:
+ # New col
+ chg = True
+ col = left
+ if chg:
+ self.SetGridCursor(row, col)
+ self.SelectBlock(row, col, row, col)
def __onWxGridEditorShown(self, evt):
@@ -3913,12 +3909,10 @@
ret = None
bo = self.getBizobj()
try:
- ret = self.getBizobj().getDataSet()
+ ret = bo.getDataSet()
except AttributeError:
# See if the DataSource is a reference
- try:
- ret = eval(self.DataSource)
- except: pass
+ ret = self.Source
self._dataSet = ret
else:
try:
@@ -4132,7 +4126,7 @@
def _getRowHeight(self):
try:
v = self._rowHeight
- except:
+ except AttributeError:
v = self._rowHeight = self.GetDefaultRowSize()
return v
@@ -4163,7 +4157,7 @@
def _getRowLabelWidth(self):
try:
v = self._rowLabelWidth
- except:
+ except AttributeError:
v = self._rowLabelWidth = self.GetDefaultRowLabelSize()
return v
@@ -4279,19 +4273,19 @@
try:
self.SetSelectionMode(wx.grid.Grid.wxGridSelectRows)
self._selectionMode = "Row"
- except:
+ except wx.PyAssertionError:
dabo.ui.callAfter(self._setSelectionMode, val)
elif val2 == "co":
try:
self.SetSelectionMode(wx.grid.Grid.wxGridSelectColumns)
self._selectionMode = "Col"
- except:
+ except wx.PyAssertionError:
dabo.ui.callAfter(self._setSelectionMode, val)
else:
try:
self.SetSelectionMode(wx.grid.Grid.wxGridSelectCells)
self._selectionMode = "Cell"
- except:
+ except wx.PyAssertionError:
dabo.ui.callAfter(self._setSelectionMode, val)
if self._selectionMode != orig:
self._checkSelectionType()
@@ -4362,7 +4356,7 @@
## pkm: we can't call this until after the grid is fully
constructed. Need to fix.
try:
tbl = self.GetTable()
- except:
+ except AttributeError:
tbl = None
if not tbl:
try:
Modified: trunk/dabo/ui/uiwx/dGridSizer.py
===================================================================
--- trunk/dabo/ui/uiwx/dGridSizer.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dGridSizer.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -300,7 +300,7 @@
obj = self.getItem(obj)
try:
row, col = self.GetItemPosition(obj)
- except:
+ except wx.PyAssertionError:
# Window isn't controlled by this sizer
row, col = None, None
return (row, col)
@@ -336,7 +336,7 @@
spn = wx.GBSpan(row, col)
try:
self.SetItemSpan(obj, spn)
- except:
+ except wx.PyAssertionError:
raise dabo.ui.GridSizerSpanException, _("An item
already exists in that location")
@@ -387,18 +387,16 @@
"""Returns either the managed item or the sizer item at the
given position if one exists. If not, returns None.
"""
- try:
- itm = self.FindItemAtPosition((row, col))
- if returnObject:
- if itm.IsWindow():
- ret = itm.GetWindow()
- elif itm.IsSizer():
- ret = itm.GetSizer()
- else:
- # Return the sizer item itself.
- ret = itm
- except:
- ret = None
+ ret = None
+ itm = self.FindItemAtPosition((row, col))
+ if returnObject:
+ if itm.IsWindow():
+ ret = itm.GetWindow()
+ elif itm.IsSizer():
+ ret = itm.GetSizer()
+ else:
+ # Return the sizer item itself.
+ ret = itm
return ret
@@ -422,13 +420,9 @@
row, col = self.getGridPos(obj)
newRow = row + off[0]
newCol = col + off[1]
- try:
- ret = self.getItemByRowCol(newRow, newCol)
- except:
- ret = None
- return ret
+ return self.getItemByRowCol(newRow, newCol)
-
+
def getItemProp(self, itm, prop):
if not isinstance(itm, (self.SizerItem, self.GridSizerItem)):
itm = itm.ControllingSizerItem
Modified: trunk/dabo/ui/uiwx/dHtmlBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dHtmlBox.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dHtmlBox.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -134,7 +134,7 @@
self._source = url.read()
self.LoadPage(val)
self._page = val
- except:
+ except urllib2.URLError:
self._source = "<html><body>Cannot Open URL
%s</body><html>" % (val,)
self._page = ""
self.SetPage(self._source)
Modified: trunk/dabo/ui/uiwx/dHyperLink.py
===================================================================
--- trunk/dabo/ui/uiwx/dHyperLink.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dHyperLink.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -52,17 +52,11 @@
"""Updated the link with the specified colors."""
lc, vc, rc = self._linkColor, self._visitedColor,
self._hoverColor
if isinstance(lc, basestring):
- try:
- lc = dColors.colorTupleFromName(lc)
- except: pass
+ lc = dColors.colorTupleFromName(lc)
if isinstance(vc, basestring):
- try:
- vc = dColors.colorTupleFromName(vc)
- except: pass
+ vc = dColors.colorTupleFromName(vc)
if isinstance(rc, basestring):
- try:
- rc = dColors.colorTupleFromName(rc)
- except: pass
+ rc = dColors.colorTupleFromName(rc)
self.SetColours(lc, vc, rc)
self.UpdateLink(True)
Modified: trunk/dabo/ui/uiwx/dImage.py
===================================================================
--- trunk/dabo/ui/uiwx/dImage.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dImage.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -224,7 +224,9 @@
idx = self.PictureIndex = maxIdx
try:
self._Image.LoadFile(val, index=idx)
- except:
+ except IndexError:
+ # Note: when I try to load an invalid index, I
get a segfault, so I don't know
+ # how useful this is.
self._Image.LoadFile(val, index=-1)
if self._Image.Ok():
self._imgProp = float(self._Image.GetWidth()) /
float(self._Image.GetHeight())
@@ -282,9 +284,8 @@
if not isFile:
# Probably an image stream
try:
- log = wx.LogNull()
img = dabo.ui.imageFromData(val)
- except:
+ except TypeError:
# No dice, so just bail
img = wx.EmptyImage(1, 1)
self._setPic(img)
Modified: trunk/dabo/ui/uiwx/dKeys.py
===================================================================
--- trunk/dabo/ui/uiwx/dKeys.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dKeys.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -6,7 +6,7 @@
try:
# Versions < 2.8 don't have this
key_Command = wx.WXK_COMMAND
-except:
+except AttributeError:
key_Command = None
key_Back = wx.WXK_BACK
key_Tab = wx.WXK_TAB
@@ -133,7 +133,7 @@
try:
# Versions < 2.8 don't have this
mod_Cmd = wx.ACCEL_CMD
-except:
+except AttributeError:
mod_Cmd = None
mod_Normal = wx.ACCEL_NORMAL
Modified: trunk/dabo/ui/uiwx/dListControl.py
===================================================================
--- trunk/dabo/ui/uiwx/dListControl.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dListControl.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -37,7 +37,7 @@
try:
style = style | wx.LC_REPORT
- except:
+ except NameError:
style = wx.LC_REPORT
preClass = wx.PreListCtrl
dcm.dControlItemMixin.__init__(self, preClass, parent,
properties, attProperties,
@@ -428,7 +428,7 @@
try:
itm = self.GetItem(row, col)
data.append((itm.GetText(), row))
- except:
+ except AttributeError:
pass
data.sort()
if (self._sortOrder % 2):
Modified: trunk/dabo/ui/uiwx/dMenu.py
===================================================================
--- trunk/dabo/ui/uiwx/dMenu.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dMenu.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -59,7 +59,7 @@
self.raiseEvent(dEvents.MenuOpen, evt)
else:
evt.Skip()
- except:
+ except AttributeError:
evt.Skip()
@@ -74,7 +74,7 @@
self.raiseEvent(dEvents.MenuClose, evt)
else:
evt.Skip()
- except:
+ except AttributeError:
evt.Skip()
@@ -104,7 +104,7 @@
# separators haven't been abstracted yet, so there are
still pure wx items.
try:
de = item.DynamicEnabled
- except:
+ except AttributeError:
de = None
if de is not None:
if callable(de):
@@ -333,13 +333,13 @@
if itm is target:
try:
itm.Checked =True
- except:
+ except AttributeError:
pass
else:
if unCheckOthers:
try:
itm.Checked = False
- except:
+ except AttributeError:
pass
@@ -460,7 +460,7 @@
def _getCaption(self):
try:
v = self._caption
- except:
+ except AttributeError:
v = self._caption = ""
return v
Modified: trunk/dabo/ui/uiwx/dPage.py
===================================================================
--- trunk/dabo/ui/uiwx/dPage.py 2008-06-26 13:05:12 UTC (rev 4185)
+++ trunk/dabo/ui/uiwx/dPage.py 2008-06-26 13:13:13 UTC (rev 4186)
@@ -32,7 +32,7 @@
""" Set up the default vertical box sizer for the page."""
try:
szCls = self.Parent.PageSizerClass
- except:
+ except AttributeError:
# Not part of a paged control
return
if szCls is not None:
@@ -69,7 +69,7 @@
""" Returns the position of this page within its parent."""
try:
ret = self.Parent.Pages.index(self)
- exc
(19748 bytes were truncated as it was too long for the email (max 40000 bytes.)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]