You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
576 B
Python

import subprocess
from typing import Literal, Union
def call(args, check=True, stdin=None) -> subprocess.CompletedProcess:
proc = subprocess.run(args, capture_output=True, check=check, text=True, stdin=stdin)
return proc
def update_bool_value(old_value: bool, new_value: Union[bool, Literal["toggle"]]) -> bool:
if new_value == "toggle":
return not old_value
if type(new_value) != bool:
raise Exception(f"Invalid type of new_value: Expected bool or literal \"toggle\", got type={type(new_value)!r}, value={new_value!r}")
return new_value