ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/IssueTrackerReporter.py
Revision: 506
Committed: Tue Jan 14 21:38:26 2014 UTC (12 years, 2 months ago) by nino.borges
Content type: text/x-python
File size: 15948 byte(s)
Log Message:
Started adding the small menu to the project list.

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