in tools/records/convert2yaml.py [0:0]
def get_value(type, value):
def have_multipliers(value, mps):
for m in mps:
if value.endswith(m):
return True
return False
if value == 'nullptr' or value == 'NULL':
return None
# We want to make the type right when inserting the element into the dict.
if type == 'FLOAT':
return float(value)
elif type == 'INT':
# We need to make it YAML compliant as this will be an int, so if contains
# any special character like hex or a multiplier, then we make a string. ATS will
# parse it as string anyway.
if value.startswith('0x') or have_multipliers(value, ['K', 'M', 'G', 'T']):
return str(value)
else:
return int(value)
elif type == 'STRING':
return str(value)
return None