ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/IssueTrackerReporter.py
Revision: 502
Committed: Wed Jan 8 21:39:12 2014 UTC (12 years, 2 months ago) by nino.borges
Content type: text/x-python
File size: 8236 byte(s)
Log Message:
Added more html and multiple pages.

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("""
16 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.5 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
17 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
18 <head>
19 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
20 <meta name="description" content="Your description goes here" />
21 <meta name="keywords" content="your,keywords,goes,here" />
22 <meta name="author" content="Emanuel Borges">
23 <link rel="stylesheet" type="text/css" href="main.css" title="ITO Report" media="all" />
24 <title>ITO Report</title>
25 </head>
26
27 <body>
28 <div id="containerfull"><!-- Use"containerfull" for 100% width. For fixed width, use "container980", "container760" or "container600" (the number is the layout width in pixels). -->
29 <div id="header">
30 <h1><a href="index.html">ITO Report</a></h1>
31 <h2>Report gathered from Issue Tracking Object.</h2>
32 </div>
33 """)
34 outputFile.close()
35 def FinishReport(outputFile):
36 """Creates the bottom of the HTML file"""
37 outputFile.write("""
38
39 <div class="clear">&nbsp;</div>
40 </div>
41 <div class="clear">&nbsp;</div>
42 </div>
43 <div id="footer">
44 <div id="footersections">
45 <div class="half">
46 <h2>Footer area #1</h2>
47 <p>manny test.</p>
48 </div>
49 <div class="quarter">
50 <h2>Footer area #2</h2>
51 <p>manny test 2.</p>
52 <p>Paragraphs and <a href="#">links</a> work here too.</p>
53 </div>
54 <div class="lastquarter">
55 <h2>Footer menu</h2>
56 <ul>
57 <li><a href="#">Link #1</a></li>
58 <li><a href="#">Link #2</a></li>
59 </ul>
60 </div>
61 <div class="clear">&nbsp;</div>
62 </div>
63 </div>
64 <div id="credits">
65 <p>&copy; 2014 Emanuel Borges<br />
66 </div>
67 </div>
68 </body>
69 </html>
70 """)
71 outputFile.close()
72
73 def SplitIntoPlates(exportFile):
74 openMWEList = []
75 openKPMGList = []
76 closedList = []
77
78 contents = open(exportFile).readlines()
79 contents = contents[1:]
80
81 for line in contents:
82 line = line.replace("\n","")
83 ID = line.split(",")[0]
84 ID = ID.replace('"',"")
85 if ID.isalpha():
86 pass
87 else:
88 KPMGStatus = line.split(",")[2]
89 MWEStatus = line.split(",")[3]
90 if KPMGStatus in ['"Resolved"', '"Sent to MWE"','"Closed"','"Transmit to Counsel"'] :
91 if MWEStatus in ['"Resolved"','"Closed"']:
92 closedList.append(line)
93 else:
94 openMWEList.append(line)
95 else:
96 openKPMGList.append(line)
97 return openMWEList,openKPMGList, closedList
98
99 def SplitIntoSections(currentList):
100 """Splits into sections and returns matrix"""
101 matrix = {}
102 for i in currentList:
103 i = i.split(",")
104 writeList = [i[0],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]]
105 issueType = i[1]
106 issueType = issueType.replace('"',"")
107 if issueType in matrix.keys():
108 matrix[issueType].append(writeList)
109 else:
110 matrix[issueType] = [writeList,]
111 return matrix
112
113 def ProcessToHTML(currentMatrix,outputFile,headdingList,part):
114 """Converts the lists into HTML tables"""
115 outputFile.write("""
116 <div id="menu">
117 <ul>
118 """)
119 if part[:3] == "MWE":
120 outputFile.write('<li><a class="current" href="index2.html">%s</a></li>\n'% headdingList[0])
121 outputFile.write("""
122 <li><a href="KPMGs_Plate.html">KPMG's Plate (4)</a></li>
123 <li><a href="Closed_Items.html">Closed Issues (239)</a></li>
124 <li><a href="Project_View.html">Project View</a></li>
125 </ul>
126 </div>
127
128 <div id="feature">
129 <div class="left">
130 <h2>About the MWE Plate</h2>
131 <p>These are all of the tasks and projects, broken out by Issue type, that are currently assigned to the MWE team.</p>
132 </div>
133 <div class="clear">&nbsp;</div>
134 </div>
135 <div id="main">
136 <div id="sidebar">
137 <div class="sidebarbox">
138 <h2>Issue menu</h2>
139 <ul class="sidemenu">\n""")
140 for section in currentMatrix.keys():
141 outputFile.write(' <li><a href="#%s">%s</a></li>\n'%(section,section))
142 outputFile.write(""" </ul>
143 </div>
144
145 <div class="sidebarbox">
146 <h2>Text box</h2>
147 <p>Important links:</p>
148 <ul>
149 <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
150 <li><a href="#">Another</a></li>
151 </ul>
152 </div>
153 </div>
154
155 <div id="content">
156 """)
157 for section in currentMatrix.keys():
158 outputFile.write('<h3 id="%s">%s</h3>\n'%(section,section))
159 outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=95%>\n")
160 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>")
161 for x in currentMatrix[section]:
162 outputFile.write("<tr>\n")
163 for y in x:
164 outputFile.write("<td>%s</td>"%y)
165 outputFile.write("</tr>\n")
166 outputFile.write("</table></center><br><br>\n")
167
168 elif part[:3] == "KPM":
169 outputFile.write('<li><a class="current" href="index2.html">%s</a></li>\n'% headdingList[1])
170 elif part[:3] == "Clo":
171 outputFile.write('<h2>%s</h2>\n'% headdingList[2])
172 else:
173 pass
174 ##
175 ## outputFile.write('<h2>%s</h2>\n'% headdingList[0])
176 ## outputFile.write('''<hr width="40%">''')
177 ## for section in currentMatrix.keys():
178 ## outputFile.write("<h3>%s</h3>\n"%section)
179 ## outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=90%>\n")
180 ## 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>")
181 ## for x in currentMatrix[section]:
182 ## outputFile.write("<tr>\n")
183 ## for y in x:
184 ## outputFile.write("<td>%s</td>"%y)
185 ## outputFile.write("</tr>\n")
186 ## outputFile.write("</table></center>\n")
187 outputFile.close()
188
189 if __name__ == '__main__':
190 #exportFile = "/Users/ninoborges/Dropbox/Misc/export_20140106_191259.csv"
191 #htmlFile = "/Users/ninoborges/Documents/ITO_Report.html"
192 exportFile = "T:\honeywell\export_20140106_191259.csv"
193 indexFile= "T:\honeywell\ITO_Report\index2.html"
194 kpmgFile = "T:\honeywell\ITO_Report\KPMGs_Plate.html"
195 closedFile = "T:\honeywell\ITO_Report\Closed_Items.html"
196 projectViewFile = "T:\honeywell\ITO_Report\Project_View.html"
197 openMWEList,openKPMGList, closedList = SplitIntoPlates(exportFile)
198 print "mwe list %s"%len(openMWEList)
199 print "kpmg list %s"%len(openKPMGList)
200 print "closed list %s"%len(closedList)
201 mwePlate = SplitIntoSections(openMWEList)
202 kpmgPlate = SplitIntoSections(openKPMGList)
203 closedPlate = SplitIntoSections(closedList)
204
205 headdingList = ["MWE's Plate (%s items)"%len(openMWEList),"KPMG's Plate (%s items)"%len(openKPMGList),"Closed Requests (%s items)"%len(closedList)]
206
207 CreateBaseReport(open(indexFile,'w'))
208 CreateBaseReport(open(kpmgFile,'w'))
209 CreateBaseReport(open(closedFile,'w'))
210 CreateBaseReport(open(projectViewFile,'w'))
211
212 ProcessToHTML(mwePlate,open(indexFile,'a'),headdingList,"MWE's List")
213 ProcessToHTML(kpmgPlate,open(kpmgFile,'a'),headdingList,"KPMG's List")
214 ProcessToHTML(closedPlate,open(closedFile,'a'),headdingList,"Closed List")
215
216 FinishReport(open(indexFile,'a'))
217 FinishReport(open(kpmgFile,'a'))
218 FinishReport(open(closedFile,'a'))
219 FinishReport(open(projectViewFile,'a'))