From 134182597898323d1d47229e9af55df7616b7a1e Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 19 May 2016 18:27:24 +0300 Subject: enhance stats to support JSON --- .../trex_control_plane/stl/trex_stl_lib/trex_stl_types.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py') diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py index d84af22f..85215f3d 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py @@ -147,16 +147,15 @@ def listify (x): return [x] # shows as 'N/A', but does not let any compares for user to not mistake in automation -class StatNotAvailable(object): - def __init__(self, stat_name): - self.stat_name = stat_name - - def __repr__(self, *args, **kwargs): - return 'N/A' +class StatNotAvailable(str): + def __new__(cls, value, *args, **kwargs): + cls.stat_name = value + return super(X, cls).__new__(cls, 'N/A') def __cmp__(self, *args, **kwargs): raise Exception("Stat '%s' not available at this setup" % self.stat_name) + class LRU_cache(OrderedDict): def __init__(self, maxlen = 20, *args, **kwargs): OrderedDict.__init__(self, *args, **kwargs) -- cgit 1.2.3-korg