def Pack(self, ui, testset): testcases = testset.ListTestCases() try: files.RemoveTree(testset.mjudge_pack_dir) files.MakeDir(testset.mjudge_pack_dir) except Exception: ui.errors.Exception(testset) yield False for (i, testcase) in enumerate(testcases): basename = os.path.splitext(testcase.infile)[0] difffile = basename + consts.DIFF_EXT packed_infile = str(i + 1) + consts.IN_EXT packed_difffile = str(i + 1) + consts.DIFF_EXT try: ui.console.PrintAction( 'PACK', testset, '%s -> %s' % (os.path.basename(testcase.infile), packed_infile), progress=True) files.CopyFile( os.path.join(testset.out_dir, testcase.infile), os.path.join(testset.mjudge_pack_dir, packed_infile)) ui.console.PrintAction( 'PACK', testset, '%s -> %s' % (os.path.basename(difffile), packed_difffile), progress=True) files.CopyFile( os.path.join(testset.out_dir, difffile), os.path.join(testset.mjudge_pack_dir, packed_difffile)) except Exception: ui.errors.Exception(testset) yield False yield True
def Pack(self, ui, testset): testcases = testset.ListTestCases() try: files.RemoveTree(testset.pack_dir) files.MakeDir(testset.pack_dir) files.MakeDir(os.path.join(testset.pack_dir, 'input')) files.MakeDir(os.path.join(testset.pack_dir, 'output')) except Exception: ui.errors.Exception(testset) yield False template_packed_infile = 'input{:d}.txt' template_packed_difffile = 'output{:d}.txt' for i, testcase in enumerate(testcases): basename = os.path.splitext(testcase.infile)[0] difffile = basename + consts.DIFF_EXT packed_infile = template_packed_infile.format(i) packed_difffile = template_packed_difffile.format(i) try: ui.console.PrintAction( 'PACK', testset, '%s -> input/%s' % (os.path.basename(testcase.infile), packed_infile), progress=True) files.CopyFile( os.path.join(testset.out_dir, testcase.infile), os.path.join(testset.pack_dir, 'input', packed_infile)) ui.console.PrintAction( 'PACK', testset, '%s -> output/%s' % (os.path.basename(difffile), packed_difffile), progress=True) files.CopyFile( os.path.join(testset.out_dir, difffile), os.path.join(testset.pack_dir, 'output', packed_difffile)) except Exception: ui.errors.Exception(testset) yield False # hacker_rank.zip try: shutil.make_archive(os.path.join(testset.pack_dir, 'hacker_rank'), 'zip', os.path.join(testset.pack_dir)) ui.console.PrintAction('PACK', testset, 'zipped to hacker_rank.zip', progress=True) except Exception: ui.errors.Exception(testset) yield False yield True
def Pack(self, ui, testset): testcases = testset.ListTestCases() try: files.RemoveTree(testset.aoj_pack_dir) files.MakeDir(testset.aoj_pack_dir) except Exception: ui.errors.Exception(testset) yield False for (i, testcase) in enumerate(testcases): basename = os.path.splitext(testcase.infile)[0] difffile = basename + consts.DIFF_EXT packed_infile = 'in' + str(i + 1) + '.txt' packed_difffile = 'out' + str(i + 1) + '.txt' try: ui.console.PrintAction( 'PACK', testset, '%s -> %s' % (os.path.basename(testcase.infile), packed_infile), progress=True) files.CopyFile(os.path.join(testset.out_dir, testcase.infile), os.path.join(testset.aoj_pack_dir, packed_infile)) ui.console.PrintAction( 'PACK', testset, '%s -> %s' % (os.path.basename(difffile), packed_difffile), progress=True) files.CopyFile(os.path.join(testset.out_dir, difffile), os.path.join(testset.aoj_pack_dir, packed_difffile)) except Exception: ui.errors.Exception(testset) yield False # case.txt files.WriteFile(str(len(testcases)), os.path.join(testset.aoj_pack_dir, 'case.txt')) # build.sh # TODO(mizuno): reactive checker = testset.judges[0] if (len(testset.judges) == 1 and not isinstance(checker, basic_codes.InternalDiffCode)): ui.console.PrintAction( 'PACK', testset, 'checker files', progress=True) files.CopyFile(os.path.join(testset.src_dir, checker.src_name), os.path.join(testset.aoj_pack_dir, 'checker.cpp')) for f in checker.dependency: files.CopyFile(os.path.join(testset.project.library_dir, f), os.path.join(testset.aoj_pack_dir, f)) files.WriteFile( '#!/bin/bash\ng++ -o checker -std=c++11 checker.cpp', os.path.join(testset.aoj_pack_dir, 'build.sh')) elif len(testset.judges) > 1: ui.errors.Error( testset, "Multiple output checker is not supported!") yield False # AOJCONF aoj_conf = '''\ # -*- coding: utf-8; mode: python -*- # Problem ID PROBLEM_ID = '*' # Judge type # 'diff-validator' for a problem without special judge # 'float-validator' for a problem with floating point validator # 'special-validator' for a problem with special validator # 'reactive' for a reactive problem {0} # Language of problem description # 'ja', 'en' or 'ja-en' DOCUMENT_TYPE = '*' # Title of the problem TITLE = '{1}' # Time limit (integer, in seconds) TIME_LIMIT = 1 # Memory limit (integer, in KB) MEMORY_LIMIT = 32768 # Date when the problem description will be able to be seen PUBLICATION_DATE = datetime.datetime(*, *, *, *, *) ''' if not isinstance(checker, basic_codes.InternalDiffCode): files.WriteFile( aoj_conf.format( 'JUDGE_TYPE = \'special-validator\'', testset.problem.title), os.path.join(testset.aoj_pack_dir, 'AOJCONF')) else: files.WriteFile( aoj_conf.format( 'JUDGE_TYPE = \'diff-validator\'', testset.problem.title), os.path.join(testset.aoj_pack_dir, 'AOJCONF')) yield True
def Pack(self, ui, testset): testcases = testset.ListTestCases() try: files.RemoveTree(testset.atcoder_pack_dir) files.MakeDir(testset.atcoder_pack_dir) files.MakeDir(os.path.join(testset.atcoder_pack_dir, 'in')) files.MakeDir(os.path.join(testset.atcoder_pack_dir, 'out')) files.MakeDir(os.path.join(testset.atcoder_pack_dir, 'etc')) except Exception: ui.errors.Exception(testset) yield False for (i, testcase) in enumerate(testcases): basename = os.path.splitext(testcase.infile)[0] difffile = basename + consts.DIFF_EXT packed_infile = os.path.join('in', os.path.basename(basename)) packed_difffile = os.path.join('out', os.path.basename(basename)) try: ui.console.PrintAction( 'PACK', testset, '%s -> %s' % (os.path.basename(testcase.infile), packed_infile), progress=True) files.CopyFile(os.path.join(testset.out_dir, testcase.infile), os.path.join(testset.atcoder_pack_dir, packed_infile)) ui.console.PrintAction( 'PACK', testset, '%s -> %s' % (os.path.basename(difffile), packed_difffile), progress=True) files.CopyFile(os.path.join(testset.out_dir, difffile), os.path.join(testset.atcoder_pack_dir, packed_difffile)) except Exception: ui.errors.Exception(testset) yield False # checker checker = testset.judges[0] if (len(testset.judges) == 1 and not isinstance(checker, basic_codes.InternalDiffCode)): ui.console.PrintAction( 'PACK', testset, 'output checker files', progress=True) files.CopyFile( os.path.join(testset.src_dir, checker.src_name), os.path.join(testset.atcoder_pack_dir, 'etc', 'output_checker.cpp')) for f in checker.dependency: files.CopyFile(os.path.join(testset.project.library_dir, f), os.path.join(testset.atcoder_pack_dir, 'etc', f)) elif len(testset.judges) > 1: ui.errors.Error( testset, "Multiple output checker is not supported!") yield False # reactive if len(testset.reactives) == 1: reactive = testset.reactives[0] ui.console.PrintAction( 'PACK', testset, 'reactive checker files', progress=True) files.CopyFile( os.path.join(testset.src_dir, reactive.src_name), os.path.join(testset.atcoder_pack_dir, 'etc', 'reactive.cpp')) for f in reactive.dependency: files.CopyFile(os.path.join(testset.project.library_dir, f), os.path.join(testset.atcoder_pack_dir, 'etc', f)) # outは使わない files.RemoveTree(os.path.join(testset.atcoder_pack_dir, 'out')) elif len(testset.judges) > 1: ui.errors.Error( testset, "Multiple reactive checker is not supported!") yield False # score.txt subtasks = testset.subtask_testcases if len(subtasks) > 0: score = '\n'.join([ s.name + '(' + str(s.score) + ')' + ': ' + ','.join(s.input_patterns) for s in subtasks]) else: score = 'All(100): *' files.WriteFile( score, os.path.join(testset.atcoder_pack_dir, 'etc', 'score.txt')) yield True