fixed OSError unsupported dile type bug when saving chip as .json

This commit is contained in:
John Henry Beale
2026-06-11 15:14:24 +02:00
parent c3a92ff242
commit 006b337d8c
+13 -13
View File
@@ -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)