diff --git a/interactive_runner/__main__.py b/interactive_runner/__main__.py index 7078e62..132414a 100644 --- a/interactive_runner/__main__.py +++ b/interactive_runner/__main__.py @@ -2,23 +2,22 @@ import interactive_runner as lib s = lib.Sources() for l in s.languages.values(): - print("lname",l.name) - print("lsname",l.styled_name) - print("ldesc",l.description) - print("lbc",l._build_command) - print("ldni",l.check_dependencies_installed()) - print("lisc",l.is_compiled) - print("lrcmd",l._run_command) + print("lname", l.name) + print("lsname", l.styled_name) + print("ldesc", l.description) + print("lbc", l._build_command) + print("ldni", l.check_dependencies_installed()) + print("lisc", l.is_compiled) + print("lrcmd", l._run_command) print() for a in l.assignments.values(): - print("alang",a.language) - print("aname",a.name) - print("agivend",a.given_date) - print("adesc",a.description) - print("adirs",a.directions) + print("alang", a.language) + print("aname", a.name) + print("agivend", a.given_date) + print("adesc", a.description) + print("adirs", a.directions) try: a.run() except Exception as e: - print("errrun",e) + print("errrun", e) print() - diff --git a/interactive_runner/assignment.py b/interactive_runner/assignment.py index e6dc8c9..bffcc88 100644 --- a/interactive_runner/assignment.py +++ b/interactive_runner/assignment.py @@ -3,9 +3,9 @@ from __future__ import annotations __all__ = ("Assignment",) from functools import cached_property -from typing import TypedDict, TYPE_CHECKING -from tomllib import loads as decode_toml from os import system as cmd +from tomllib import loads as decode_toml +from typing import TYPE_CHECKING, TypedDict if TYPE_CHECKING: from .language import Language @@ -21,6 +21,7 @@ AssignmentConfig = TypedDict( } ) + class Assignment: __config: AssignmentConfig language: Language @@ -68,18 +69,23 @@ class Assignment: if not self.language.is_compiled: return None - return cmd(self.language._build_command.format( - **{ - "out-file": self.__directory / "compiled.out", - "main-file": self.__main_file.absolute(), - } - ) + - (QUIET_SUFFIX if quiet else "") - ) + return cmd( + self.language._build_command.format( + **{ + "out-file": self.__directory / "compiled.out", + "main-file": self.__main_file.absolute(), + } + ) + + (QUIET_SUFFIX if quiet else "") + ) def run(self) -> int: if self.language.is_compiled and not (self.__directory / "compiled.out").exists(): self.compile(quiet=True) - return cmd(self.language._run_command.format((self.__directory / "compiled.out").absolute() if self.language.is_compiled else self.__main_file.absolute())) - + return cmd( + self.language._run_command.format( + ( + self.__directory / "compiled.out").absolute() if self.language.is_compiled else self.__main_file.absolute() + ) + ) diff --git a/interactive_runner/language.py b/interactive_runner/language.py index 871af17..deabfa2 100644 --- a/interactive_runner/language.py +++ b/interactive_runner/language.py @@ -2,14 +2,15 @@ from __future__ import annotations __all__ = ("Language",) -from .assignment import Assignment -from .consts import OS_KEY, CHECK_COMMAND_EXISTS -from typing import TYPE_CHECKING, TypedDict -from tomllib import loads as decode_toml -from chalky import hex from functools import cached_property from os import system as cmd -from chalky.shortcuts.sty import bold +from tomllib import loads as decode_toml +from typing import TYPE_CHECKING, TypedDict + +from chalky import hex + +from .assignment import Assignment +from .consts import CHECK_COMMAND_EXISTS, OS_KEY if TYPE_CHECKING: from pathlib import Path @@ -53,6 +54,7 @@ LanguageConfig = TypedDict( } ) + class Language: __directory: Path __config: LanguageConfig diff --git a/interactive_runner/sources.py b/interactive_runner/sources.py index 3eef258..3c0972a 100644 --- a/interactive_runner/sources.py +++ b/interactive_runner/sources.py @@ -2,14 +2,16 @@ from __future__ import annotations __all__ = ("Sources",) -from .language import Language -from .consts import ROOT from functools import cached_property from typing import TYPE_CHECKING +from .consts import ROOT +from .language import Language + if TYPE_CHECKING: from pathlib import Path + class Sources: __directory: Path languages: dict[str, Language]