From b1252bf9371b2b104a25b2c0e498930553f1b778 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Wed, 25 Sep 2024 06:04:09 +0000 Subject: [PATCH 1/3] refactored dialogs.py v2 --- gui/wxpython/dbmgr/dialogs.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gui/wxpython/dbmgr/dialogs.py b/gui/wxpython/dbmgr/dialogs.py index 26e6d876371..8749ef338a4 100644 --- a/gui/wxpython/dbmgr/dialogs.py +++ b/gui/wxpython/dbmgr/dialogs.py @@ -222,10 +222,13 @@ def GetSQLString(self, updateValues=False): ctype = columns[name]["ctype"] value = columns[name]["values"][idx] id = columns[name]["ids"][idx] - try: - newvalue = self.FindWindowById(id).GetValue() - except: - newvalue = self.FindWindowById(id).GetLabel() + widget = self.FindWindowById(id) + if hasattr(widget, "GetValue"): + newvalue = widget.GetValue() + elif hasattr(widget, "GetLabel"): + newvalue = widget.GetLabel() + else: + raise AttributeError(f"AttributeError in {widget}") if newvalue: try: From f698de31bde2ce9c8ea0f7b795cf8ae9b6ad726f Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Wed, 25 Sep 2024 06:04:37 +0000 Subject: [PATCH 2/3] update flake8 --- .flake8 | 1 - 1 file changed, 1 deletion(-) diff --git a/.flake8 b/.flake8 index d570fac7990..93ed48e30a6 100644 --- a/.flake8 +++ b/.flake8 @@ -26,7 +26,6 @@ per-file-ignores = doc/gui/wxpython/example/dialogs.py: F401 gui/scripts/d.wms.py: E501 gui/wxpython/dbmgr/base.py: E722 - gui/wxpython/dbmgr/dialogs.py: E722 gui/wxpython/dbmgr/sqlbuilder.py: E722 gui/wxpython/dbmgr/manager.py: E722 gui/wxpython/docs/wxgui_sphinx/conf.py: E402, W291 From 9ca07bc54ddeae7d9a3e8ca5e33e72d71dcbbd4b Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Wed, 25 Sep 2024 20:12:17 -0700 Subject: [PATCH 3/3] Update gui/wxpython/dbmgr/dialogs.py Co-authored-by: Vaclav Petras --- gui/wxpython/dbmgr/dialogs.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gui/wxpython/dbmgr/dialogs.py b/gui/wxpython/dbmgr/dialogs.py index 8749ef338a4..0d7c6e9e523 100644 --- a/gui/wxpython/dbmgr/dialogs.py +++ b/gui/wxpython/dbmgr/dialogs.py @@ -223,12 +223,10 @@ def GetSQLString(self, updateValues=False): value = columns[name]["values"][idx] id = columns[name]["ids"][idx] widget = self.FindWindowById(id) - if hasattr(widget, "GetValue"): + try: newvalue = widget.GetValue() - elif hasattr(widget, "GetLabel"): + except AttributeError: newvalue = widget.GetLabel() - else: - raise AttributeError(f"AttributeError in {widget}") if newvalue: try: