comparison upreckon/config.py @ 201:32650f4a2177

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.
author Oleg Oshmyan <chortos@inbox.lv>
date Wed, 17 Aug 2011 01:05:06 +0300
parents fa81289ee407
children dd1f715398f0
comparison
equal deleted inserted replaced
200:fa81289ee407 201:32650f4a2177
175 if isinstance(module.tester, basestring): 175 if isinstance(module.tester, basestring):
176 module.tester = nativize_path(module.tester) 176 module.tester = nativize_path(module.tester)
177 elif not callable(module.tester): 177 elif not callable(module.tester):
178 tester = tuple(module.tester) 178 tester = tuple(module.tester)
179 module.tester = (nativize_path(tester[0]),) + tester[1:] 179 module.tester = (nativize_path(tester[0]),) + tester[1:]
180 try:
181 module.taskweight = dict(zip(module.problems, module.taskweight))
182 except TypeError:
183 pass
184 try:
185 module.taskweight = module.taskweight[problem_name]
186 except KeyError:
187 module.taskweight = defaults_problem['taskweight']
188 except TypeError:
189 pass
180 for name in 'pointmap', 'groupweight': 190 for name in 'pointmap', 'groupweight':
181 oldmap = getattr(module, name) 191 oldmap = getattr(module, name)
182 if isinstance(oldmap, dict): 192 if isinstance(oldmap, dict):
183 newmap = {} 193 newmap = {}
184 for key in oldmap: 194 for key in oldmap:
241 if not options.erase: 251 if not options.erase:
242 for name in defaults_noerase: 252 for name in defaults_noerase:
243 setattr(module, name, getattr(module, name, defaults_noerase[name])) 253 setattr(module, name, getattr(module, name, defaults_noerase[name]))
244 if hasattr(module, 'tasknames'): 254 if hasattr(module, 'tasknames'):
245 module.problems = module.tasknames 255 module.problems = module.tasknames
256 # Iterable and mapping taskweights cause re-iteration over problems
257 try:
258 len(module.problems)
259 except Exception:
260 module.problems = tuple(module.problems)
246 global globalconf 261 global globalconf
247 globalconf = module 262 globalconf = module
248 try: 263 try:
249 sys.dont_write_bytecode = dwb 264 sys.dont_write_bytecode = dwb
250 except NameError: 265 except NameError: