mirror of
https://github.com/RGBCube/CSAssignments
synced 2025-07-27 05:57:44 +00:00
Finish command checking & Reformat
This commit is contained in:
parent
8ad5f2d626
commit
1720c613e5
3 changed files with 10 additions and 6 deletions
|
@ -3,9 +3,10 @@ from __future__ import annotations
|
||||||
__all__ = ("Assignment",)
|
__all__ = ("Assignment",)
|
||||||
|
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from toml import loads as decode_toml
|
|
||||||
from typing import TYPE_CHECKING, TypedDict
|
from typing import TYPE_CHECKING, TypedDict
|
||||||
|
|
||||||
|
from toml import loads as decode_toml
|
||||||
|
|
||||||
from .helpers import command
|
from .helpers import command
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
__all__ = ("command", "chalk_from_int", "command_exists")
|
__all__ = ("command", "chalk_from_int", "command_exists")
|
||||||
|
|
||||||
from subprocess import DEVNULL as NULL, call as sys_command
|
from subprocess import DEVNULL as NULL, call as sys_command, getstatusoutput as sys_get_out_err
|
||||||
|
|
||||||
from chalky import Chalk, TrueColor
|
from chalky import Chalk, TrueColor
|
||||||
|
|
||||||
|
from .constants import OS
|
||||||
|
|
||||||
|
|
||||||
def command(s: str, /, *, quiet: bool) -> int:
|
def command(s: str, /, *, quiet: bool) -> int:
|
||||||
return sys_command(
|
return sys_command(
|
||||||
s.split(" "), **(dict(stdout=NULL, stderr=NULL, stdin=NULL) if quiet else {})
|
s.split(" "), shell=True, **(dict(stdout=NULL, stderr=NULL, stdin=NULL) if quiet else {})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,5 +28,5 @@ def chalk_from_int(foreground: int, background: int = None, /) -> Chalk:
|
||||||
|
|
||||||
|
|
||||||
def command_exists(s: str, /) -> bool:
|
def command_exists(s: str, /) -> bool:
|
||||||
"""TODO"""
|
prefix = "Get-Command" if OS == "windows" else "command -v"
|
||||||
return False
|
return sys_get_out_err(f"{prefix} {s}")[0] == 0
|
||||||
|
|
|
@ -3,9 +3,10 @@ from __future__ import annotations
|
||||||
__all__ = ("Language",)
|
__all__ = ("Language",)
|
||||||
|
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from toml import loads as decode_toml
|
|
||||||
from typing import TYPE_CHECKING, TypedDict
|
from typing import TYPE_CHECKING, TypedDict
|
||||||
|
|
||||||
|
from toml import loads as decode_toml
|
||||||
|
|
||||||
from .assignment import Assignment
|
from .assignment import Assignment
|
||||||
from .constants import OS
|
from .constants import OS
|
||||||
from .helpers import chalk_from_int, command_exists
|
from .helpers import chalk_from_int, command_exists
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue