Beispiel #1
0
    def run(cls, args):
        tpl_path = locate_template(args.template, new=False)
        tpl = open(tpl_path).read()

        # TODO: render from a template
        output = tpl

        if args.out == '-':
            sys.stdout.write(tpl)
        else:
            filename = args.out or locate_template(args.template, new=True)
            cls.check_overwrite(args, filename)

            with open(filename, 'w') as outfile:
                outfile.write(output)

            # chmod +x
            st = os.stat(filename)
            os.chmod(filename, st.st_mode | stat.S_IEXEC)
Beispiel #2
0
def render_primer3_input(**kwargs):
    tpl_path = locate_template('d.primer3.txt')
    tpl = open(tpl_path).read()
    tpl = Template(tpl)
    return tpl.render(**kwargs)
Beispiel #3
0
def render_svg(**kwargs):
    # font-size: 12; font: Arial
    tpl_path = locate_template('d.arrows.xml')
    tpl = open(tpl_path).read()
    tpl = Template(tpl)
    return tpl.render(**kwargs)
Beispiel #4
0
def test_j2(gbdict):
    import jinja2
    tmpl = jinja2.Template(open(locate_template('d.genbank.tpl')).read())
    res = tmpl.render(gbdict=gbdict, wrap=textwrap.wrap)
    return res