1
Fork 0
mirror of https://github.com/RGBCube/CSAssignments synced 2025-07-25 13:07:46 +00:00
This commit is contained in:
RGBCube 2022-11-05 20:20:01 +03:00
parent 9ed2410cc0
commit d782a4d879
4 changed files with 43 additions and 34 deletions

View file

@ -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()

View file

@ -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()
)
)

View file

@ -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

View file

@ -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]