[PATCH] osmo-gsm-tester[master]: config: Fix combination of lists

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Aug 28 12:34:04 UTC 2017


Review at  https://gerrit.osmocom.org/3722

config: Fix combination of lists

It can make sense to recursively call combine() for a list containing
complex structures like dictionaries or lists. However, for a list of
simple types (eg. integers or strings), we just want to merge both lists
and we only need to check if the value is already there. This case won't
work if we call combine for each element of the list because for a
simple case it will just end up checking if a[i] == b[i].

Change-Id: Ib7a38f10eb9de338a77bf1fa3afceb9df1532015
---
M src/osmo_gsm_tester/config.py
1 file changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/22/3722/1

diff --git a/src/osmo_gsm_tester/config.py b/src/osmo_gsm_tester/config.py
index f6e81ac..392cd04 100644
--- a/src/osmo_gsm_tester/config.py
+++ b/src/osmo_gsm_tester/config.py
@@ -246,7 +246,11 @@
             raise ValueError('cannot combine list with a value of type: %r' % type(src))
         for i in range(len(src)):
             log.ctx(idx=i)
-            combine(dest[i], src[i])
+            assert type(dest[i]) == type(src[i])
+            if is_dict(dest[i]) or is_list(dest[i]):
+                combine(dest[i], src[i])
+            elif src[i] not in dest:
+                dest.append(src[i])
         return
     if dest == src:
         return

-- 
To view, visit https://gerrit.osmocom.org/3722
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7a38f10eb9de338a77bf1fa3afceb9df1532015
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list