Esempio n. 1
0
    for n, r in zip(steps, rs):
        print(1 / n, tuple(x / base for x in r))

    return


def main():
    t = (1, 2, [], {})
    slice_args_ls = [(None, None), (1, 2), (None, -2), (2, None),
                     (None, None, -2)]

    print('is_slice_all_self', is_slice_all_self(t))

    for slice_args in slice_args_ls:
        print('are_slice_twice_results_the_same',
              are_slice_twice_results_the_same(t, *slice_args))

    for slice_args in slice_args_ls:
        print('does_slice_use_old_tuple',
              does_slice_use_old_tuple(t, *slice_args))

    t = tuple(range(1000000))
    print('does_slice_use_old_memory_data')
    does_slice_use_old_memory_data(t)
    return


if is_main(__name__):
    main()
    pass
Esempio n. 2
0
def to_pdf(tex_fname, pdf_fname):
    #dvi_file = tempfile.NamedTemporaryFile(prefix='textmp', delete=True)
    with tempfile.NamedTemporaryFile(suffix='.dvi',
                                     prefix='textmp',
                                     delete=True) as dvi_file:
        dvi_fname = dvi_file.name
        subprocess.call(
            tex2dvi_cmd_tpl.format(out_fname=dvi_fname, tex_fname=tex_fname))
        with tempfile.NamedTemporaryFile(suffix='.ps',
                                         prefix='textmp',
                                         delete=True) as ps_file:
            ps_fname = ps_file.name
            subprocess.call(
                dvi2ps_cmd_tpl.format(out_fname=ps_fname, dvi_fname=dvi_fname))
            subprocess.call(
                ps2pdf_cmd_tpl.format(ps_fname=ps_fname, pdf_fname=pdf_fname))


if sand.is_main(__name__):
    txt_fname = 'task.txt'
    pdf_fname = 'tasktmp.pdf'
    with open(txt_fname) as txt_file:
        tex = to_plain_tex_text(txt_file)

    with tempfile.NamedTemporaryFile(suffix='.tex',
                                     prefix='textmp',
                                     delete=True) as tex_file:
        tex_fname = tex_file.name
        tex_file.write(tex.encode(encoding='utf_8'))
        to_pdf(tex_fname, pdf_fname)