From 006b337d8ca56aac5ee2ef6ad04b58fd05ee3ca3 Mon Sep 17 00:00:00 2001 From: John Henry Beale Date: Thu, 11 Jun 2026 15:14:24 +0200 Subject: [PATCH] fixed OSError unsupported dile type bug when saving chip as .json --- ModuleFixTarget.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ModuleFixTarget.py b/ModuleFixTarget.py index b3f625f..adc6e88 100644 --- a/ModuleFixTarget.py +++ b/ModuleFixTarget.py @@ -368,16 +368,16 @@ class WndFixTarget(QWidget): if not filename: return - #settings.setValue("folders/last_prelocation_folder", QFileInfo(filename).canonicalPath()) - #_log.info("Saving data in {}".format(filename)) - #data = self.get_data(as_numpy=True) - #df = pd.DataFrame(data) - #df.to_csv(filename, float_format="%.6f") - #import numpy as np - base,ext=os.path.splitext(filename) - if ext=='': - ext='.json' - filename=base+ext + filename = str(filename).strip() + base, ext = os.path.splitext(filename) + ext = ext.strip().lower() + if ext == '': + ext = '.json' + filename = base + ext + elif not ext.startswith('.'): + ext = f'.{ext}' + filename = base + ext + try: wnd=app._mainWnd except AttributeError: @@ -387,11 +387,11 @@ class WndFixTarget(QWidget): grp=wnd._goTracked data=grp.childItems() - if ext.lower()=='.json': + if ext == '.json': with open(filename, 'w') as f: - json.dump(data, f,cls=MyJsonEncoder, indent=2)#separators=(',', ':') + json.dump(data, f, cls=MyJsonEncoder, indent=2) # separators=(',', ':') else: - raise(IOError('unsupported file type')) + raise IOError('unsupported file type') #elif ext=='yaml': # with open(filename, 'w') as f: # yaml.dump(self._data, f)