reqif/reqif_conv.py

38 rader
1.1 KiB
Python

#!/usr/bin/env python
import jinja2
import os
import sys
"""fn_tex = 'requirements_specification.tex'
fn_pdf = 'requirements_specification.pdf'
tmp_path = 'tmp'"""
def tex_gen(reqif_data, tex_path):
print('Creating LaTeX-File %s' % tex_path)
with open(tex_path, 'w') as fh:
#
template_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates', 'tex'))
template_filename = 'requirement_specification.tex'
jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path))
template = jenv.get_template(template_filename)
fh.write(template.render(data=reqif_data))
def pdf_gen(tex_path):
pdf_path = os.path.splitext(tex_path)[0] + '.pdf'
print('Creating PDF %s' % pdf_path)
for i in range(3):
sys.stdout.write(' Starting run %d/3 of pdflatex... ' % (i + 1))
sys.stdout.flush()
exit_value = os.system("pdflatex -interaction nonstopmode %s 1> /dev/null" % tex_path)
if exit_value != 0:
print('FAILED')
return -1
break
else:
print('SUCCESS')
return 0