|
@@ -0,0 +1,36 @@
|
|
1
|
+#!/usr/bin/env python
|
|
2
|
+# -*- coding: utf-8 -*-
|
|
3
|
+#
|
|
4
|
+import jinja2
|
|
5
|
+import optparse
|
|
6
|
+import os
|
|
7
|
+import sys
|
|
8
|
+
|
|
9
|
+BASEPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
10
|
+sys.path.insert(0, BASEPATH)
|
|
11
|
+
|
|
12
|
+import reqif
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+if __name__ == '__main__':
|
|
16
|
+ parser = optparse.OptionParser("usage: %prog reqif_file")
|
|
17
|
+ parser.add_option("-t", "--template", dest="template", default=os.path.join(BASEPATH, 'reqif', 'templates', 'tex', 'requirement_specification.tex'), help="path to the template")
|
|
18
|
+ (options, args) = parser.parse_args()
|
|
19
|
+
|
|
20
|
+ #
|
|
21
|
+ # Check options and args
|
|
22
|
+ if len(args) != 1 or not os.path.isfile(args[0]):
|
|
23
|
+ parser.print_help()
|
|
24
|
+ else:
|
|
25
|
+ reqif_path = args[0]
|
|
26
|
+ template_path = os.path.abspath(options.template)
|
|
27
|
+ output_path = os.path.splitext(reqif_path)[0] + os.path.splitext(template_path)[1]
|
|
28
|
+ if reqif_path == output_path:
|
|
29
|
+ sys.exit('ERROR: Source and Destination would be the same file')
|
|
30
|
+ #
|
|
31
|
+ reqif_data = reqif.reqif_dict(reqif_path, 'Heading', 'Software Specification')
|
|
32
|
+ #
|
|
33
|
+ with open(output_path, 'w') as fh:
|
|
34
|
+ jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(template_path)))
|
|
35
|
+ template = jenv.get_template(os.path.basename(template_path))
|
|
36
|
+ fh.write(template.render(data=reqif_data))
|