def grader_from_conf(conf):
 if isinstance(conf, CourseGrader):
  return conf
 subgraders = []
 for subgraderconf in conf:
  subgraderconf = subgraderconf.copy()
  weight = subgraderconf.pop('weight', 0)
  try:
   if ('min_count' in subgraderconf):
    subgrader_class = AssignmentFormatGrader
   else:
    raise ValueError('Configuration has no appropriate grader class.')
   bad_args = invalid_args(subgrader_class.__init__, subgraderconf)
   if (len(bad_args) > 0):
    log.warning('Invalid arguments for a subgrader: %s', bad_args)
    for key in bad_args:
     del subgraderconf[key]
   subgrader = subgrader_class(**subgraderconf)
   subgraders.append((subgrader, subgrader.category, weight))
  except (TypeError, ValueError) as error:
   msg = ((('Unable to parse grader configuration:\n    ' + str(subgraderconf)) + '\n    Error was:\n    ') + str(error))
   raise ValueError(msg), None, sys.exc_info()[2]
 return WeightedSubsectionsGrader(subgraders)

def grader_from_conf ( conf ) : if isinstance ( conf , CourseGrader ) : return conf subgraders = [ ] for subgraderconf in conf : subgraderconf = subgraderconf . copy ( ) weight = subgraderconf . pop ( 'weight' , 0 ) try : if ( 'min_count' in subgraderconf ) : subgrader_class = AssignmentFormatGrader else : raise ValueError ( 'Configuration has no appropriate grader class.' ) bad_args = invalid_args ( subgrader_class . __init__ , subgraderconf ) if ( len ( bad_args ) > 0 ) : log . warning ( 'Invalid arguments for a subgrader: %s' , bad_args ) for key in bad_args : del subgraderconf [ key ] subgrader = subgrader_class ( ** subgraderconf ) subgraders . append ( ( subgrader , subgrader . category , weight ) ) except ( TypeError , ValueError ) as error : msg = ( ( ( 'Unable to parse grader configuration:\n    ' + str ( subgraderconf ) ) + '\n    Error was:\n    ' ) + str ( error ) ) raise ValueError ( msg ) , None , sys . exc_info ( ) [ 2 ] return WeightedSubsectionsGrader ( subgraders )
this creates a coursegrader from a configuration .