Skip to content

Commit

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

2024-10-22 Jan Kotanski <jankotan@gmail.com>
Expand Down
18 changes: 13 additions & 5 deletions nxstools/nxsfileinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,7 @@ class GroupMetadata(Runner):
mintype = ["Min", "min"]
maxtype = ["Max", "max"]
uniquelisttype = ["UniqueList", "U", "u", "uniquelist"]
singlelisttype = ["SingleList", "S", "s", "singlelist"]
endpointstype = ["Endpoints", "endpoints", "E", "e"]
firstlasttype = ["FirstLast", "firstlast"]
lasttype = ["Last", "last", "l", "L"]
Expand Down Expand Up @@ -1981,7 +1982,8 @@ def _merge_string(cls, parent, key, md, tgtype=None):
tg = None
if key in parent.keys():
tg = parent[key]
if tgtype in cls.listtype or tgtype in cls.uniquelisttype:
if tgtype in cls.listtype or tgtype in cls.uniquelisttype \
or tgtype in cls.singlelisttype:
if not isinstance(tg, list):
if tg:
parent[key] = [tg]
Expand Down Expand Up @@ -2009,7 +2011,9 @@ def _merge_string(cls, parent, key, md, tgtype=None):
else:
parent[key][1] = md
elif key in parent and isinstance(parent[key], list):
if tgtype not in cls.uniquelisttype or md not in parent[key]:
if (tgtype not in cls.uniquelisttype and \
tgtype not in cls.singlelisttype) or \
md not in parent[key]:
parent[key].append(md)
elif not tg:
parent[key] = md
Expand Down Expand Up @@ -2219,7 +2223,11 @@ def _merge_list_list(cls, parent, key, md, unit, tgtype):
and md != parent[key]:
parent[key] = [tg]

if tgtype not in cls.uniquelisttype or \
if tgtype in cls.singlelisttype:
for mm in md:
if mm not in parent[key]:
parent[key].append(mm)
elif tgtype not in cls.uniquelisttype or \
(md not in parent[key] and md != parent[key]):
if tgtype in cls.uniquelisttype and not parent[key]:
parent[key] = md
Expand Down Expand Up @@ -2508,9 +2516,9 @@ def _merge_list(cls, parent, key, md, unit, tgtype=None):
return cls._merge_firstlast_list(parent, key, md, unit)
if tgtype in cls.endpointstype:
return cls._merge_endpoints_list(parent, key, md, unit)
if (tgtype in cls.listtype or tgtype in cls.uniquelisttype):
if tgtype in cls.listtype or tgtype in cls.uniquelisttype \
or tgtype in cls.singlelisttype:
return cls._merge_list_list(parent, key, md, unit, tgtype)

elif tgtype in cls.dicttype:
return cls._merge_dict_list(parent, key, md, unit)
elif md:
Expand Down

0 comments on commit 0f6b427

Please sign in to comment.