From 472c2428e9c5827de79384c11418220389d57532 Mon Sep 17 00:00:00 2001 From: Niyaz Nigmatullin Date: Fri, 14 Aug 2020 10:41:06 +0300 Subject: [PATCH] [usaco] Fix no scoring in statement bug --- polygon_uploader/__init__.py | 2 +- polygon_uploader/usaco/usaco.py | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/polygon_uploader/__init__.py b/polygon_uploader/__init__.py index 372c429..ac5ed01 100644 --- a/polygon_uploader/__init__.py +++ b/polygon_uploader/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.2.4" +__version__ = "0.2.5" diff --git a/polygon_uploader/usaco/usaco.py b/polygon_uploader/usaco/usaco.py index bf7000c..5554327 100644 --- a/polygon_uploader/usaco/usaco.py +++ b/polygon_uploader/usaco/usaco.py @@ -81,8 +81,14 @@ def extract_part(class_name): return part scoring = extract_part('prob-section') + if scoring is not None: + scoring = latexify_post(scoring.text, lang) input = extract_part('prob-in-spec') + if input is not None: + input = latexify_post(input.text, lang) output = extract_part('prob-out-spec') + if output is not None: + output = latexify_post(output.text, lang) for x in statement.find_all_next('h4'): x.extract() @@ -93,9 +99,10 @@ def extract_part(class_name): e.extract() note = e break - - for x in note.find_all_next('pre'): - x.extract() + if note is not None: + for x in note.find_all_next('pre'): + x.extract() + note = latexify_post(note.text, lang) # print("Legend: " + statement.text) # print("Input: " + input.text) @@ -106,10 +113,10 @@ def extract_part(class_name): polygon_statement = Statement(encoding="UTF-8", name=name, legend=latexify_post(statement.text, lang), - input=latexify_post(input.text, lang), - output=latexify_post(output.text, lang) + - "\n\\Scoring\n" + latexify_post(scoring.text, lang), - notes=latexify_post(note.text, lang)) + input=input, + output=("" if output is None else output) + + ("" if scoring is None else ("\n\\Scoring\n" + scoring)), + notes=note) prob.save_statement(lang=lang_polygon, problem_statement=polygon_statement) def download_tests(dir, tests_dir):