MCPcopy Create free account
hub / github.com/apache/trafficserver / get_value

Method get_value

doc/ext/traffic-server.py:93–119  ·  view source on GitHub ↗
(type, value)

Source from the content-addressed store, hash-verified

91 def add_object(config, var, value, type=None):
92
93 def get_value(type, value):
94
95 def have_multipliers(value, mps):
96 for m in mps:
97 if value.endswith(m):
98 return True
99
100 return False
101
102 if value is None or value == 'nullptr' or value == 'NULL':
103 return None
104
105 # We want to make the type right when inserting the element into the dict.
106 if type == 'FLOAT':
107 return float(value)
108 elif type == 'INT':
109 # We need to make it YAML compliant as this will be an int, so if contains
110 # any special character like hex or a multiplier, then we make a string. ATS will
111 # parse it as string anyway.
112 if value.startswith('0x') or have_multipliers(value, ['K', 'M', 'G', 'T']):
113 return str(value)
114 else:
115 return int(value)
116 elif type == 'STRING':
117 return str(value)
118
119 return None
120
121 obj = {}
122 key = ''

Callers 6

OperatorSetRedirectClass · 0.45
initializeMethod · 0.45
execMethod · 0.45
add_operatorMethod · 0.45
test_parsingFunction · 0.45
test_processingFunction · 0.45

Calls 2

have_multipliersFunction · 0.85
strFunction · 0.85

Tested by 2

test_parsingFunction · 0.36
test_processingFunction · 0.36