Skip to content

Commit 9bd10af

Browse files
remove redundant datetime conversion
1 parent 17f09ad commit 9bd10af

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

pygeoapi_config_dialog.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,6 @@
7878
headers = {"accept": "*/*", "Content-Type": "application/json"}
7979

8080

81-
def preprocess_for_json(d):
82-
"""Recursively converts datetime/date objects in a dict to ISO strings."""
83-
if isinstance(d, dict):
84-
return {k: preprocess_for_json(v) for k, v in d.items()}
85-
elif isinstance(d, list):
86-
return [preprocess_for_json(i) for i in d]
87-
elif isinstance(d, (datetime, date)):
88-
return d.isoformat()
89-
return d
90-
91-
9281
class ServerConfigDialog(QDialog, Ui_serverDialog):
9382
"""
9483
Logic for the Server Configuration Dialog.
@@ -190,7 +179,7 @@ def on_button_clicked(self, button):
190179
# check #1: show diff with "Procced" and "Cancel" options
191180
if not self._diff_original_and_current_data():
192181
return
193-
182+
194183
self.server_config(save=True)
195184
else:
196185
# check #1: show diff with "Procced" and "Cancel" options
@@ -236,10 +225,9 @@ def push_to_server(self, url):
236225
f"Pushing configuration to: {url}",
237226
)
238227

239-
config_dict = self.config_data.asdict_enum_safe(self.config_data)
240-
241-
# Pre-process the dictionary to handle datetime objects
242-
processed_config_dict = preprocess_for_json(config_dict)
228+
processed_config_dict = self.config_data.asdict_enum_safe(
229+
self.config_data, datetime_to_str=True
230+
)
243231

244232
# TODO: support authentication through the QT framework
245233
try:

0 commit comments

Comments
 (0)