def validate_course_mode(course_id, mode, is_active=None, include_expired=False):
 if (not include_expired):
  include_expired = ((not is_active) if (is_active is not None) else False)
 course_enrollment_info = _data_api().get_course_enrollment_info(course_id, include_expired=include_expired)
 course_modes = course_enrollment_info['course_modes']
 available_modes = [m['slug'] for m in course_modes]
 if (mode not in available_modes):
  msg = u"Specified course mode '{mode}' unavailable for course {course_id}.  Available modes were: {available}".format(mode=mode, course_id=course_id, available=', '.join(available_modes))
  log.warn(msg)
  raise errors.CourseModeNotFoundError(msg, course_enrollment_info)

def validate_course_mode ( course_id , mode , is_active = None , include_expired = False ) : if ( not include_expired ) : include_expired = ( ( not is_active ) if ( is_active is not None ) else False ) course_enrollment_info = _data_api ( ) . get_course_enrollment_info ( course_id , include_expired = include_expired ) course_modes = course_enrollment_info [ 'course_modes' ] available_modes = [ m [ 'slug' ] for m in course_modes ] if ( mode not in available_modes ) : msg = u"Specified course mode '{mode}' unavailable for course {course_id}.  Available modes were: {available}" . format ( mode = mode , course_id = course_id , available = ', ' . join ( available_modes ) ) log . warn ( msg ) raise errors . CourseModeNotFoundError ( msg , course_enrollment_info )
checks to see if the specified course mode is valid for the course .