changeset 102:796eb7667fb0

Added the --list-problems command-line option
author Oleg Oshmyan <chortos@inbox.lv>
date Fri, 01 Apr 2011 23:58:46 +0300
parents b92333120c67
children 4e6f231f055f
files upreckon-vcs
diffstat 1 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/upreckon-vcs	Wed Mar 09 16:51:20 2011 +0000
+++ b/upreckon-vcs	Fri Apr 01 23:58:46 2011 +0300
@@ -6,11 +6,12 @@
 
 from compat import *
 
-version = '2.00.0 ($$REV$$)'
+version = '2.01.0 ($$REV$$)'
 parser = optparse.OptionParser(version='Upreckon '+version, epilog='Python 2.5 or newer is required.')
 parser.add_option('-1', dest='legacy', action='store_true', default=False, help='handle configuration files in a way more compatible with test.py 1.x')
 parser.add_option('-u', '--update', dest='update', action='store_true', default=False, help='update the installed Upreckon to the latest publicly available version')
 parser.add_option('-p', '--problem', dest='problems', metavar='PROBLEM', action='append', help='test only the PROBLEM (this option can be specified more than once with different problem names, all of which will be tested)')
+parser.add_option('--list-problems', action='store_true', default=False, help='just list all problem names')
 parser.add_option('-m', '--copy-io', dest='copyonly', action='store_true', default=False, help='create a copy of the input/output files of the last test case for manual testing and exit')
 parser.add_option('-x', '--auto-exit', dest='pause', action='store_false', default=True, help='do not wait for a key to be pressed after finishing testing')
 parser.add_option('-s', '--save-io', dest='erase', action='store_false', default=True, help='do not delete the copies of input/output files after the last test case; create copies of input files and store output in files even if the solution uses standard I/O; delete the stored input/output files if the solution uses standard I/O and the -c/--cleanup option is specified')
@@ -61,6 +62,9 @@
 if options.legacy:
 	compat.pseudobuiltins += 'xrange',
 
+if options.list_problems:
+	options.pause = False
+
 import testcases
 
 try:
@@ -70,7 +74,7 @@
 
 try:
 	globalconf = config.load_global()
-
+	
 	# Do this check here so that if we have to warn them, we do it as early as possible
 	if options.pause and not pause and not hasattr(globalconf, 'pause'):
 		if os.name == 'posix':
@@ -81,9 +85,9 @@
 			globalconf.pause = 'pause'
 		else:
 			sys.exit('Error: configuration variable pause is not defined and cannot be devised automatically.')
-
+	
 	from problem import *
-
+	
 	# Support single-problem configurations
 	if globalconf.problems is None:
 		shouldprintnames = False
@@ -92,12 +96,17 @@
 	else:
 		globalconf.multiproblem = True
 		shouldprintnames = True
-
+	
+	if options.list_problems:
+		for taskname in globalconf.problems:
+			say(taskname)
+		sys.exit()
+	
 	ntasks = 0
 	nfulltasks = 0
 	maxscore = 0
 	realscore = 0
-
+	
 	for taskname in (globalconf.problems if not options.problems else options.problems):
 		problem = Problem(taskname)
 		
@@ -113,10 +122,10 @@
 		nfulltasks += real == max
 		realscore += real
 		maxscore += max
-
+	
 	if options.copyonly:
 		sys.exit()
-
+	
 	if ntasks != 1:
 		say()
 		say('Grand total: %g/%g weighted points; %d/%d problems solved fully' % (realscore, maxscore, nfulltasks, ntasks))