ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/IssueTrackerReporter.py
Revision: 499
Committed: Mon Jan 6 21:41:44 2014 UTC (12 years, 2 months ago) by nino.borges
Content type: text/x-python
File size: 3310 byte(s)
Log Message:
added program that will make a report from an issue tracker export.

File Contents

# Content
1 """
2 IssueTrackerReporter
3
4 Created by
5 Emanuel Borges
6 01.06.2014
7
8 Creates an easy to read report from the issue tracker export of "all issues".
9
10 """
11
12
13 def CreateBaseReport(outputFile):
14 """Creates the top of the HTML file"""
15 outputFile.write("""<html>\n <head>\n <title> ITO Report</title>\n</head><body>\n
16 """)
17 def FinishReport(outputFile):
18 """Creates the bottom of the HTML file"""
19 outputFile.write("""</body></html>""")
20
21 def SplitIntoPlates(exportFile):
22 openMWEList = []
23 openKPMGList = []
24 closedList = []
25
26 contents = open(exportFile).readlines()
27 contents = contents[1:]
28
29 for line in contents:
30 line = line.replace("\n","")
31 ID = line.split(",")[0]
32 ID = ID.replace('"',"")
33 if ID.isalpha():
34 pass
35 else:
36 KPMGStatus = line.split(",")[2]
37 MWEStatus = line.split(",")[3]
38 if KPMGStatus == '"Resolved"':
39 if MWEStatus == '"Resolved"':
40 closedList.append(line)
41 else:
42 openMWEList.append(line)
43 else:
44 openKPMGList.append(line)
45 return openMWEList,openKPMGList, closedList
46
47 def SplitIntoSections(currentList):
48 """Splits into sections and returns matrix"""
49 matrix = {}
50 for i in currentList:
51 i = i.split(",")
52 writeList = [i[0],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]]
53 issueType = i[1]
54 issueType = issueType.replace('"',"")
55 if issueType in matrix.keys():
56 matrix[issueType].append(writeList)
57 else:
58 matrix[issueType] = [writeList,]
59 return matrix
60
61 def ProcessToHTML(currentMatrix,outputFile,headding):
62 """Converts the lists into HTML tables"""
63 outputFile.write('<h2>%s</h2>\n'% headding)
64 outputFile.write('''<hr width="40%">''')
65 for section in currentMatrix.keys():
66 outputFile.write("<h3>%s</h3>\n"%section)
67 outputFile.write("<table border=1 cellspacing=0 cellpadding=5>\n")
68 outputFile.write("<tr><th>ID</th><th>KPMG Status</th><th>MWE Status</th><th>TE Prefix</th><th>TE Description</th><th>Reporter</th><th>Assignee</th><th>Created On</th><th>Modified On</th></tr>")
69 for x in currentMatrix[section]:
70 outputFile.write("<tr>\n")
71 for y in x:
72 outputFile.write("<td>%s</td>"%y)
73 outputFile.write("</tr>\n")
74 outputFile.write("</table>\n")
75
76 if __name__ == '__main__':
77 exportFile = "T:\honeywell\export_20140106_191259.csv"
78 htmlFile = "T:\honeywell\ITO_Report.html"
79 openMWEList,openKPMGList, closedList = SplitIntoPlates(exportFile)
80 print "mwe list %s"%len(openMWEList)
81 print "kpmg list %s"%len(openKPMGList)
82 print "closed list %s"%len(closedList)
83 mwePlate = SplitIntoSections(openMWEList)
84 kpmgPlate = SplitIntoSections(openKPMGList)
85 closedPlate = SplitIntoSections(closedList)
86 CreateBaseReport(open(htmlFile,'w'))
87 ProcessToHTML(mwePlate,open(htmlFile,'a'),"MWE's Plate")
88 ProcessToHTML(kpmgPlate,open(htmlFile,'a'),"<br><br><br>KPMG's Plate")
89 ProcessToHTML(closedPlate,open(htmlFile,'a'),"<br><br><br>Closed Requests")
90
91 FinishReport(open(htmlFile,'a'))