diff options
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py')
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py | 17 |
1 files changed, 17 insertions, 0 deletions
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 bd48f939..4b599f16 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 @@ -100,11 +100,28 @@ def RC_ERR (err): def RC_WARN (warn): return RC(True, warn, is_warn = True) +try: + long + long_exists = True +except: + long_exists = False + +def is_integer(arg): + if type(arg) is int: + return True + if long_exists and type(arg) is long: + return True + return False # validate type of arg # example1: validate_type('somearg', somearg, [int, long]) # example2: validate_type('another_arg', another_arg, str) def validate_type(arg_name, arg, valid_types): + if long_exists: + if valid_types is int: + valid_types = (int, long) + elif type(valid_types) is list and int in valid_types and long not in valid_types: + valid_types.append(long) if type(valid_types) is list: valid_types = tuple(valid_types) if (type(valid_types) is type or # single type, not array of types |