13 lines
		
	
	
		
			311 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			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.")
 |