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

Function get_value

tools/records/convert2yaml.py:171–197  ·  view source on GitHub ↗
(type, value)

Source from the content-addressed store, hash-verified

169
170
171def get_value(type, value):
172
173 def have_multipliers(value, mps):
174 for m in mps:
175 if value.endswith(m):
176 return True
177
178 return False
179
180 if value == 'nullptr' or value == 'NULL':
181 return None
182
183 # We want to make the type right when inserting the element into the dict.
184 if type == 'FLOAT':
185 return float(value)
186 elif type == 'INT':
187 # We need to make it YAML compliant as this will be an int, so if contains
188 # any special character like hex or a multiplier, then we make a string. ATS will
189 # parse it as string anyway.
190 if value.startswith('0x') or have_multipliers(value, ['K', 'M', 'G', 'T']):
191 return str(value)
192 else:
193 return int(value)
194 elif type == 'STRING':
195 return str(value)
196
197 return None
198
199
200def add_object(config, var, value, type, track_info):

Callers 3

add_objectFunction · 0.85
add_objectMethod · 0.85
add_objectMethod · 0.85

Calls 2

have_multipliersFunction · 0.85
strFunction · 0.85

Tested by

no test coverage detected