MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / get_parameter_infos

Function get_parameter_infos

helpers/parameter_generator.py:12–76  ·  view source on GitHub ↗

Parse config header file. Parameters ---------- config_hpp : string Path to the config header file. Returns ------- infos : tuple Tuple with names and content of sections.

(config_hpp)

Source from the content-addressed store, hash-verified

10
11
12def get_parameter_infos(config_hpp):
13 """Parse config header file.
14
15 Parameters
16 ----------
17 config_hpp : string
18 Path to the config header file.
19
20 Returns
21 -------
22 infos : tuple
23 Tuple with names and content of sections.
24 """
25 is_inparameter = False
26 cur_key = None
27 cur_info = {}
28 keys = []
29 member_infos = []
30 with open(config_hpp) as config_hpp_file:
31 for line in config_hpp_file:
32 if "#pragma region Parameters" in line:
33 is_inparameter = True
34 elif "#pragma region" in line and "Parameters" in line:
35 cur_key = line.split("region")[1].strip()
36 keys.append(cur_key)
37 member_infos.append([])
38 elif '#pragma endregion' in line:
39 if cur_key is not None:
40 cur_key = None
41 elif is_inparameter:
42 is_inparameter = False
43 elif cur_key is not None:
44 line = line.strip()
45 if line.startswith("//"):
46 key, _, val = line[2:].partition("=")
47 key = key.strip()
48 val = val.strip()
49 if key not in cur_info:
50 if key == "descl2" and "desc" not in cur_info:
51 cur_info["desc"] = []
52 elif key != "descl2":
53 cur_info[key] = []
54 if key == "desc":
55 cur_info["desc"].append(("l1", val))
56 elif key == "descl2":
57 cur_info["desc"].append(("l2", val))
58 else:
59 cur_info[key].append(val)
60 elif line:
61 has_eqsgn = False
62 tokens = line.split("=")
63 if len(tokens) == 2:
64 if "default" not in cur_info:
65 cur_info["default"] = [tokens[1][:-1].strip()]
66 has_eqsgn = True
67 tokens = line.split()
68 cur_info["inner_type"] = [tokens[0].strip()]
69 if "name" not in cur_info:

Callers 1

gen_parameter_codeFunction · 0.85

Calls 2

appendMethod · 0.80
partitionMethod · 0.80

Tested by

no test coverage detected