Parse boolean using argument parser.
(v)
| 48 | |
| 49 | |
| 50 | def str2bool(v): |
| 51 | """ |
| 52 | Parse boolean using argument parser. |
| 53 | """ |
| 54 | if isinstance(v, bool): |
| 55 | return v |
| 56 | if v.lower() in ('yes', 'true', 't', 'y', '1'): |
| 57 | return True |
| 58 | elif v.lower() in ('no', 'false', 'f', 'n', '0'): |
| 59 | return False |
| 60 | else: |
| 61 | raise argparse.ArgumentTypeError('Boolean value expected.') |
| 62 | |
| 63 | def str2float(x): |
| 64 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…