xautodl/lib/config_utils/args_utils.py
2021-03-30 09:17:05 +00:00

13 lines
311 B
Python

import argparse
def arg_str2bool(v):
if isinstance(v, bool):
return v
elif v.lower() in ("yes", "true", "t", "y", "1"):
return True
elif v.lower() in ("no", "false", "f", "n", "0"):
return False
else:
raise argparse.ArgumentTypeError("Boolean value expected.")