Skip to content

Commit

Permalink
wxGUI: Fix E722 do not use bare 'except' warnings in gui_core/ (#4396)
Browse files Browse the repository at this point in the history
* updated 722 from gui_core

* updated flake8

* updated ghelp v2

* updated ghelp v3

* Update gui/wxpython/gui_core/dialogs.py

Co-authored-by: Anna Petrasova <[email protected]>

* removed prints

* Update dialogs.py

* updated indexerror

* updated exception

* Update .flake8

* Update .flake8

---------

Co-authored-by: Anna Petrasova <[email protected]>
  • Loading branch information
arohanajit and petrasovaa authored Oct 1, 2024
1 parent 3e53e34 commit 25619dd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
6 changes: 0 additions & 6 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ per-file-ignores =
doc/python/m.distance.py: E501
doc/gui/wxpython/example/dialogs.py: F401
gui/scripts/d.wms.py: E501
gui/wxpython/gui_core/*: E722
gui/wxpython/gui_core/dialogs.py: E722
gui/wxpython/gui_core/forms.py: E722
gui/wxpython/gui_core/ghelp.py: E722
gui/wxpython/gui_core/gselect.py: E722
gui/wxpython/gui_core/widgets.py: E722
gui/wxpython/image2target/*: F841, E722
gui/wxpython/image2target/g.gui.image2target.py: E501, F841
gui/wxpython/iscatt/*: F841, E722, F405, F403
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ def _filter(self, data):
try:
if re.compile(self.flt_pattern).search(dt):
flt_data.append(dt)
except:
except re.error:
pass

return flt_data
Expand Down Expand Up @@ -1656,7 +1656,7 @@ def OnFilter(self, event):
try:
if re.compile(event.GetString()).search(layer):
list.append(layer)
except:
except re.error:
pass
list = naturally_sorted(list)

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar
# check wildcard
try:
fExt = os.path.splitext(p.get("key_desc", ["*.*"])[0])[1]
except:
except IndexError:
fExt = None
if not fExt:
fMask = "*"
Expand Down
14 changes: 7 additions & 7 deletions gui/wxpython/gui_core/ghelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,15 @@ def _langString(self, k, v):
allStr = "%s :" % k.upper()
try:
allStr += _(" %d translated") % v["good"]
except:
except KeyError:
pass
try:
allStr += _(" %d fuzzy") % v["fuzzy"]
except:
except KeyError:
pass
try:
allStr += _(" %d untranslated") % v["bad"]
except:
except KeyError:
pass
return allStr

Expand All @@ -589,7 +589,7 @@ def _langBox(self, par, k, v):
)
tgood.SetForegroundColour(wx.Colour(35, 142, 35))
langBox.Add(tgood)
except:
except KeyError:
tgood = StaticText(parent=par, id=wx.ID_ANY, label="")
langBox.Add(tgood)
try:
Expand All @@ -598,7 +598,7 @@ def _langBox(self, par, k, v):
)
tfuzzy.SetForegroundColour(wx.Colour(255, 142, 0))
langBox.Add(tfuzzy)
except:
except KeyError:
tfuzzy = StaticText(parent=par, id=wx.ID_ANY, label="")
langBox.Add(tfuzzy)
try:
Expand All @@ -607,7 +607,7 @@ def _langBox(self, par, k, v):
)
tbad.SetForegroundColour(wx.Colour(255, 0, 0))
langBox.Add(tbad)
except:
except KeyError:
tbad = StaticText(parent=par, id=wx.ID_ANY, label="")
langBox.Add(tbad)
return langBox
Expand Down Expand Up @@ -844,7 +844,7 @@ def fillContentsFromFile(self, htmlFile, skipDescription=True):
contents.append(line)
self.SetPage("".join(contents))
self.loaded = True
except: # The Manual file was not found
except Exception: # The Manual file was not found
self.loaded = False


Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/gselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def GetElementList(self, elements=None, exclude=False):
try:
self.seltree.EnsureVisible(item)
self.seltree.SelectItem(item)
except:
except Exception:
pass

def _getElementList(self, element, mapsets=None, elements=None, exclude=False):
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def _validate(self, win):
if text:
try:
datetime.strptime(text, "%Y-%m-%d")
except:
except ValueError:
self._notvalid()
return False

Expand Down

0 comments on commit 25619dd

Please sign in to comment.