summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-03-17 16:54:46 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-03-17 16:54:46 +0200
commit6af21336f6942263943dcd4385bc28d80d6fc1fe (patch)
tree98dd045c5064608cc852bb5f4dd06c9d7bc355c8 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
parent11425470921de652bc6849666562d4bc4045229b (diff)
fix integer checks, now they include "long"
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.py17
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