MCPcopy
hub / github.com/ChristianLempa/boilerplates / convert

Method convert

cli/core/template/variable.py:370–390  ·  view source on GitHub ↗
(self, value: Any)

Source from the content-addressed store, hash-verified

368 return self.type == SECRET_TYPE
369
370 def convert(self, value: Any) -> Any:
371 if value is None:
372 return None
373
374 if isinstance(value, str) and value.strip() == "":
375 return None
376
377 converters = {
378 "bool": self._convert_bool,
379 "int": self._convert_int,
380 "float": self._convert_float,
381 "enum": self._convert_enum,
382 "url": self._convert_url,
383 "email": self._convert_email,
384 }
385
386 converter = converters.get(self.type)
387 if converter:
388 return converter(value)
389
390 return str(value)
391
392 def validate_and_convert(self, value: Any, check_required: bool = True) -> Any:
393 converted = self.convert(value)

Callers 15

validate_and_convertMethod · 0.95
_coerce_default_valueMethod · 0.95
is_enabledMethod · 0.80
_check_variable_needMethod · 0.80
_matches_any_valueMethod · 0.80
_matches_single_valueMethod · 0.80
get_all_valuesMethod · 0.80

Calls

no outgoing calls