6 from xml
.dom
import minidom
7 from BeautifulSoup
import BeautifulSoup
13 res_div_re
= re
.compile('(.*?)_res_div')
14 settings_div_re
= re
.compile('(.*?)_settings_div')
17 gray_border_div_str
= '<div style = "border-style: dotted; border-width: 1px; border-color: lightgray">'
18 space_div_str
= '<div style = "width: 100%; height: 20px">'
22 def logical_build_from_build(build
):
29 sys
.stderr
.write(build
)
33 def img_title_from_origs(label
, title
, base_build_ref
, build_name
, logical_build_name
):
34 title
= title
.replace('_tt_', '<tt>')
35 title
= title
.replace('_455tt_', '</tt>')
36 title
= title
.replace('_b_', '<b>')
37 title
= title
.replace('_455b_', '</b>')
38 title
= title
.replace('_456', ',')
39 title
= title
.replace('_457', '[]')
40 title
= title
.replace('_', ' ')
41 return '%s: %s - <a href = "%s_performance_tests.html#%s">%s</a>' % (
49 def make_png(src_dir
, doc_dir
, res_dir
, tests_info_xml_f_name
, build_name
, test_name
):
50 cmd_str
= '%s/scripts/make_graph.py %s %s %s %s %s' % (
53 tests_info_xml_f_name
,
56 # Must start a new process for pychart - otherwise pngs overlap.
57 so
= commands
.getstatusoutput(cmd_str
)
59 sys
.stderr
.write(cmd_str
+ '\n')
60 sys
.stderr
.write(so
[1] + '\n')
64 def make_png_str(label
, test_name
, build
):
65 ret
= '<h6 class="c1">'
66 ret
+= '<a name="%s" id= "%s">' % (label
, label
)
67 ret
+= '<img src="%s" ' % (test_name
+ '_' + build
+ '.png')
68 ret
+= 'alt="no image" />'
72 def process_html(html_f_name
, src_dir
, build_dir
, htmls_xml_f_name
, tests_info_xml_f_name
, build_name
, compiler_name
):
73 doc_dir
= src_dir
+ "/doc/html/ext/pb_ds"
75 html_f
= open(doc_dir
+ '/' + html_f_name
)
76 soup
= BeautifulSoup(html_f
.read())
78 platform_comp_re
= re
.compile('platform_comp_%s' % build_name
)
81 settings_m
= settings_div_re
.match(d
['id'])
82 res_m
= res_div_re
.match(d
['id'])
88 build
= settings_m
.groups()[0]
89 if build
== build_name
:
90 logical_build_name
= logical_build_from_build(build
)
91 info
= gray_border_div_str
92 info
+= '<h3><a name = "%s"><u>%s</u></a></h3>' % (build
, logical_build_name
)
93 info
+= make_graph
.comp_platform_info(compiler_name
)
94 info
+= '</div>%s</div>' % space_div_str
97 label
= res_m
.groups()[0]
100 build
= d
['id'].replace('%s_' % label
, '')
102 if build
== build_name
:
103 logical_build_name
= logical_build_from_build(build
)
105 test_name
= d
['id'].replace('%s_' % label
, '')
107 base_build_ref
= d
['id'].replace('%s_' % label
, '')
109 title
= d
['id'].replace('%s_' % label
, '')
110 img_title
= img_title_from_origs(label
, title
, base_build_ref
, build
, logical_build_name
)
112 make_png(src_dir
, doc_dir
, res_dir
, tests_info_xml_f_name
, build_name
, test_name
)
113 png_str
= make_png_str(label
, test_name
, build
)
114 content
= gray_border_div_str
117 # content += make_graph.legend(doc_dir, res_dir, tests_info_xml_f_name, test_name, build_name)
118 content
+= '</div>%s</div>' % space_div_str
125 if __name__
== "__main__":
128 This module takes 6 parameters from the command line:
132 Tests info XML file name
137 usg
= "make_graph.py <src_dir> <build_dir> <htmls_xml_f_name> <tests_info_xml_f_name> <build_name> <compiler_name>\n"
139 if len(sys
.argv
) != 7:
140 sys
.stderr
.write(usg
)
143 src_dir
= sys
.argv
[1]
144 build_dir
= sys
.argv
[2]
145 htmls_xml_f_name
= sys
.argv
[3]
146 tests_info_xml_f_name
= sys
.argv
[4]
147 build_name
= sys
.argv
[5]
148 compiler_name
= sys
.argv
[6]
149 doc_dir
= src_dir
+ "/doc/html/ext/pb_ds"
150 htmls_dat
= minidom
.parse(htmls_xml_f_name
)
151 for html
in htmls_dat
.getElementsByTagName('html'):
152 html_f_name
= html
.attributes
['name'].value
154 new_soup
= process_html(html_f_name
, src_dir
, build_dir
, htmls_xml_f_name
, tests_info_xml_f_name
, build_name
, compiler_name
)
156 html_f
= open(doc_dir
+ '/' + html_f_name
, 'w')
157 html_f
.write(str(new_soup
))