mirror of
https://github.com/RGBCube/CSAssignments
synced 2025-07-24 20:47:43 +00:00
Reformat
This commit is contained in:
parent
9ed2410cc0
commit
d782a4d879
4 changed files with 43 additions and 34 deletions
|
@ -2,23 +2,22 @@ import interactive_runner as lib
|
||||||
|
|
||||||
s = lib.Sources()
|
s = lib.Sources()
|
||||||
for l in s.languages.values():
|
for l in s.languages.values():
|
||||||
print("lname",l.name)
|
print("lname", l.name)
|
||||||
print("lsname",l.styled_name)
|
print("lsname", l.styled_name)
|
||||||
print("ldesc",l.description)
|
print("ldesc", l.description)
|
||||||
print("lbc",l._build_command)
|
print("lbc", l._build_command)
|
||||||
print("ldni",l.check_dependencies_installed())
|
print("ldni", l.check_dependencies_installed())
|
||||||
print("lisc",l.is_compiled)
|
print("lisc", l.is_compiled)
|
||||||
print("lrcmd",l._run_command)
|
print("lrcmd", l._run_command)
|
||||||
print()
|
print()
|
||||||
for a in l.assignments.values():
|
for a in l.assignments.values():
|
||||||
print("alang",a.language)
|
print("alang", a.language)
|
||||||
print("aname",a.name)
|
print("aname", a.name)
|
||||||
print("agivend",a.given_date)
|
print("agivend", a.given_date)
|
||||||
print("adesc",a.description)
|
print("adesc", a.description)
|
||||||
print("adirs",a.directions)
|
print("adirs", a.directions)
|
||||||
try:
|
try:
|
||||||
a.run()
|
a.run()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("errrun",e)
|
print("errrun", e)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ from __future__ import annotations
|
||||||
__all__ = ("Assignment",)
|
__all__ = ("Assignment",)
|
||||||
|
|
||||||
from functools import cached_property
|
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 os import system as cmd
|
||||||
|
from tomllib import loads as decode_toml
|
||||||
|
from typing import TYPE_CHECKING, TypedDict
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .language import Language
|
from .language import Language
|
||||||
|
@ -21,6 +21,7 @@ AssignmentConfig = TypedDict(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Assignment:
|
class Assignment:
|
||||||
__config: AssignmentConfig
|
__config: AssignmentConfig
|
||||||
language: Language
|
language: Language
|
||||||
|
@ -68,18 +69,23 @@ class Assignment:
|
||||||
if not self.language.is_compiled:
|
if not self.language.is_compiled:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return cmd(self.language._build_command.format(
|
return cmd(
|
||||||
**{
|
self.language._build_command.format(
|
||||||
"out-file": self.__directory / "compiled.out",
|
**{
|
||||||
"main-file": self.__main_file.absolute(),
|
"out-file": self.__directory / "compiled.out",
|
||||||
}
|
"main-file": self.__main_file.absolute(),
|
||||||
) +
|
}
|
||||||
(QUIET_SUFFIX if quiet else "")
|
) +
|
||||||
)
|
(QUIET_SUFFIX if quiet else "")
|
||||||
|
)
|
||||||
|
|
||||||
def run(self) -> int:
|
def run(self) -> int:
|
||||||
if self.language.is_compiled and not (self.__directory / "compiled.out").exists():
|
if self.language.is_compiled and not (self.__directory / "compiled.out").exists():
|
||||||
self.compile(quiet=True)
|
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()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
|
@ -2,14 +2,15 @@ from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ("Language",)
|
__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 functools import cached_property
|
||||||
from os import system as cmd
|
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:
|
if TYPE_CHECKING:
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -53,6 +54,7 @@ LanguageConfig = TypedDict(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Language:
|
class Language:
|
||||||
__directory: Path
|
__directory: Path
|
||||||
__config: LanguageConfig
|
__config: LanguageConfig
|
||||||
|
|
|
@ -2,14 +2,16 @@ from __future__ import annotations
|
||||||
|
|
||||||
__all__ = ("Sources",)
|
__all__ = ("Sources",)
|
||||||
|
|
||||||
from .language import Language
|
|
||||||
from .consts import ROOT
|
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from .consts import ROOT
|
||||||
|
from .language import Language
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
class Sources:
|
class Sources:
|
||||||
__directory: Path
|
__directory: Path
|
||||||
languages: dict[str, Language]
|
languages: dict[str, Language]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue