Ejemplo n.º 1
0
def operate(args):
    """
    Takes the passed in args and delegates to the proper functionality. This is
    set as the executable function when `writers todo` subparser is used

    Arguments:
    args: Namespace - The arguments passed via CLI
    """
    # Parse the problem numbers from commandline
    problemParser = NumberParse()
    if not args.problems is None:
        specifiedProblems = problemParser.str_list_to_uniq_range(args.problems)
    else:
        specifiedProblems = None

    todo_writers(args.writer_directories, specifiedProblems, args.email,
            args.language, args.writer, args.name)
Ejemplo n.º 2
0
def operate(args):
    """
    Takes the passed in args and delegates to proper functionality. This is set
    as the executable function when the `writers assign` subparser is used.

    Arguments:
    args: Namespace - The arguments passed via CLI
    """
    # If the user specified a problem list, use that as the list of problems. 
    problemParser = NumberParse()
    if not args.problems is None:
        specifiedProblems = problemParser.str_list_to_uniq_range(args.problems)
    else:
        specifiedProblems = problemParser.str_list_to_uniq_range(['1+'])

    specifiedLanguages = []
    if not args.language is None:
        for languageName in args.language:
            loadedLanguage = Languages.get_language_by_name(languageName)
            if loadedLanguage is None:
                raise PyCException('Error: {} is an invalid language'.format(languageName))
            specifiedLanguages.append(loadedLanguage)
    else:
        specifiedLanguages = [Languages.get_language_by_name(name) for name in 
                Languages.get_all_language_names()]

    specifiedWriters = []
    if not args.full and not args.writer_names is None and len(args.writer_names) > 0:
        for writerName in args.writer_names:
            loadedWriter = Writer.load_from_folder(writerName)
            if loadedWriter is None:
                raise PyCException('Error: {} is an invalid writer'.format(writerName))
            specifiedWriters.append(loadedWriter)
    else:
        specifiedWriters = Writers.get_all_writers()

    allocator = AssignmentAllocator(specifiedProblems, specifiedLanguages, 
            specifiedWriters, fromScratch=args.full)
    allocator.do_assignment(Definitions.get_value('complete_threshold'), overflow=args.overallocate)