Skip to content

Commit

Permalink
wxGUI: Fixed bare 'except' in nviz/ (#4613)
Browse files Browse the repository at this point in the history
* updated E722

* updates

* updates

---------

Co-authored-by: Anna Petrasova <[email protected]>
  • Loading branch information
arohanajit and petrasovaa authored Oct 30, 2024
1 parent 9be02ee commit 9581ca1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 46 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ per-file-ignores =
doc/python/m.distance.py: E501
gui/scripts/d.wms.py: E501
gui/wxpython/image2target/g.gui.image2target.py: E501
gui/wxpython/nviz/*: E722
gui/wxpython/photo2image/g.gui.photo2image.py: E501
gui/wxpython/psmap/*: E501, E722
gui/wxpython/vdigit/*: F841, E722, F405, F403
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/nviz/mapwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def LoadDataLayers(self):
GError(parent=self, message=e.value)
# when nviz.tools is not yet ready
# during opening 3D view 2nd time
except:
except Exception:
pass

stop = gs.clock()
Expand Down
62 changes: 18 additions & 44 deletions gui/wxpython/nviz/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def SetInitialMaps(self):
else:
try:
selection = layers[0].GetName()
except:
except (AttributeError, IndexError):
continue
if ltype == "raster":
self.FindWindowById(self.win["surface"]["map"]).SetValue(selection)
Expand Down Expand Up @@ -734,24 +734,11 @@ def _createDataPage(self):
self.mainPanelData = SP.ScrolledPanel(parent=self)
self.mainPanelData.SetupScrolling(scroll_x=False)
self.mainPanelData.AlwaysShowScrollbars(hflag=False)
try: # wxpython <= 2.8.10
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
style=fpb.FPB_DEFAULT_STYLE,
extraStyle=fpb.FPB_SINGLE_FOLD,
)
except:
try: # wxpython >= 2.8.11
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)
except: # to be sure
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData, id=wx.ID_ANY, style=fpb.FPB_SINGLE_FOLD
)
self.foldpanelData = fpb.FoldPanelBar(
parent=self.mainPanelData,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)

self.foldpanelData.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)

Expand Down Expand Up @@ -814,24 +801,11 @@ def _createAppearancePage(self):
self.mainPanelAppear = SP.ScrolledPanel(parent=self)
self.mainPanelAppear.SetupScrolling(scroll_x=False)
self.mainPanelAppear.AlwaysShowScrollbars(hflag=False)
try: # wxpython <= 2.8.10
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
style=fpb.FPB_DEFAULT_STYLE,
extraStyle=fpb.FPB_SINGLE_FOLD,
)
except:
try: # wxpython >= 2.8.11
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)
except: # to be sure
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear, id=wx.ID_ANY, style=fpb.FPB_SINGLE_FOLD
)
self.foldpanelAppear = fpb.FoldPanelBar(
parent=self.mainPanelAppear,
id=wx.ID_ANY,
agwStyle=fpb.FPB_SINGLE_FOLD,
)

self.foldpanelAppear.Bind(fpb.EVT_CAPTIONBAR, self.OnPressCaption)
# light page
Expand Down Expand Up @@ -3360,7 +3334,7 @@ def OnSetSurface(self, event):
name = event.GetString()
try:
self._getLayerPropertiesByName(name, mapType="raster")["surface"]
except:
except (AttributeError, TypeError, KeyError):
self.EnablePage("fringe", False)
return

Expand All @@ -3384,7 +3358,7 @@ def OnSetVector(self, event):
name = event.GetString()
try:
data = self._getLayerPropertiesByName(name, mapType="vector")["vector"]
except:
except (AttributeError, TypeError, KeyError):
self.EnablePage("vector", False)
return
layer = self._getMapLayerByName(name, mapType="vector")
Expand All @@ -3396,7 +3370,7 @@ def OnSetRaster3D(self, event):
name = event.GetString()
try:
data = self._getLayerPropertiesByName(name, mapType="raster_3d")["volume"]
except:
except (AttributeError, TypeError, KeyError):
self.EnablePage("volume", False)
return

Expand Down Expand Up @@ -4925,7 +4899,7 @@ def OnCPlaneSelection(self, event):
try:
planeIndex = int(plane.split()[-1]) - 1
self.EnablePage("cplane", enabled=True)
except:
except (ValueError, IndexError):
planeIndex = -1
self.EnablePage("cplane", enabled=False)
self.mapWindow.SelectCPlane(planeIndex)
Expand All @@ -4942,7 +4916,7 @@ def OnCPlaneChanging(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

if event.GetId() in (
Expand Down Expand Up @@ -4984,7 +4958,7 @@ def OnCPlaneShading(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

self.mapWindow.cplanes[planeIndex]["shading"] = shading
Expand All @@ -4999,7 +4973,7 @@ def OnCPlaneReset(self, event):
plane = self.FindWindowById(self.win["cplane"]["planes"]).GetStringSelection()
try:
planeIndex = int(plane.split()[-1]) - 1
except: # TODO disabled page
except (ValueError, IndexError): # TODO disabled page
planeIndex = -1

self.mapWindow.cplanes[planeIndex] = copy.deepcopy(
Expand Down

0 comments on commit 9581ca1

Please sign in to comment.