1
Fork 0
mirror of https://github.com/RGBCube/CSAssignments synced 2025-06-21 21:42:09 +00:00

Refactor most of the interactive runner

This commit is contained in:
RGBCube 2022-11-05 21:16:42 +03:00
parent d782a4d879
commit 58f5c52db5
9 changed files with 138 additions and 122 deletions

View file

@ -0,0 +1,30 @@
__all__ = ("command", "chalk_from_int", "command_exists")
from subprocess import DEVNULL as NULL, call as sys_command
from chalky import Chalk, TrueColor
def command(s: str, /, *, quiet: bool) -> int:
return sys_command(
s.split(" "), **(dict(stdout=NULL, stderr=NULL, stdin=NULL) if quiet else {})
)
def __rgb_from_int(i: int, /) -> tuple[int, int, int]:
r = (i >> 16) & 255
g = (i >> 8) & 255
b = i & 255
return r, g, b
def chalk_from_int(foreground: int, background: int = None, /) -> Chalk:
return Chalk(
foreground=TrueColor(*__rgb_from_int(foreground)),
background=TrueColor(*__rgb_from_int(background))
)
def command_exists(s: str, /) -> bool:
"""TODO"""
return False