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)
| 18 | |
| 19 | |
| 20 | def 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) |
no outgoing calls
no test coverage detected