From 1869bc8265c0b041cb1596ff0914869d8403a182 Mon Sep 17 00:00:00 2001 From: Andrea Ciprietti Date: Fri, 13 Jan 2023 12:07:42 +0100 Subject: [PATCH] Samples are now fetched from statements directory --- p2d/parse_polygon_package.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/p2d/parse_polygon_package.py b/p2d/parse_polygon_package.py index f003267..850244d 100644 --- a/p2d/parse_polygon_package.py +++ b/p2d/parse_polygon_package.py @@ -150,14 +150,18 @@ def pol_path(*path): logging.warning('testset \'%s\' ignored: only the testset \'tests\' is exported in DOMjudge (apart from the samples).' % testset.attrib['name']) local_id = 1 # Pretests are processed only to collect samples. + input_format = testset.find('input-path-pattern').text output_format = testset.find('answer-path-pattern').text + # Fetch samples from statements directory (for custum input/output) + sample_input_format = input_format.replace('tests/', os.path.join('statements', 'english') + '/example.') + sample_output_format = output_format.replace('tests/', os.path.join('statements', 'english') + '/example.') for test in testset.iter('test'): t = { 'num': test_id, - 'in': pol_path(input_format % local_id), - 'out': pol_path(output_format % local_id), + 'in': pol_path(sample_input_format % local_id) if 'sample' in test.attrib else pol_path(input_format % local_id), + 'out': pol_path(sample_output_format % local_id) if 'sample' in test.attrib else pol_path(output_format % local_id), 'is_sample': 'sample' in test.attrib } local_id += 1