aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-05-10 13:31:41 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-05-11 12:33:00 +0200
commit803d87c2e82de7fdf22c1507bf325937b11bd9d7 (patch)
treea7435103f46ba910680148a941c671afebbdb8cc
parenta6278b7fd0887da753ca5787cce3dc239fac8c71 (diff)
util: simplify listdict
listdict came into the code base from some other python code of mine, for no apparent reason: it is actually not used here at all. However, an upcoming patch will use a dict of lists. Also, the listdict implementation is convoluted/complex (to allow accessing keys as direct object members, which we don't need). Simplify the implementation to be used by I0939ef414bc599ee8742df48da04d8d9569d00ba. Change-Id: I09adfd128a19c6c5ba36aae1d4cab83dbd07e0fb
-rw-r--r--src/osmo_gsm_tester/util.py26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/osmo_gsm_tester/util.py b/src/osmo_gsm_tester/util.py
index 0849ccb..e985a0f 100644
--- a/src/osmo_gsm_tester/util.py
+++ b/src/osmo_gsm_tester/util.py
@@ -49,34 +49,20 @@ def ip_to_iface(ip):
pass
return None
-class listdict:
+class listdict(dict):
'a dict of lists { "a": [1, 2, 3], "b": [1, 2] }'
- def __getattr__(ld, name):
- if name == 'add':
- return ld.__getattribute__(name)
- return ld.__dict__.__getattribute__(name)
- def add(ld, name, item):
- l = ld.__dict__.get(name)
+ def add(self, name, item):
+ l = self.get(name)
if not l:
l = []
- ld.__dict__[name] = l
+ self[name] = l
l.append(item)
return l
- def add_dict(ld, d):
+ def add_dict(self, d):
for k,v in d.items():
- ld.add(k, v)
-
- def __setitem__(ld, name, val):
- return ld.__dict__.__setitem__(name, val)
-
- def __getitem__(ld, name):
- return ld.__dict__.__getitem__(name)
-
- def __str__(ld):
- return ld.__dict__.__str__()
-
+ self.add(k, v)
class DictProxy:
'''