Parse boolean arguments from the command line.
(s)
| 237 | |
| 238 | |
| 239 | def bool_flag(s): |
| 240 | """ |
| 241 | Parse boolean arguments from the command line. |
| 242 | """ |
| 243 | FALSY_STRINGS = {"off", "false", "0"} |
| 244 | TRUTHY_STRINGS = {"on", "true", "1"} |
| 245 | if s.lower() in FALSY_STRINGS: |
| 246 | return False |
| 247 | elif s.lower() in TRUTHY_STRINGS: |
| 248 | return True |
| 249 | else: |
| 250 | raise argparse.ArgumentTypeError("invalid value for a boolean flag") |
| 251 | |
| 252 | |
| 253 | def print_and_log(results: dict, n: int = 0): |
nothing calls this directly
no outgoing calls
no test coverage detected