import jinja2 import optparse import os import rspec req_spec = rspec.rspec() req_spec.add_title("Module ") # # Section # sec_uuid = req_spec.add( itemtype=rspec.ITYPE_SEC, id=1, heading="Section heading", ) # Requirement req_spec.add( parent=sec_uuid, itemtype=rspec.ITYPE_REQ, id=1, heading="Requirement heading", description="A meaningfull description.", reason="A meaningfull reson for the requirement.", fitcriterion="A meaningfull and exact fitcriterion.", ) if __name__ == '__main__': BASEPATH = os.path.abspath(os.path.dirname(__file__)) parser = optparse.OptionParser("usage: %prog specification_file") parser.add_option("-t", "--template", dest="template", default=os.path.join(BASEPATH, 'rspec', 'templates', 'tex', 'requirement_specification.tex'), help="path to the template") (options, args) = parser.parse_args() # render template_path = os.path.abspath(options.template) jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(template_path))) template = jenv.get_template(os.path.basename(template_path)) print(template.render(data=req_spec))