summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/config.py
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-09-12 13:43:40 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2017-09-12 17:06:56 +0200
commit6e96f494dc4568164af48d76f72b1e1b4dd0f779 (patch)
tree2eb0e2e241d485acee4aa9baece8d20ee2a94777 /src/osmo_gsm_tester/config.py
parentd761efc80fe36443fd747d50bbb546ea212639a4 (diff)
Move code to replicate dicts based on times attr to its own function
Diffstat (limited to 'src/osmo_gsm_tester/config.py')
-rw-r--r--src/osmo_gsm_tester/config.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/osmo_gsm_tester/config.py b/src/osmo_gsm_tester/config.py
index f6e81ac..a0fe969 100644
--- a/src/osmo_gsm_tester/config.py
+++ b/src/osmo_gsm_tester/config.py
@@ -52,6 +52,7 @@
import yaml
import os
+import copy
from . import log, schema, util
from .util import is_dict, is_list, Dir, get_tempdir
@@ -271,4 +272,18 @@ def overlay(dest, src):
dest[i] = overlay(dest[i], src[i])
return dest
return src
+
+def replicate_times(d):
+ 'replicate items that have a "times" > 1'
+ d = copy.deepcopy(d)
+ for key, item_list in d.items():
+ more_items = []
+ for item in item_list:
+ times = int(item.pop('times'))
+ if times and times > 1:
+ for i in range(times - 1):
+ more_items.append(copy.deepcopy(item))
+ item_list.extend(more_items)
+ return d
+
# vim: expandtab tabstop=4 shiftwidth=4