-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_generator.py
78 lines (62 loc) · 2.17 KB
/
report_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
__author__ = 'ak'
import pickle
from report_generator_tex import tex_page_renderer, tex_image_renderer
from report_generator_dot import dot_renderer
from report_generator_to_tex import simplex_table_to_tex_full, simplex_table_to_tex_table_only, simplex_table_to_tex_assumptions, simplex_table_to_tex_solution_good
result_file_name = 'result/task.pck'
report_graph_file_name = 'reports/task.png'
report_full_file_name = 'reports/task.pdf'
def add_node(tr, dr, i, pid, table):
(t, chs) = table
table_img_path = tr.put_some(simplex_table_to_tex_table_only(t))
assumps = simplex_table_to_tex_assumptions(t)
c_img_path = tr.put_some(assumps)
np = list()
"""c, pp = simplex_table_to_tex_assumptions(t)
c_img_path = ''
if len(c) > 0: c_img_path = tr.put_some(c)
np = list()
for p in pp:
p_img_path = ''
if len(p) > 0: p_img_path = tr.put_some(p)
np.append(p_img_path)"""
if not t.solution:
dr.add_node(i, pid, table_img_path, c_img_path, np)
else:
solution_img_path = tr.put_some(simplex_table_to_tex_solution_good(t))
dr.add_node_solution(i, pid, table_img_path, solution_img_path, c_img_path, np)
_i = i + 1
for ch in chs:
_i = add_node(tr, dr, _i, i, ch)
return _i
def add_nodes(tr, dr, solution):
(t, chs) = solution
img_path = tr.put_some(simplex_table_to_tex_table_only(t))
dr.add_node_lonely(0, img_path)
i = 1
for ch in chs:
i = add_node(tr, dr, i, 0, ch)
def full_add_node(tr, table):
(t, chs) = table
tr.put_some(simplex_table_to_tex_full(t))
tr.put_newpage()
for ch in chs:
full_add_node(tr, ch)
def full_add_nodes(tr, solution):
(t, chs) = solution
tr.put_some(simplex_table_to_tex_full(t))
tr.put_newpage()
for ch in chs:
full_add_node(tr, ch)
def main():
solution = pickle.load(open(result_file_name, 'rb'))
tr1 = tex_page_renderer()
full_add_nodes(tr1, solution)
tr1.compile(report_full_file_name)
tr = tex_image_renderer()
dr = dot_renderer()
add_nodes(tr, dr, solution)
tr.compile_images()
dr.compile(report_graph_file_name)
if __name__ == "__main__":
main()