From 569c2261da18f30188c841af90567f38aa817412 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Thu, 31 Oct 2024 14:55:19 -0400 Subject: [PATCH 1/5] fixed 722 --- .flake8 | 2 +- gui/wxpython/psmap/frame.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.flake8 b/.flake8 index 3adda73f28..9cdfcbfc93 100644 --- a/.flake8 +++ b/.flake8 @@ -24,7 +24,7 @@ per-file-ignores = gui/scripts/d.wms.py: E501 gui/wxpython/image2target/g.gui.image2target.py: E501 gui/wxpython/photo2image/g.gui.photo2image.py: E501 - gui/wxpython/psmap/*: E501, E722 + gui/wxpython/psmap/*: E501 gui/wxpython/vdigit/*: F841, E722, F405, F403 gui/wxpython/animation/g.gui.animation.py: E501 gui/wxpython/tplot/frame.py: F841, E722 diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 8926b8d1e7..0759b3f8a1 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -1049,7 +1049,7 @@ def makePSFont(self, textDict): fn = wx.Font( pointSize=fontsize, family=family, style=style, weight=weight, face=face ) - except: + except (ValueError, wx.PyAssertionError): fn = wx.Font( pointSize=fontsize, family=wx.FONTFAMILY_DEFAULT, @@ -1071,7 +1071,7 @@ def getTextExtent(self, textDict): dc.SetFont(fn) w, h, lh = dc.GetFullMultiLineTextExtent(textDict["text"]) return (w, h) - except: + except (wx.PyAssertionError, ValueError): return (0, 0) def getInitMap(self): From 5041d4c511f28f368e62d406584146b887315e4a Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 12:24:43 -0800 Subject: [PATCH 2/5] Update gui/wxpython/psmap/frame.py Co-authored-by: Anna Petrasova --- gui/wxpython/psmap/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 0759b3f8a1..0c321571b7 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -1047,7 +1047,7 @@ def makePSFont(self, textDict): try: fn = wx.Font( - pointSize=fontsize, family=family, style=style, weight=weight, face=face + pointSize=fontsize, family=family, style=style, weight=weight, faceName=face ) except (ValueError, wx.PyAssertionError): fn = wx.Font( From a7ed9e7ec7698b7bb08b4dcb54b9670eb1e4c76a Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 15:29:26 -0500 Subject: [PATCH 3/5] updates --- gui/wxpython/psmap/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 0c321571b7..2a75332e3d 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -1071,7 +1071,7 @@ def getTextExtent(self, textDict): dc.SetFont(fn) w, h, lh = dc.GetFullMultiLineTextExtent(textDict["text"]) return (w, h) - except (wx.PyAssertionError, ValueError): + except (wx.PyAssertionError, ValueError, KeyError): return (0, 0) def getInitMap(self): From 5ec08081c6eb0baf0600251a0d4858348676209f Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 4 Nov 2024 12:35:43 -0800 Subject: [PATCH 4/5] Update gui/wxpython/psmap/frame.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- gui/wxpython/psmap/frame.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 2a75332e3d..2e84fc2149 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -1047,7 +1047,11 @@ def makePSFont(self, textDict): try: fn = wx.Font( - pointSize=fontsize, family=family, style=style, weight=weight, faceName=face + pointSize=fontsize, + family=family, + style=style, + weight=weight, + faceName=face, ) except (ValueError, wx.PyAssertionError): fn = wx.Font( From 6f87314b7a35d7e9f0bfede25e835a13b0dd08ff Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Tue, 5 Nov 2024 14:20:19 -0500 Subject: [PATCH 5/5] update --- gui/wxpython/psmap/frame.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 2e84fc2149..22194ece0c 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -1045,23 +1045,9 @@ def makePSFont(self, textDict): if "Bold" in fontstyle: weight = wx.FONTWEIGHT_BOLD - try: - fn = wx.Font( - pointSize=fontsize, - family=family, - style=style, - weight=weight, - faceName=face, - ) - except (ValueError, wx.PyAssertionError): - fn = wx.Font( - pointSize=fontsize, - family=wx.FONTFAMILY_DEFAULT, - style=wx.FONTSTYLE_NORMAL, - weight=wx.FONTWEIGHT_NORMAL, - ) - - return fn + return wx.Font( + pointSize=fontsize, family=family, style=style, weight=weight, faceName=face + ) def getTextExtent(self, textDict): """Estimates bounding rectangle of text"""