in doc/ext/traffic-server.cmake.in.py [0:0]
def __generate_code(self, cv_name, cv_default, cv_type):
def add_object(config, var, value, type=None):
def get_value(type, value):
def have_multipliers(value, mps):
for m in mps:
if value.endswith(m):
return True
return False
if value is None or 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
obj = {}
key = ''
index = var.find('.')
if index < 0: # last part
config[var] = get_value(type, value)
else:
key = var[:index]
if key not in config:
config[key] = {}
add_object(config[key], var[index + 1:], value, type=type)
name = cv_name
if name.startswith("proxy.config."):
name = name[len("proxy.config."):]
elif name.startswith("local.config."):
name = name[len("local.config."):]
ts = {}
config = {}
# Build the object
add_object(config, name, cv_default, cv_type)
ts['records'] = config
code = get_code(ts)
literal = nodes.literal_block(code, code)
literal['linenos'] = True
literal['force'] = True
literal['language'] = 'yaml'
literal['caption'] = 'records.yaml'
return literal