view 2.00/testcases.py @ 16:f2279b7602d3

Initial 2.00 commit
author Oleg Oshmyan <chortos@inbox.lv>
date Mon, 07 Jun 2010 23:36:52 +0000
parents
children ec6f1a132109
line wrap: on
line source

#!/usr/bin/python
# Copyright (c) 2010 Chortos-2 <chortos@inbox.lv>

try:
	import files as _files, problem as _problem
except ImportError as e:
	import __main__
	__main__.import_error(e)

class TestCase(object):
	__slots__ = 'problem', 'infile', 'outfile'
	
	def __init__(case, prob, infile, outfile):
		case.problem = prob
		case.infile = infile
		case.outfile = outfile
	
	def __call__(case):
		os.copy()

def load_problem(prob):
	if prob.config.usegroups:
		pass
	else:
		for i in prob.config.tests:
			s = str(i).zfill(prob.config.padwithzeroestolength)
			prob.cache.padoutputtolength = max(prob.cache.padoutputtolength, len(s))
			infile = _files.TestCaseFile(prob, prob.config.testcaseinname.replace('$', s))
			if infile:
				if prob.config.kind != _problem.BATCH:
					yield TestCase(prob, infile, None)
				else:
					outfile = _files.TestCaseFile(prob, prob.config.testcaseoutname.replace('$', s))
					if outfile:
						yield TestCase(prob, infile, outfile)