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)
def render_primer3_input(**kwargs): tpl_path = locate_template('d.primer3.txt') tpl = open(tpl_path).read() tpl = Template(tpl) return tpl.render(**kwargs)
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)
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