Skip to content

Commit

Permalink
wxGUI: Improve exception handling specificity in location wizard (#4953)
Browse files Browse the repository at this point in the history
  • Loading branch information
arohanajit authored Jan 18, 2025
1 parent 2c9b614 commit bfcb541
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ per-file-ignores =
gui/wxpython/animation/g.gui.animation.py: E501
gui/wxpython/tplot/g.gui.tplot.py: E501
gui/wxpython/iclass/g.gui.iclass.py: E501
gui/wxpython/location_wizard/wizard.py: E722
gui/wxpython/mapdisp/main.py: E722
gui/wxpython/mapdisp/test_mapdisp.py: E501
gui/wxpython/mapswipe/g.gui.mapswipe.py: E501
Expand Down
18 changes: 9 additions & 9 deletions gui/wxpython/location_wizard/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def OnSearch(self, event):
self.proj, self.projdesc = self.projlist.Search(
index=[0, 1], pattern=search_str
)
except:
except (IndexError, ValueError):
self.proj = self.projdesc = ""

event.Skip()
Expand Down Expand Up @@ -1188,15 +1188,15 @@ def OnDText(self, event):
self.datumparams = self.parent.datums[self.datum][2]
try:
self.datumparams.remove("dx=0.0")
except:
except ValueError:
pass
try:
self.datumparams.remove("dy=0.0")
except:
except ValueError:
pass
try:
self.datumparams.remove("dz=0.0")
except:
except ValueError:
pass

nextButton.Enable(True)
Expand All @@ -1211,7 +1211,7 @@ def OnDSearch(self, event):
self.datum, self.ellipsoid, self.datumdesc = self.datumlist.Search(
index=[0, 1, 2], pattern=search_str
)
except:
except (IndexError, ValueError):
self.datum = self.datumdesc = self.ellipsoid = ""

event.Skip()
Expand Down Expand Up @@ -1392,7 +1392,7 @@ def OnSearch(self, event):
self.ellipseparams = self.parent.ellipsoids[self.ellipse][1]
else:
self.ellipseparams = self.parent.planetary_ellipsoids[self.ellipse][1]
except:
except (IndexError, ValueError, KeyError):
self.ellipse = self.ellipsedesc = self.ellipseparams = ""

event.Skip()
Expand Down Expand Up @@ -1935,7 +1935,7 @@ def OnText(self, event):
self.epsgcode = event.GetString()
try:
self.epsgcode = int(self.epsgcode)
except:
except ValueError:
self.epsgcode = None

nextButton = wx.FindWindowById(wx.ID_FORWARD)
Expand Down Expand Up @@ -2558,7 +2558,7 @@ def __readData(self):
plist.append(p)
self.projections[proj.lower().strip()] = (projdesc.strip(), plist)
self.projdesc[proj.lower().strip()] = projdesc.strip()
except:
except (ValueError, IndexError):
continue
f.close()

Expand Down Expand Up @@ -2620,7 +2620,7 @@ def __readData(self):
try:
pparam, datatype, proj4term, desc = line.split(":")
self.paramdesc[pparam] = (datatype, proj4term, desc)
except:
except ValueError:
continue
f.close()

Expand Down

0 comments on commit bfcb541

Please sign in to comment.