-
Notifications
You must be signed in to change notification settings - Fork 0
/
deckOutput.py
39 lines (32 loc) · 1.12 KB
/
deckOutput.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
def saveStep(dataDirectory, filePrefix, stepName, resultsMatrix):
outputString = "# Step " + stepName + "\n"
outputString += outputStringFromResults(resultsMatrix)
outputFile = filePrefix + "_" + stepName + ".txt"
mkdir_p(dataDirectory)
f = open(dataDirectory + outputFile, 'w')
f.write(outputString)
print(outputString)
f.close()
def saveDeckList(dataDirectory, filePrefix, stepName, resultsMatrix, header):
outputString = "#" + header + "\n"
outputString += outputStringFromResults(resultsMatrix)
outputFile = filePrefix + "_" + stepName + ".txt"
mkdir_p(dataDirectory)
f = open(dataDirectory + outputFile, 'w')
f.write(outputString)
print(outputString)
f.close()
def outputStringFromResults(resultsMatrix):
outputString = ""
for result in resultsMatrix:
deckOutput = map(str, result)
outputString += "\t".join(deckOutput) + "\n"
return outputString
def mkdir_p(path):
import os, errno
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST:
pass
else: raise