Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
kyuridenamida committed Jun 7, 2024
1 parent 5e9536c commit 5ce9011
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion atcodertools/atcoder_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def main():
if len(sys.argv) < 2 or sys.argv[1] not in ("gen", "test", "submit", "codegen", "compile", "set", "version"):
print("Usage:")
print("{} gen -- to generate workspace".format(sys.argv[0]))
print("{} codegen -- to generate code for one problem".format(sys.argv[0]))
print(
"{} codegen -- to generate code for one problem".format(sys.argv[0]))
print(
"{} compile -- to compile codes in your workspace".format(sys.argv[0]))
print("{} test -- to test codes in your workspace".format(sys.argv[0]))
Expand Down
3 changes: 2 additions & 1 deletion atcodertools/common/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def from_name(cls, name: str):
name="python",
display_name="Python",
extension="py",
submission_lang_pattern=re.compile(".*Python \\(3.*|.*Python \\(CPython 3.*"),
submission_lang_pattern=re.compile(
".*Python \\(3.*|.*Python \\(CPython 3.*"),
default_code_generator=python.main,
default_template_path=get_default_template_path('py'),
compile_command="python3 -mpy_compile {filename}.py",
Expand Down
9 changes: 6 additions & 3 deletions atcodertools/constprediction/constants_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def predict_is_format_analysis_allowed_by_rule(html: str) -> bool:
is_target_contest_of_no_llm_rule = "/contests/abc" in url_meta_tag["content"]

# If there is no virtual standings link, assume it's ongoing.
is_ongoing_contest = len([tag for tag in soup.find_all("a") if "/standings/virtual" in tag.get("href", "")]) == 0
is_ongoing_contest = len([tag for tag in soup.find_all(
"a") if "/standings/virtual" in tag.get("href", "")]) == 0

if is_target_contest_of_no_llm_rule and is_ongoing_contest:
return False
Expand Down Expand Up @@ -258,9 +259,11 @@ def predict_constants(html: str) -> ProblemConstantSet:
timeout = None

try:
is_format_analysis_allowed_by_rule = predict_is_format_analysis_allowed_by_rule(html)
is_format_analysis_allowed_by_rule = predict_is_format_analysis_allowed_by_rule(
html)
except FailingToKnowFormatAnalysisAllowedByRuleError as e:
logger.warning("Failed to know whether format analysis is allowed by the contest rules -- ", e.reason)
logger.warning(
"Failed to know whether format analysis is allowed by the contest rules -- ", e.reason)
is_format_analysis_allowed_by_rule = None

return ProblemConstantSet(
Expand Down
3 changes: 2 additions & 1 deletion atcodertools/tools/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def emit_info(text):
constants = predict_constants(content.original_html)

try:
prediction_result = predict_format(content, constants.is_format_analysis_allowed_by_rule or False)
prediction_result = predict_format(
content, constants.is_format_analysis_allowed_by_rule or False)
emit_info(
with_color("Format prediction succeeded", Fore.LIGHTGREEN_EX))
except (NoPredictionResultError, MultiplePredictionResultsError, PredictionNotAllowedError) as e:
Expand Down
3 changes: 2 additions & 1 deletion atcodertools/tools/envgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def emit_info(text):
constants = predict_constants(content.original_html)

try:
prediction_result = predict_format(content, constants.is_format_analysis_allowed_by_rule or False)
prediction_result = predict_format(
content, constants.is_format_analysis_allowed_by_rule or False)
emit_info(
with_color("Format prediction succeeded", Fore.LIGHTGREEN_EX))
except (NoPredictionResultError, MultiplePredictionResultsError, PredictionNotAllowedError) as e:
Expand Down
4 changes: 3 additions & 1 deletion tests/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from atcodertools.common.language import CPP, JAVA, RUST, PYTHON, DLANG, NIM, CSHARP, SWIFT, GO, JULIA


class TestLanguage(unittest.TestCase):
def test_compilers(self):
language_compiler_map = {
Expand All @@ -26,7 +27,7 @@ def test_previous_compilers(self):
JAVA: 'Java (OpenJDK 11.0.6)',
RUST: 'Rust (1.42.0)',
PYTHON: 'Python (3.8.2)',
DLANG: 'D (DMD 2.091.0)',
DLANG: 'D (DMD 2.091.0)',
NIM: 'Nim (1.0.6)',
CSHARP: 'C# (Mono-mcs 6.8.0.105)',
SWIFT: 'Swift (5.2.1)',
Expand All @@ -36,5 +37,6 @@ def test_previous_compilers(self):
for language, compiler in language_compiler_map.items():
self.assertRegex(compiler, language.submission_lang_pattern)


if __name__ == '__main__':
unittest.main()

0 comments on commit 5ce9011

Please sign in to comment.