ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/IssueTrackerReporter.py
Revision: 505
Committed: Fri Jan 10 15:24:14 2014 UTC (12 years, 2 months ago) by nino.borges
Content type: text/x-python
File size: 15318 byte(s)
Log Message:
Refactored

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 GetProjectList(mwePlate,kpmgPlate,closedPlate,outputFile,headdingList):
74 """Combines the plates (not lists) into the project list, so that you can populate the project view"""
75 ## cycle through the 2 open lists and only pull from the closed list, if the proj exists in the first two.
76 ## Everything should already be in a matrix by catagory.
77 projectMatrix = {}
78 for i in mwePlate.keys():
79 for p in mwePlate[i]:
80 project = p[3]
81 if project == '""':
82 project = "Tasks"
83 if project in projectMatrix.keys():
84 projectMatrix[project].append(["MWE",p])
85 else:
86 projectMatrix[project] = [["MWE",p],]
87 for i in kpmgPlate.keys():
88 for p in kpmgPlate[i]:
89 project = p[3]
90 if project=='""':
91 project = "Tasks"
92 if project in projectMatrix.keys():
93 projectMatrix[project].append(["KPMG",p])
94 else:
95 projectMatrix[project] = [["KPMG",p],]
96 for i in closedPlate.keys():
97 for p in closedPlate[i]:
98 project = p[3]
99 if project in projectMatrix.keys():
100 projectMatrix[project].append(["Closed",p])
101 outputFile.write("""
102 <div id="menu">
103 <ul>
104 """)
105 outputFile.write('<li><a href="index2.html">%s</a></li>\n'% headdingList[0])
106 outputFile.write('<li><a href="KPMGs_Plate.html">%s</a></li>\n'% headdingList[1])
107 outputFile.write('<li><a href="Closed_Items.html">%s</a></li>\n'% headdingList[2])
108 outputFile.write("""
109 <li><a class="current" href="Project_View.html">Project View</a></li>
110 </ul>
111 </div>
112
113 <div id="feature">
114 <div class="left">
115 <h2>About the Project View</h2>
116 <p>The project view takes the open items and formats them as a "project".</p>
117 </div>
118 <div class="clear">&nbsp;</div>
119 </div>
120 <div id="main">
121 <div id="content">""")
122 for p in projectMatrix.keys():
123 outputFile.write("<ul><li>%s<ul>"% p)
124 for i in projectMatrix[p]:
125 if i[0] == "Closed":
126 outputFile.write('<li><table border="1"><tr><td><strike>%s</strike></td><td><strike>%s</strike></td><td><strike>%s</strike></td></tr></table> --- %s</li>'% (i[1][0],i[1][1],i[1][4],i[0]))
127 else:
128 outputFile.write('<li> %s<table border="1"><tr><td>%s</td><td>%s</td><td>%s</td></tr></table></li>'% (i[0],i[1][0],i[1][1],i[1][4]))
129 outputFile.write("</ul></li></ul><hr 40%>")
130 outputFile.write("""</div></div>""")
131 outputFile.close()
132
133
134 def SplitIntoPlates(exportFile):
135 openMWEList = []
136 openKPMGList = []
137 closedList = []
138
139 contents = open(exportFile).readlines()
140 contents = contents[1:]
141
142 for line in contents:
143 line = line.replace("\n","")
144 ID = line.split(",")[0]
145 ID = ID.replace('"',"")
146 if ID.isalpha():
147 pass
148 else:
149 KPMGStatus = line.split(",")[2]
150 MWEStatus = line.split(",")[3]
151 if KPMGStatus in ['"Resolved"', '"Sent to MWE"','"Closed"','"Transmit to Counsel"'] :
152 if MWEStatus in ['"Resolved"','"Closed"']:
153 closedList.append(line)
154 else:
155 openMWEList.append(line)
156 else:
157 openKPMGList.append(line)
158 return openMWEList,openKPMGList, closedList
159
160 def SplitIntoSections(currentList):
161 """Splits into sections and returns matrix"""
162 matrix = {}
163 for i in currentList:
164 i = i.split(",")
165 writeList = [i[0],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]]
166 issueType = i[1]
167 issueType = issueType.replace('"',"")
168 if issueType in matrix.keys():
169 matrix[issueType].append(writeList)
170 else:
171 matrix[issueType] = [writeList,]
172 return matrix
173
174 def ProcessToHTML(currentMatrix,outputFile,headdingList,part):
175 """Converts the lists into HTML tables"""
176 outputFile.write("""
177 <div id="menu">
178 <ul>
179 """)
180 if part[:3] == "MWE":
181 outputFile.write('<li><a class="current" href="index2.html">%s</a></li>\n'% headdingList[0])
182 outputFile.write('<li><a href="KPMGs_Plate.html">%s</a></li>\n'% headdingList[1])
183 outputFile.write('<li><a href="Closed_Items.html">%s</a></li>\n'% headdingList[2])
184 outputFile.write("""
185 <li><a href="Project_View.html">Project View</a></li>
186 </ul>
187 </div>
188
189 <div id="feature">
190 <div class="left">
191 <h2>About the MWE Plate</h2>
192 <p>These are all of the tasks and projects, broken out by Issue type, that are currently assigned to the MWE team.</p>
193 </div>
194 <div class="clear">&nbsp;</div>
195 </div>
196 <div id="main">
197 <div id="sidebar">
198 <div class="sidebarbox">
199 <h2>Issue menu</h2>
200 <ul class="sidemenu">\n""")
201 for section in currentMatrix.keys():
202 outputFile.write(' <li><a href="#%s">%s</a></li>\n'%(section,section))
203 outputFile.write(""" </ul>
204 </div>
205
206 <div class="sidebarbox">
207 <h2>Text box</h2>
208 <p>Important links:</p>
209 <ul>
210 <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
211 <li><a href="#">Another</a></li>
212 </ul>
213 </div>
214 </div>
215
216 <div id="content">
217 """)
218 for section in currentMatrix.keys():
219 outputFile.write('<h3 id="%s">%s</h3>\n'%(section,section))
220 outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=95%>\n")
221 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>")
222 for x in currentMatrix[section]:
223 outputFile.write("<tr>\n")
224 for y in x:
225 outputFile.write("<td>%s</td>"%y)
226 outputFile.write("</tr>\n")
227 outputFile.write("</table></center><br><br>\n")
228
229 elif part[:3] == "KPM":
230 outputFile.write('<li><a href="index2.html">%s</a></li>\n'% headdingList[0])
231 outputFile.write('<li><a class="current" href="KPMGs_Plate.html">%s</a></li>\n'% headdingList[1])
232 outputFile.write('<li><a href="Closed_Items.html">%s</a></li>\n'% headdingList[2])
233 outputFile.write("""
234 <li><a href="Project_View.html">Project View</a></li>
235 </ul>
236 </div>
237
238 <div id="feature">
239 <div class="left">
240 <h2>About the KPMG Plate</h2>
241 <p>These are all of the tasks and projects, broken out by Issue type, that are currently assigned to the KPMG team.</p>
242 </div>
243 <div class="clear">&nbsp;</div>
244 </div>
245 <div id="main">
246 <div id="sidebar">
247 <div class="sidebarbox">
248 <h2>Issue menu</h2>
249 <ul class="sidemenu">\n""")
250 for section in currentMatrix.keys():
251 outputFile.write(' <li><a href="#%s">%s</a></li>\n'%(section,section))
252 outputFile.write(""" </ul>
253 </div>
254
255 <div class="sidebarbox">
256 <h2>Text box</h2>
257 <p>Important links:</p>
258 <ul>
259 <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
260 <li><a href="#">Another</a></li>
261 </ul>
262 </div>
263 </div>
264
265 <div id="content">
266 """)
267 for section in currentMatrix.keys():
268 outputFile.write('<h3 id="%s">%s</h3>\n'%(section,section))
269 outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=95%>\n")
270 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>")
271 for x in currentMatrix[section]:
272 outputFile.write("<tr>\n")
273 for y in x:
274 outputFile.write("<td>%s</td>"%y)
275 outputFile.write("</tr>\n")
276 outputFile.write("</table></center><br><br>\n")
277 elif part[:3] == "Clo":
278 outputFile.write('<li><a href="index2.html">%s</a></li>\n'% headdingList[0])
279 outputFile.write('<li><a href="KPMGs_Plate.html">%s</a></li>\n'% headdingList[1])
280 outputFile.write('<li><a class="current" href="Closed_Items.html">%s</a></li>\n'% headdingList[2])
281 outputFile.write("""
282 <li><a href="Project_View.html">Project View</a></li>
283 </ul>
284 </div>
285
286 <div id="feature">
287 <div class="left">
288 <h2>About the Closed Items page</h2>
289 <p>These are all of the tasks and projects, broken out by Issue type, that are currently closed and marked complete.</p>
290 </div>
291 <div class="clear">&nbsp;</div>
292 </div>
293 <div id="main">
294 <div id="sidebar">
295 <div class="sidebarbox">
296 <h2>Issue menu</h2>
297 <ul class="sidemenu">\n""")
298 for section in currentMatrix.keys():
299 outputFile.write(' <li><a href="#%s">%s</a></li>\n'%(section,section))
300 outputFile.write(""" </ul>
301 </div>
302
303 <div class="sidebarbox">
304 <h2>Text box</h2>
305 <p>Important links:</p>
306 <ul>
307 <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
308 <li><a href="#">Another</a></li>
309 </ul>
310 </div>
311 </div>
312
313 <div id="content">
314 """)
315 for section in currentMatrix.keys():
316 outputFile.write('<h3 id="%s">%s</h3>\n'%(section,section))
317 outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=95%>\n")
318 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>")
319 for x in currentMatrix[section]:
320 outputFile.write("<tr>\n")
321 for y in x:
322 outputFile.write("<td>%s</td>"%y)
323 outputFile.write("</tr>\n")
324 outputFile.write("</table></center><br><br>\n")
325 else:
326 pass
327 ##
328 ## outputFile.write('<h2>%s</h2>\n'% headdingList[0])
329 ## outputFile.write('''<hr width="40%">''')
330 ## for section in currentMatrix.keys():
331 ## outputFile.write("<h3>%s</h3>\n"%section)
332 ## outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=90%>\n")
333 ## 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>")
334 ## for x in currentMatrix[section]:
335 ## outputFile.write("<tr>\n")
336 ## for y in x:
337 ## outputFile.write("<td>%s</td>"%y)
338 ## outputFile.write("</tr>\n")
339 ## outputFile.write("</table></center>\n")
340 outputFile.close()
341
342 if __name__ == '__main__':
343 exportFile = "/Users/ninoborges/Dropbox/Misc/export_20140109_011143.csv"
344 indexFile = "/Users/ninoborges/Documents/ITO_Report/index2.html"
345 kpmgFile = "/Users/ninoborges/Documents/ITO_Report/KPMGs_Plate.html"
346 closedFile = "/Users/ninoborges/Documents/ITO_Report/Closed_Items.html"
347 projectViewFile = "/Users/ninoborges/Documents/ITO_Report/Project_View.html"
348 #exportFile = "T:\honeywell\ITO_Report\Export\export.csv"
349 #indexFile= "T:\honeywell\ITO_Report\index2.html"
350 #kpmgFile = "T:\honeywell\ITO_Report\KPMGs_Plate.html"
351 #closedFile = "T:\honeywell\ITO_Report\Closed_Items.html"
352 #projectViewFile = "T:\honeywell\ITO_Report\Project_View.html"
353 openMWEList,openKPMGList, closedList = SplitIntoPlates(exportFile)
354 print "mwe list %s"%len(openMWEList)
355 print "kpmg list %s"%len(openKPMGList)
356 print "closed list %s"%len(closedList)
357 mwePlate = SplitIntoSections(openMWEList)
358 kpmgPlate = SplitIntoSections(openKPMGList)
359 closedPlate = SplitIntoSections(closedList)
360
361 headdingList = ["MWE's Plate (%s items)"%len(openMWEList),"KPMG's Plate (%s items)"%len(openKPMGList),"Closed Requests (%s items)"%len(closedList)]
362
363 CreateBaseReport(open(indexFile,'w'))
364 CreateBaseReport(open(kpmgFile,'w'))
365 CreateBaseReport(open(closedFile,'w'))
366 CreateBaseReport(open(projectViewFile,'w'))
367
368 ProcessToHTML(mwePlate,open(indexFile,'a'),headdingList,"MWE's List")
369 ProcessToHTML(kpmgPlate,open(kpmgFile,'a'),headdingList,"KPMG's List")
370 ProcessToHTML(closedPlate,open(closedFile,'a'),headdingList,"Closed List")
371 GetProjectList(mwePlate,kpmgPlate,closedPlate,open(projectViewFile,'a'),headdingList)
372
373 FinishReport(open(indexFile,'a'))
374 FinishReport(open(kpmgFile,'a'))
375 FinishReport(open(closedFile,'a'))
376 FinishReport(open(projectViewFile,'a'))
377