diff --git a/bin/export.py b/bin/export.py index 2562be5fe..7a470eee3 100644 --- a/bin/export.py +++ b/bin/export.py @@ -86,7 +86,7 @@ def build_samples_zip(problems, statement_language): # Add samples for non-interactive problems. if not problem.interactive: - samples = problem.testcases(only_sample=True) + samples = problem.testcases(only_samples=True) for i in range(0, len(samples)): sample = samples[i] basename = outputdir / str(i + 1) diff --git a/bin/problem.py b/bin/problem.py index e4eab5f61..01951f88c 100644 --- a/bin/problem.py +++ b/bin/problem.py @@ -180,25 +180,19 @@ def get_testdata_yaml(p, path): def testcases( p, *, - needans=True, - needinteraction=False, - only_sample=False, - statement_samples=False, mode=None, - copy=False, + needans=True, + only_samples=False, ): - def maybe_copy(x): - return x.copy() if copy and isinstance(x, (list, dict)) else x + only_samples = config.args.samples or only_samples - samplesonly = config.args.samples or only_sample - - key = (needans, samplesonly) + key = (needans, only_samples) if key in p._testcases is not None: - return maybe_copy(p._testcases[key]) + return p._testcases[key] in_paths = None if config.args.testcases: - if samplesonly: + if only_samples: assert False # Deduplicate testcases with both .in and .ans. in_paths = [] @@ -223,19 +217,12 @@ def maybe_copy(x): in_paths += glob(p.path, f'data/{prefix}/**/*.in') else: in_paths = list(glob(p.path, 'data/sample/**/*.in')) - if statement_samples: - in_paths += list(glob(p.path, 'data/sample/**/*.in.statement')) - if not samplesonly: + if not only_samples: in_paths += list(glob(p.path, 'data/secret/**/*.in')) testcases = [] for f in in_paths: t = testcase.Testcase(p, f) - # Require both in and ans files - if needinteraction and not t.in_path.with_suffix('.interaction').is_file(): - assert only_sample - warn(f'Found input file {f} without a .interaction file. Skipping.') - continue if needans and not t.ans_path.is_file(): if t.root != 'invalid_inputs': warn(f'Found input file {f} without a .ans file. Skipping.') @@ -244,14 +231,11 @@ def maybe_copy(x): testcases.sort(key=lambda t: t.name) if len(testcases) == 0: - if needinteraction: - warn(f'Didn\'t find any testcases with interaction for {p.name}') - else: - warn(f'Didn\'t find any testcases{" with answer" if needans else ""} for {p.name}') + warn(f'Didn\'t find any testcases{" with answer" if needans else ""} for {p.name}') testcases = False p._testcases[key] = testcases - return maybe_copy(testcases) + return testcases # Returns a list of: # - (Path, Path) = (.in, .ans) pairs