summaryrefslogtreecommitdiffstats
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
parentd761efc80fe36443fd747d50bbb546ea212639a4 (diff)
Move code to replicate dicts based on times attr to its own function
-rw-r--r--src/osmo_gsm_tester/config.py15
-rw-r--r--src/osmo_gsm_tester/resource.py11
2 files changed, 16 insertions, 10 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
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index d8efe2f..8f34bdb 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -134,16 +134,7 @@ class ResourcesPool(log.Origin):
'''
schema.validate(want, WANT_SCHEMA)
- # replicate items that have a 'times' > 1
- want = copy.deepcopy(want)
- for key, item_list in want.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)
+ want = config.replicate_times(want)
origin_id = origin.origin_id()