Ejemplo n.º 1
0
def main():
    if sys.argv[1] in ('help', '-h', '--help', '-help'):
        print(__doc__)
        sys.exit()
    code = int(sys.argv[-1])
    group = get_group()
    locals_ = {}
    exec('from varEC.courses.%s import input_files' % group, globals(), locals_)
    input_files = locals_['input_files']
    print('input files:\n  ', end='')
    print(*input_files, sep='\n  ', end='\n\n')
    books = BookShelf(input_files)
    text = books.exercise_text(code)
    exercise_test(text, variation_number=6, with_latextable=1)
Ejemplo n.º 2
0
def make_testpapers(solution_file=True):

    books = BookShelf(files.input)

    codes = get_ordered_codes(exercise_numbers)
    number_of_variations = variations.num
    assert isinstance(number_of_variations, int) and number_of_variations >= 0

    global exercise_numbers
    try:
        variation = varexercise.Variations(
            exercise_numbers,
            files.input,
            number_of_variations
        )
    except CodeNotFoundError:
        message(_("Not all the exercise codes exists on the books "
                  "that was listed in the test paper."))
        return
    base_name, extension = os.path.splitext(files.output)

    pagesize, solution_pagesize, list_pagesize = get_pagesize(page)

    shared_parameters = dict(
        preamble_file="magyarpreambulum",
        rhead=header_footer.inst,
        lfoot=header_footer.course,
        rfoot=header_footer.date,
        definitions=books.definitions(codes)
    )

    solution_text = variation.one()
    text = solution_text if number_of_variations == 0 else variation.all()

    parameters = shared_parameters.copy()
    parameters.update(
        doc_type='testpaper',
        pagesize=pagesize,
        fontsize=fontsize,
        lhead=header_footer.title,
        cfoot=None,
    )
    file_name = "%s.tex" % base_name
    save_file(text, parameters, file_name, page == '4a5')

    if solution_file:

        parameters = shared_parameters.copy()
        parameters.update(
            doc_type='plain',
            pagesize=solution_pagesize,
            fontsize=fontsize,
            lhead=header_footer.title + " Megoldás",
            cfoot='\\thepage',
        )
        file_name = "%s_megold.tex" % base_name
        save_file(solution_text, parameters, file_name)

    if not number_of_variations == 0:
        text = variation.list()
        if not text:
            raise ValueError('no variations in TeX source.')
        else:
            parameters = shared_parameters.copy()
            parameters.update(
                doc_type='plain',
                fontsize=10,
                pagesize=list_pagesize,
                lhead=header_footer.title,
                cfoot='\\thepage',
            )
            file_name = "%s_list.tex" % base_name
            save_file(text, parameters, file_name)

    wrote_files_message = _('I wrote the files:\n %s\n')
    message(wrote_files_message % output_tex_files)

    other_output_files = OutputFiles()  # Non-tex files.
    if make.format == '0':
        make.format = 0
    if output_tex_files.list and make.format:
        message(_('I will translate the files. It will take a while.\n'))
        for file in output_tex_files.list:
            new_files = translate(file)
            other_output_files.extend(new_files)

    print('\n')
    message(wrote_files_message %
                ("%s%s" % (output_tex_files, other_output_files)))