1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-09 13:59:02 +08:00
AzurLaneAutoScript/deploy/set.py

37 lines
850 B
Python
Raw Normal View History

2024-06-05 23:20:28 +08:00
import sys
import typing as t
2025-01-14 02:54:10 +08:00
from deploy.utils import poor_yaml_read, poor_yaml_write, DEPLOY_TEMPLATE
2024-06-05 23:20:28 +08:00
"""
Set config/deploy.yaml with commands like
python -m deploy.set GitExecutable=/usr/bin/git PythonExecutable=/usr/bin/python3.8
"""
def get_args() -> t.Dict[str, str]:
args = {}
for arg in sys.argv[1:]:
if '=' not in arg:
continue
k, v = arg.split('=')
k, v = k.strip(), v.strip()
args[k] = v
return args
2025-01-14 02:54:10 +08:00
def config_set(output='./config/deploy.yaml'):
2024-06-05 23:20:28 +08:00
data = poor_yaml_read(DEPLOY_TEMPLATE)
data.update(poor_yaml_read(output))
2025-01-14 02:54:10 +08:00
for k, v in get_args().items():
2024-06-05 23:20:28 +08:00
if k in data:
2025-01-14 02:54:10 +08:00
print(f'{k} set')
2024-06-05 23:20:28 +08:00
data[k] = v
else:
2025-01-14 02:54:10 +08:00
print(f'{k} not exist')
2024-06-05 23:20:28 +08:00
poor_yaml_write(data, file=output)
if __name__ == '__main__':
2025-01-14 02:54:10 +08:00
config_set()