summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-04-24 14:48:29 +0000
committerCedric BAIL <cedric@ddlm.me>2019-04-24 09:56:57 -0700
commit9fd3c26a5e9e1895344565cbb27d278453c669ed (patch)
treec86b8e0feb3ee6bd0632f795f8d74e8561ceb6f9
parentb624cde117968a8f62f62d17ce3502d1d678b13e (diff)
2to3 modifications to expedite-cmp
Make expedite-cmp runnable with py3 Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D8700
-rwxr-xr-xsrc/bin/expedite-cmp60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/bin/expedite-cmp b/src/bin/expedite-cmp
index 2df01ad..ea6d5ec 100755
--- a/src/bin/expedite-cmp
+++ b/src/bin/expedite-cmp
@@ -1,5 +1,7 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2 2
3from __future__ import print_function
4
3import sys 5import sys
4import os 6import os
5import os.path 7import os.path
@@ -68,12 +70,12 @@ def report_text():
68 fmtsize = len(options.format % {"value": 12345.67, "percentual": 1234.56}) 70 fmtsize = len(options.format % {"value": 12345.67, "percentual": 1234.56})
69 hdrfmt = "%%%d.%ds" % (fmtsize, fmtsize) 71 hdrfmt = "%%%d.%ds" % (fmtsize, fmtsize)
70 72
71 print test_name_fmt % "\\", 73 print(test_name_fmt % "\\", end=' ')
72 print "%7.7s" % (files[0][-7:],), 74 print("%7.7s" % (files[0][-7:],), end=' ')
73 for f in files[1:]: 75 for f in files[1:]:
74 n, e = os.path.splitext(f) 76 n, e = os.path.splitext(f)
75 print hdrfmt % n[-fmtsize:], 77 print(hdrfmt % n[-fmtsize:], end=' ')
76 print 78 print()
77 79
78 if options.color and os.environ.get("TERM", "") in ( 80 if options.color and os.environ.get("TERM", "") in (
79 "xterm", "xterm-color", "rxvt", "rxvt-unicode", "screen", 81 "xterm", "xterm-color", "rxvt", "rxvt-unicode", "screen",
@@ -90,14 +92,14 @@ def report_text():
90 92
91 93
92 def print_row(test): 94 def print_row(test):
93 print test_name_fmt % test, 95 print(test_name_fmt % test, end=' ')
94 ref_val = data[ref_f][test] 96 ref_val = data[ref_f][test]
95 print "%7.2f" % ref_val, 97 print("%7.2f" % ref_val, end=' ')
96 for f in others_f: 98 for f in others_f:
97 try: 99 try:
98 val = data[f][test] 100 val = data[f][test]
99 except KeyError: 101 except KeyError:
100 print "-?????-", 102 print("-?????-", end=' ')
101 continue 103 continue
102 104
103 percent = (val - ref_val) / ref_val 105 percent = (val - ref_val) / ref_val
@@ -111,9 +113,9 @@ def report_text():
111 fmt = options.format % {"value": val, "percentual": percent * 100} 113 fmt = options.format % {"value": val, "percentual": percent * 100}
112 if len(fmt) < fmtsize: 114 if len(fmt) < fmtsize:
113 fmt = hdrfmt % fmt 115 fmt = hdrfmt % fmt
114 print "%s%s%s" % (c, fmt, color_reset), 116 print("%s%s%s" % (c, fmt, color_reset), end=' ')
115 117
116 print 118 print()
117 119
118 for t in tests: 120 for t in tests:
119 print_row(t) 121 print_row(t)
@@ -123,7 +125,7 @@ def report_html():
123 import time 125 import time
124 126
125 fnames = [os.path.basename(f) for f in files] 127 fnames = [os.path.basename(f) for f in files]
126 print """\ 128 print("""\
127<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 129<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
128 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 130 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
129 131
@@ -156,9 +158,9 @@ def report_html():
156 border-bottom: 1px dashed #ccc; 158 border-bottom: 1px dashed #ccc;
157 } 159 }
158 td.test-name, thead tr td { text-align: right; }\ 160 td.test-name, thead tr td { text-align: right; }\
159""" 161""")
160 if options.color: 162 if options.color:
161 print """\ 163 print("""\
162 td.value-good { background-color: #aaffaa; } 164 td.value-good { background-color: #aaffaa; }
163 td.value-bad { background-color: #ffaaaa; } 165 td.value-bad { background-color: #ffaaaa; }
164 td.value-missing { background-color: #ffffaa; } 166 td.value-missing { background-color: #ffffaa; }
@@ -168,9 +170,9 @@ def report_html():
168 background-color: #d9d9d9; 170 background-color: #d9d9d9;
169 border-bottom: 1px dashed #ccc; 171 border-bottom: 1px dashed #ccc;
170 } 172 }
171""" 173""")
172 174
173 print """ 175 print("""
174 </style> 176 </style>
175 <body> 177 <body>
176 <p>Comparison sheet for %(files)s, created at %(date)s.</p> 178 <p>Comparison sheet for %(files)s, created at %(date)s.</p>
@@ -180,17 +182,17 @@ def report_html():
180 <td>\\</td>\ 182 <td>\\</td>\
181""" % {"files": ", ".join(fnames), 183""" % {"files": ", ".join(fnames),
182 "date": time.asctime(), 184 "date": time.asctime(),
183 } 185 })
184 186
185 for f in fnames: 187 for f in fnames:
186 print """\ 188 print("""\
187 <td>%s</td>\ 189 <td>%s</td>\
188""" % f 190""" % f)
189 print """\ 191 print("""\
190 </tr> 192 </tr>
191 </thead> 193 </thead>
192 <tbody>\ 194 <tbody>\
193""" 195""")
194 196
195 def print_row(test): 197 def print_row(test):
196 ref_val = data[ref_f][test] 198 ref_val = data[ref_f][test]
@@ -199,19 +201,19 @@ def report_html():
199 else: 201 else:
200 extra_cls = "" 202 extra_cls = ""
201 203
202 print """\ 204 print("""\
203 <tr%s> 205 <tr%s>
204 <td class="test-name">%s</td> 206 <td class="test-name">%s</td>
205 <td class="value-reference">%7.2f</td>\ 207 <td class="value-reference">%7.2f</td>\
206""" % (extra_cls, test, ref_val) 208""" % (extra_cls, test, ref_val))
207 209
208 for f in others_f: 210 for f in others_f:
209 try: 211 try:
210 val = data[f][test] 212 val = data[f][test]
211 except KeyError: 213 except KeyError:
212 print """\ 214 print("""\
213 <td class="value-missing">-?????-</td>\ 215 <td class="value-missing">-?????-</td>\
214""" 216""")
215 continue 217 continue
216 218
217 percent = (val - ref_val) / ref_val 219 percent = (val - ref_val) / ref_val
@@ -224,23 +226,23 @@ def report_html():
224 226
225 v = options.format % {"value": val, "percentual": percent * 100} 227 v = options.format % {"value": val, "percentual": percent * 100}
226 228
227 print """\ 229 print("""\
228 <td class="value-%s">%s</td>\ 230 <td class="value-%s">%s</td>\
229""" % (c, v) 231""" % (c, v))
230 232
231 print """\ 233 print("""\
232 </tr>\ 234 </tr>\
233""" 235""")
234 236
235 for t in tests: 237 for t in tests:
236 print_row(t) 238 print_row(t)
237 239
238 print """\ 240 print("""\
239 </tbody> 241 </tbody>
240 </table> 242 </table>
241 </body> 243 </body>
242</html> 244</html>
243""" 245""")
244 246
245if options.report == "text": 247if options.report == "text":
246 report_text() 248 report_text()