-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvscan-view
executable file
·59 lines (52 loc) · 1.04 KB
/
vscan-view
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
#!/usr/bin/env python
# Copyright (c) 2011 Akamai Technologies, Inc.
import sys
from string import Template
from subprocess import Popen, PIPE
from os.path import dirname, join
t = Template("""
<html>
<head>
<style type="text/css">
.hit {background-color: red; font-weight: normal;}
</style>
</head>
<body>
<p>
Report For Path<br/>
.......................
</p>
<p>${path}</p>
<p>
Features:<br/>
.......................
</p>
<p>
${features}
<p/>
Highlighted Contents<br/>
.......................
</p>
<p>
${content}
</p>
</body>
</html>
""")
qpath = sys.argv[1]
highlighter = join(dirname(sys.argv[0]), "vscan-highlight")
features = []
content = ""
out = Popen([highlighter, qpath], stdout=PIPE).communicate()[0]
for line in out.split("\n"):
if len(line) > 0:
if line[0] == 'P':
features = line.split()[2:]
elif line[0] == 'H':
content = line.split(' ', 2)[2]
html = t.safe_substitute({
"path": qpath,
"features": "<br/>".join(features) + "<br/>",
"content": content,
})
Popen(["lynx", "-stdin"], stdin=PIPE).communicate(html)