mirror of
https://github.com/aljazceru/InvSR.git
synced 2025-12-17 06:14:22 +01:00
first commit
This commit is contained in:
22
utils/util_opts.py
Normal file
22
utils/util_opts.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding:utf-8 -*-
|
||||
# Power by Zongsheng Yue 2021-11-24 15:07:43
|
||||
|
||||
import argparse
|
||||
|
||||
def update_args(args_json, args_parser):
|
||||
for arg in vars(args_parser):
|
||||
args_json[arg] = getattr(args_parser, arg)
|
||||
|
||||
def str2bool(v):
|
||||
"""
|
||||
https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
|
||||
"""
|
||||
if isinstance(v, bool):
|
||||
return v
|
||||
if 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")
|
||||
Reference in New Issue
Block a user