MCPcopy Create free account
hub / github.com/ddnet/ddnet / parse_tunings

Function parse_tunings

scripts/export_settings_commands_table.py:109–127  ·  view source on GitHub ↗
(lines)

Source from the content-addressed store, hash-verified

107
108
109def parse_tunings(lines):
110 def parse_value(value):
111 value = value.strip()
112 try:
113 if value.endswith("f / (float)SERVER_TICK_SPEED"):
114 return float(value.rstrip("f / (float)SERVER_TICK_SPEED")) / 50.0
115 return float(value.strip("f"))
116 except Exception as e:
117 raise RuntimeError("Failed to parse tuning value: {value}") from e
118
119 parsed_tunings = []
120 for line in lines:
121 args = re.match(r"^MACRO_TUNING_PARAM\((.*)\)", line)
122 if args is None:
123 continue
124 parsed = parse_arguments(args[1], num=4, name="tuning")
125 parsed_tunings.append({"name": parsed[1], "description": parsed[3], "default": parse_value(parsed[2])})
126 parsed_tunings.sort(key=lambda tuning: tuning["name"])
127 return parsed_tunings
128
129
130def export_commands(parsed_commands):

Callers 1

Calls 2

parse_argumentsFunction · 0.85
parse_valueFunction · 0.85

Tested by

no test coverage detected