Skip to content

Commit

Permalink
add support for append end extend actions in copy-map files
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotan committed Nov 4, 2024
1 parent e4e76ea commit 3057758
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024-11-04 Jan Kotanski <jankotan@gmail.com>
* add support for append end extend actions in copy-map files (#726)
* tagged as v4.17.0

2024-10-22 Jan Kotanski <jankotan@gmail.com>
* improve datasetName values generation in the ScanNames mode (#723)
* tagged as v4.16.2
Expand Down
18 changes: 17 additions & 1 deletion nxstools/nxsfileinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,10 @@ def overwrite(self, metadata, cmap=None, clist=None, cmapfield=None):
isinstance(line[0], basestring) and \
isinstance(line[1], basestring) and \
not line[0].startswith(line[1] + "."):
action = None
if line and len(line) > 2 and line[2] and \
isinstance(line[2], basestring):
action = line[2]
ts = line[0]
vs = line[1]
vls = vs.split(".")
Expand All @@ -743,7 +747,19 @@ def overwrite(self, metadata, cmap=None, clist=None, cmapfield=None):
else:
td[tg] = {}
td = td[tg]
parent[tg] = md
if action.lower() in ["extend", "append", "e", "a"]:
if tg not in parent:
parent[tg] = []
elif not isinstance(parent[tg], list):
parent[tg] = [parent[tg]]
if action.lower() in ["extend", "e"] and \
isinstance(md, list):
parent[tg].extend(md)
else:
parent[tg].append(md)

else:
parent[tg] = md
return metadata

def remove_metadata(self, metadata, cmap=None, clist=None, cmapfield=None):
Expand Down
2 changes: 1 addition & 1 deletion nxstools/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
""" NXS tools release version"""

#: (:obj:`str`) package version
__version__ = "4.16.2"
__version__ = "4.17.0"

0 comments on commit 3057758

Please sign in to comment.