fix frappy.lib.merge_status
merge_status should consider that the status text in arguments is already composed. add test for this. Change-Id: Ia000d1e1d8e97a5c2b5ef9d1569cc123232016ae Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31378 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@@ -401,8 +401,15 @@ class UniqueObject:
|
||||
def merge_status(*args):
|
||||
"""merge status
|
||||
|
||||
the status with biggest code wins
|
||||
texts matching maximal code are joined with ', '
|
||||
for combining stati of different mixins
|
||||
- the status with biggest code wins
|
||||
- texts matching maximal code are joined with ', '
|
||||
- if texts already contain ', ', it is considered as composed by
|
||||
individual texts and duplication is avoided. when commas are used
|
||||
for other purposes, the behaviour might be surprising
|
||||
"""
|
||||
maxcode = max(a[0] for a in args)
|
||||
return maxcode, ', '.join([a[1] for a in args if a[0] == maxcode and a[1]])
|
||||
merged = [a[1] for a in args if a[0] == maxcode and a[1]]
|
||||
# use dict instead of set for preserving order
|
||||
merged = {m: True for mm in merged for m in mm.split(', ')}
|
||||
return maxcode, ', '.join(merged)
|
||||
|
||||
Reference in New Issue
Block a user