Commits

Oleg Oshmyan committed 32650f4

taskweight can now be an iterable or a mapping

If an iterable, its items correspond to items of the problems
configuration variable. If a mapping, its keys are problem
names.

Comments (0)

Files changed (1)

 		elif not callable(module.tester):
 			tester = tuple(module.tester)
 			module.tester = (nativize_path(tester[0]),) + tester[1:]
+	try:
+		module.taskweight = dict(zip(module.problems, module.taskweight))
+	except TypeError:
+		pass
+	try:
+		module.taskweight = module.taskweight[problem_name]
+	except KeyError:
+		module.taskweight = defaults_problem['taskweight']
+	except TypeError:
+		pass
 	for name in 'pointmap', 'groupweight':
 		oldmap = getattr(module, name)
 		if isinstance(oldmap, dict):
 			setattr(module, name, getattr(module, name, defaults_noerase[name]))
 	if hasattr(module, 'tasknames'):
 		module.problems = module.tasknames
+	# Iterable and mapping taskweights cause re-iteration over problems
+	try:
+		len(module.problems)
+	except Exception:
+		module.problems = tuple(module.problems)
 	global globalconf
 	globalconf = module
 	try: