Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/ts/misc/concatlogs.py
16354 views
1
#!/usr/bin/env python
2
3
from optparse import OptionParser
4
import glob, sys, os, re
5
6
if __name__ == "__main__":
7
parser = OptionParser()
8
parser.add_option("-o", "--output", dest="output", help="output file name", metavar="FILENAME", default=None)
9
(options, args) = parser.parse_args()
10
11
if not options.output:
12
sys.stderr.write("Error: output file name is not provided")
13
exit(-1)
14
15
files = []
16
for arg in args:
17
if ("*" in arg) or ("?" in arg):
18
files.extend([os.path.abspath(f) for f in glob.glob(arg)])
19
else:
20
files.append(os.path.abspath(arg))
21
22
html = None
23
for f in sorted(files):
24
try:
25
fobj = open(f)
26
if not fobj:
27
continue
28
text = fobj.read()
29
if not html:
30
html = text
31
continue
32
idx1 = text.find("<tbody>") + len("<tbody>")
33
idx2 = html.rfind("</tbody>")
34
html = html[:idx2] + re.sub(r"[ \t\n\r]+", " ", text[idx1:])
35
except:
36
pass
37
38
if html:
39
idx1 = text.find("<title>") + len("<title>")
40
idx2 = html.find("</title>")
41
html = html[:idx1] + "OpenCV performance testing report" + html[idx2:]
42
open(options.output, "w").write(html)
43
else:
44
sys.stderr.write("Error: no input data")
45
exit(-1)
46
47