MCPcopy Create free account
hub / github.com/StackStorm/st2 / _construct_template

Method _construct_template

st2client/st2client/utils/interactive.py:241–259  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

239 raise validation.ValidationError(len(input), "Out of bounds")
240
241 def _construct_template(self):
242 self.template = "{0}: "
243
244 enum = self.spec.get("enum")
245 for index, value in enumerate(enum):
246 self.template += "\n {} - {}".format(index, value)
247
248 num_options = len(enum)
249 more = ""
250 if num_options > 3:
251 num_options = 3
252 more = "..."
253 options = [str(i) for i in range(0, num_options)]
254 self.template += "\nChoose from {}{}".format(", ".join(options), more)
255
256 if "default" in self.spec:
257 self.template += " [{}]: ".format(enum.index(self.spec.get("default")))
258 else:
259 self.template += ": "
260
261 def _transform_response(self, response):
262 return self.spec.get("enum")[int(response)]

Callers

nothing calls this directly

Calls 3

indexMethod · 0.80
getMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected