Skip to content

Commit 6ae322e

Browse files
authored
Merge pull request #586 from FAIRmat-NFDI/fix_short_notation
fix short "*{}" notation
2 parents 7bcf527 + a10d7b4 commit 6ae322e

File tree

1 file changed

+10
-7
lines changed
  • src/pynxtools/dataconverter/readers

1 file changed

+10
-7
lines changed

src/pynxtools/dataconverter/readers/utils.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,17 @@ def update_config(key, value, rkey):
255255
create_link_dict=create_link_dict,
256256
)
257257
)
258-
elif create_link_dict and isinstance(value, str) and value.startswith("@link:"):
259-
flattened_config[key] = {"link": value[6:]}
260258
else:
261-
flattened_config[key] = value
259+
if rkey is not None and isinstance(value, str):
260+
value = value.replace("*", rkey)
261+
if (
262+
create_link_dict
263+
and isinstance(value, str)
264+
and value.startswith("@link:")
265+
):
266+
flattened_config[key] = {"link": value[6:]}
267+
else:
268+
flattened_config[key] = value
262269

263270
for key, value in json_data.items():
264271
if base_key is not None:
@@ -274,10 +281,6 @@ def update_config(key, value, rkey):
274281
expand_keys = expand_match.group(1).split(",")
275282
for ekey in expand_keys:
276283
rkey = key.replace(expand_match.group(0), ekey)
277-
278-
if isinstance(value, str):
279-
value = value.replace("*", ekey)
280-
281284
update_config(rkey, value, ekey)
282285
continue
283286

0 commit comments

Comments
 (0)