/
githubmirror
/
salt
Обзор
Документация
Войти
/
githubmirror
/
salt
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
.github/workflows/scripts/update_winrepo.py
42 строки
1003 B
Shane Lee
Fix update winrepo script on 3006.x
21 фев 2024, 22:18
Не верифицирован
21 фев 2024, 22:18
c6991e2
Код
Авторство
О чём код?
import argparse import os print("Update winrepo script") # Where are we print(f"Current working directory: {os.getcwd()}") arg_parser = argparse.ArgumentParser() arg_parser.add_argument("-f", "--file", help="the winrepo file to edit") arg_parser.add_argument("-v", "--version", help="The version to add") args = arg_parser.parse_args() file = args.file version = args.version print("Args:") print(f"- file: {file}") print(f"- version: {version}") if version.startswith("v"): version = version[1:] with open(file) as f: print(f"Opening file: {file}") current_contents = f.readlines() new_contents = [] added = False for line in current_contents: new_contents.append(line) if "load_yaml as versions_relenv" in line and not added: print(f"Adding version: {version}") new_contents.append(f"- {version}\n") added = True with open(file, "w") as f: print(f"Writing file: {file}") f.writelines(new_contents) print("Update winrepo script complete")