ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/ITO_Report/trunk/IssueTrackerReporter.py
Revision: 501
Committed: Tue Jan 7 21:39:14 2014 UTC (12 years, 2 months ago) by nino.borges
Content type: text/x-python
Original Path: Python/NinoCode/Active_prgs/IssueTrackerReporter.py
File size: 3642 byte(s)
Log Message:
refactor more

File Contents

# User Rev Content
1 nino.borges 499 """
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 nino.borges 501 if KPMGStatus in ['"Resolved"', '"Sent to MWE"','"Closed"','"Transmit to Counsel"'] :
39     if MWEStatus in ['"Resolved"','"Closed"']:
40 nino.borges 499 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 nino.borges 500 outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=90%>\n")
68 nino.borges 499 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 nino.borges 500 outputFile.write("</table></center>\n")
75 nino.borges 499
76     if __name__ == '__main__':
77 nino.borges 501 #exportFile = "/Users/ninoborges/Dropbox/Misc/export_20140106_191259.csv"
78     #htmlFile = "/Users/ninoborges/Documents/ITO_Report.html"
79     exportFile = "T:\honeywell\export_20140106_191259.csv"
80     htmlFile = "T:\honeywell\ITO_Report\ITO_Report.html"
81 nino.borges 499 openMWEList,openKPMGList, closedList = SplitIntoPlates(exportFile)
82     print "mwe list %s"%len(openMWEList)
83     print "kpmg list %s"%len(openKPMGList)
84     print "closed list %s"%len(closedList)
85     mwePlate = SplitIntoSections(openMWEList)
86     kpmgPlate = SplitIntoSections(openKPMGList)
87     closedPlate = SplitIntoSections(closedList)
88     CreateBaseReport(open(htmlFile,'w'))
89 nino.borges 500 ProcessToHTML(mwePlate,open(htmlFile,'a'),"MWE's Plate (%s items)"%len(openMWEList))
90     ProcessToHTML(kpmgPlate,open(htmlFile,'a'),"<br><br><br>KPMG's Plate (%s items)"%len(openKPMGList))
91     ProcessToHTML(closedPlate,open(htmlFile,'a'),"<br><br><br>Closed Requests (%s items)"%len(closedList))
92 nino.borges 499
93     FinishReport(open(htmlFile,'a'))