Commit bcd5c671 authored by payno's avatar payno
Browse files

[core][spectrum] simplify the

parent b849c062
......@@ -338,19 +338,14 @@ class Spectrum(_Spectrum_Base):
"requires it, won't be able to load data "
"relative to larch"
)
for key in ddict["_larch_grp_members"]:
if key in ddict:
if hasattr(key, "decode"):
key = key.decode("UTF-8")
value = ddict[key]
del ddict[key]
else:
try:
value = ddict["_larch_grp_members"][key]
except Exception as e:
raise RuntimeError("Fails with key", key, "type", type(key))
larch_ddict[key] = None if value_is_none(value) else value
else:
for key, value in ddict["_larch_grp_members"].items():
if key in ddict:
if hasattr(key, "decode"):
key = key.decode("UTF-8")
value = ddict[key]
del ddict[key]
larch_ddict[key] = None if value_is_none(value) else value
for key, value in ddict.items():
if hasattr(value, "decode"):
......@@ -407,13 +402,14 @@ class Spectrum(_Spectrum_Base):
assert _has_larch is True
res = {}
res["_larch_grp_members"] = list(self._members().keys())
for key in self._members().keys():
if isinstance(self[key], LarchGroup):
res[key] = larchutils.group_to_dict(self[key])
else:
res[key] = getattr(self, key)
return res
return {
"_larch_grp_members": res,
}
def __str__(self):
def add_info(str_, attr):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment