38 lines
700 B
Python
38 lines
700 B
Python
|
|
import argparse
|
||
|
|
import json
|
||
|
|
import sys
|
||
|
|
|
||
|
|
g_args = None
|
||
|
|
|
||
|
|
|
||
|
|
def read_json():
|
||
|
|
global g_args
|
||
|
|
json_path = g_args.config
|
||
|
|
if json_path is None:
|
||
|
|
print("specify json path")
|
||
|
|
sys.exit()
|
||
|
|
with open(json_path, "r", encoding="utf-8") as json_f:
|
||
|
|
js = json.load(json_f)
|
||
|
|
return js
|
||
|
|
|
||
|
|
|
||
|
|
def get_config():
|
||
|
|
global g_args
|
||
|
|
return g_args
|
||
|
|
|
||
|
|
|
||
|
|
def init_config():
|
||
|
|
global g_args
|
||
|
|
if g_args is not None:
|
||
|
|
return g_args
|
||
|
|
parser = argparse.ArgumentParser(description="Help")
|
||
|
|
parser.add_argument("-config", type=str)
|
||
|
|
_args = parser.parse_args()
|
||
|
|
g_args = _args
|
||
|
|
return _args
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
args = init_config()
|
||
|
|
print(args.config)
|