Files
mongo/buildscripts/util/buildozer_utils.py
Juan Gu b93d608d2a SERVER-96927 Use extend-select instead of select to include isort (#29038)
GitOrigin-RevId: 2a83dfd190d8a6d95202702234bcef79b91d0ab6
2024-11-26 20:14:08 +00:00

31 lines
816 B
Python

import subprocess
from typing import List
def _bd_command(cmd: str, labels: List[str]):
p = subprocess.run(
f"buildozer '{cmd}' " + " ".join(labels),
capture_output=True,
shell=True,
text=True,
check=True,
)
return p
def bd_add(labels: List[str], attr: str, values: List[str]) -> None:
_bd_command(f'add {attr} {" ".join(values)}', labels)
def bd_remove(labels: List[str], attr: str, values: List[str]) -> None:
_bd_command(f'remove {attr} {" ".join(values)}', labels)
def bd_new(package: str, rule_kind: str, rule_name: str) -> None:
_bd_command(f"new {rule_kind} {rule_name}", [package])
def bd_comment(labels: List[str], comment: str, attr: str = "", value: str = "") -> None:
_bd_command(f"comment {attr} {value} {comment}", labels)