def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--output', required=True)
    parser.add_argument('--domjudge_metadata')
    parser.add_argument('--icpc_metadata')
    parser.add_argument('--statements', action='append', default=[])
    parser.add_argument('--dataset', required=True)
    options = parser.parse_args()

    # DOMJudge problem format:
    # https://www.domjudge.org/docs/manual/problem-format.html
    with tempfile.TemporaryDirectory() as tmp_dir:
        if options.domjudge_metadata:
            shutil.copy(options.domjudge_metadata,
                        os.path.join(tmp_dir, 'domjudge-problem.ini'))

        if options.icpc_metadata:
            shutil.copy(options.icpc_metadata,
                        os.path.join(tmp_dir, 'problem.yaml'))

        for statement in options.statements:
            assert statement.endswith(('.html', '.pdf'))
            statement_ext = statement.split('.')[-1]
            shutil.copy(statement,
                        os.path.join(tmp_dir, 'problem.%s' % statement_ext))

        dataset_dir = os.path.join(tmp_dir, 'data', 'secret')
        os.makedirs(dataset_dir)
        datasets.extract(options.dataset, dataset_dir)

        # TODO: Do not reuse datasets.create to create a problem ZIP archive.
        datasets.create(tmp_dir, options.output)
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--output', required=True)
    parser.add_argument('--file', dest='files', action='append', default=[])
    parser.add_argument('--dataset', dest='datasets', action='append', default=[])
    options = parser.parse_args()

    with tempfile.TemporaryDirectory() as dataset_dir:
        for path in options.files:
            shutil.copy(path, os.path.join(dataset_dir, os.path.basename(path)))
        for path in options.datasets:
            datasets.extract(path, dataset_dir)
        datasets.create(dataset_dir, options.output)
Beispiel #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--output', required=True)
    parser.add_argument('--executable', required=True)
    parser.add_argument('--command', required=True)
    options = parser.parse_args()

    with tempfile.TemporaryDirectory() as dataset_dir:
        env = exec_util.make_env({
            'EXEC': os.path.abspath(options.executable),
            'OUTPUT_DIR': dataset_dir,
        })
        subprocess.check_call(exec_util.bash_args(options.command), env=env)
        datasets.create(dataset_dir, options.output)
Beispiel #4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--output', required=True)
    parser.add_argument('--executable', required=True)
    parser.add_argument('--dataset', required=True)
    parser.add_argument('--command', required=True)
    options = parser.parse_args()

    with datasets.expand(options.dataset) as dataset_dir:
        for case in datasets.cases(dataset_dir):
            env = exec_util.make_env({
                'EXEC': os.path.abspath(options.executable),
                'INPUT_DIR': dataset_dir,
                'OUTPUT_DIR': dataset_dir,
                'TESTCASE': case,
            })
            subprocess.check_call(
                exec_util.bash_args(options.command),
                env=env)
        datasets.create(dataset_dir, options.output)
Beispiel #5
0
 def test_empty_dataset(self):
     with tempfile.NamedTemporaryFile() as zip_file:
         with tempfile.TemporaryDirectory() as empty_dir:
             datasets.create(empty_dir, zip_file.name)
         with datasets.expand(zip_file.name) as dataset_dir:
             self.assertEqual([], os.listdir(dataset_dir))