-
Notifications
You must be signed in to change notification settings - Fork 0
/
writers.py
64 lines (49 loc) · 1.44 KB
/
writers.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
import csv
from gui import os_wrapper
class CWriter(object):
def __init__(self, pFile):
super(CWriter, self).__init__()
self.mFH = open(pFile, "wb")
def write(self, pFile, pType, pInode, pHash):
pass
def close(self):
pass
class CWriterCsv(CWriter):
def __init__(self, pFile):
super(CWriterCsv, self).__init__(pFile)
self.mWriter = csv.writer(
self.mFH,
delimiter=',',
quotechar='\'',
quoting=csv.QUOTE_MINIMAL)
self.mWriter.writerow(['Path', 'Type', 'Inode', 'Hash'])
def write(self, pPathBase, pPath, pType, pInode, pHash):
self.mWriter.writerow([pPath, pType, pInode, pHash])
class CWriterHtml(CWriter):
def __init__(self, pFile):
super(CWriterHtml, self).__init__(pFile)
self.mFH.write("""
<html>
<head>
<title>Report</title>
</head>
<body>
<table border="1">
<thead>
<tr>
<td>Path</td><td>Type</td><td>Inode</td><td>Hash</td>
</tr>
</thead>
""")
def write(self, pPathBase, pPath, pType, pInode, pHash):
self.mFH.write(" <tr>")
self.mFH.write("<td>" + pPath + "</td>")
self.mFH.write("<td>" + pType + "</td>")
self.mFH.write("<td>" + pInode + "</td>")
self.mFH.write("<td>" + pHash + "</td>")
self.mFH.write("</tr>\n")
def close(self):
self.mFH.write("""</table>
</body>
</html>
""")