autodl-projects/xautodl/config_utils/args_utils.py

13 lines
311 B
Python
Raw Normal View History

2021-03-30 11:17:05 +02:00
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.")