-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.py
More file actions
26 lines (24 loc) · 768 Bytes
/
report.py
File metadata and controls
26 lines (24 loc) · 768 Bytes
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
import csv
import os
import shutil
from json import dumps
import distutils.core
def createReportDirectoryTree(filePath):
if filePath:
os.mkdir(filePath)
fromDirectory = "export_source"
toDirectory = filePath
distutils.dir_util.copy_tree(fromDirectory, toDirectory)
def exportReport(filePath, data):
if filePath:
# cree les repertoires si pas deja fait
if not os.path.exists(filePath):
createReportDirectoryTree(filePath)
# copie le csv
csvOut = csv.writer(open(filePath+"/csv/results.csv","wb"), delimiter=',',quoting=csv.QUOTE_ALL)
csvOut.writerows(data)
# copie le html
htmlOut = open(filePath+"/data/data.js", "wb")
jsonData = dumps(data, separators=(',',':'))
htmlOut.write("data = "+jsonData)
return filePath + "/results.html"