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

Function transform_to_bool

st2api/st2api/controllers/controller_transforms.py:20–32  ·  view source on GitHub ↗

Transforms a certain set of values to True or False. True can be represented by '1', 'True' and 'true.' False can be represented by '1', 'False' and 'false.' Any other representation will be rejected.

(value)

Source from the content-addressed store, hash-verified

18
19
20def transform_to_bool(value):
21 """
22 Transforms a certain set of values to True or False.
23 True can be represented by '1', 'True' and 'true.'
24 False can be represented by '1', 'False' and 'false.'
25
26 Any other representation will be rejected.
27 """
28 if value in ["1", "true", "True", True]:
29 return True
30 elif value in ["0", "false", "False", False]:
31 return False
32 raise ValueError('Invalid bool representation "%s" provided.' % value)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected