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

Function print_class

tools/cripts/genconfig.py:74–104  ·  view source on GitHub ↗
(tree, cur="", indent=0)

Source from the content-addressed store, hash-verified

72
73
74def print_class(tree, cur="", indent=0):
75 firstInstance = True
76 for k in tree.keys():
77 if isinstance(tree[k], dict):
78 if indent > 0:
79 indentp("private:", indent - 1)
80 if cur == "proxy":
81 indentp("friend class cripts::Context; // Needed to set the state", indent)
82 print()
83 indentp("class {}".format(k.title()), indent)
84 indentp("{", indent)
85 print_class(tree[k], k, indent + 1)
86 else:
87 if firstInstance:
88 indentp("public:", indent - 1)
89 firstInstance = False
90 if tree[k][1] == "TS_RECORDDATATYPE_INT":
91 indentp("cripts::IntConfig {}{{\"{}\"}};".format(k, tree[k][2]), indent)
92 elif tree[k][1] == "TS_RECORDDATATYPE_FLOAT":
93 indentp("cripts::FloatConfig {}{{\"{}\"}};".format(k, tree[k][2]), indent)
94 elif tree[k][1] == "TS_RECORDDATATYPE_STRING":
95 indentp("cripts::StringConfig {}{{\"{}\"}};".format(k, tree[k][2]), indent)
96 else:
97 print("The source file has a bad configuration data type: {}".format(tree[k][1]))
98 if cur:
99 indentp("}}; // End class {}".format(cur.title()), indent - 1)
100 print()
101 if cur != "proxy":
102 indentp("public:", indent - 2)
103 indentp("{} {};".format(cur.title(), cur), indent - 1)
104 print()
105
106
107lines = list(fileinput.input())

Callers 1

genconfig.pyFile · 0.85

Calls 3

indentpFunction · 0.85
keysMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected