ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/IssueTrackerReporter.py
Revision: 514
Committed: Sat Jan 18 20:21:26 2014 UTC (12 years, 2 months ago) by nino.borges
Content type: text/x-python
File size: 19642 byte(s)
Log Message:
Refactored

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 nino.borges 514 import os
12 nino.borges 499
13 nino.borges 514 def CreateBaseReport(outputFile,cssLocation="main.css"):
14 nino.borges 499 """Creates the top of the HTML file"""
15 nino.borges 502 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 nino.borges 514 <meta name="author" content="Emanuel Borges">""")
23     outputFile.write(' <link rel="stylesheet" type="text/css" href="%s" title="ITO Report" media="all" />'%cssLocation)
24     outputFile.write("""
25 nino.borges 502 <title>ITO Report</title>
26     </head>
27    
28     <body>
29     <div id="containerfull"><!-- Use"containerfull" for 100% width. For fixed width, use "container980", "container760" or "container600" (the number is the layout width in pixels). -->
30     <div id="header">
31     <h1><a href="index.html">ITO Report</a></h1>
32     <h2>Report gathered from Issue Tracking Object.</h2>
33     </div>
34 nino.borges 499 """)
35 nino.borges 502 outputFile.close()
36 nino.borges 499 def FinishReport(outputFile):
37     """Creates the bottom of the HTML file"""
38 nino.borges 502 outputFile.write("""
39 nino.borges 499
40 nino.borges 502 <div class="clear">&nbsp;</div>
41     </div>
42     <div class="clear">&nbsp;</div>
43     </div>
44     <div id="footer">
45     <div id="footersections">
46     <div class="half">
47     <h2>Footer area #1</h2>
48     <p>manny test.</p>
49     </div>
50     <div class="quarter">
51     <h2>Footer area #2</h2>
52     <p>manny test 2.</p>
53     <p>Paragraphs and <a href="#">links</a> work here too.</p>
54     </div>
55     <div class="lastquarter">
56     <h2>Footer menu</h2>
57     <ul>
58     <li><a href="#">Link #1</a></li>
59     <li><a href="#">Link #2</a></li>
60     </ul>
61     </div>
62     <div class="clear">&nbsp;</div>
63     </div>
64     </div>
65     <div id="credits">
66     <p>&copy; 2014 Emanuel Borges<br />
67     </div>
68     </div>
69     </body>
70     </html>
71     """)
72     outputFile.close()
73    
74 nino.borges 505 def GetProjectList(mwePlate,kpmgPlate,closedPlate,outputFile,headdingList):
75 nino.borges 504 """Combines the plates (not lists) into the project list, so that you can populate the project view"""
76     ## cycle through the 2 open lists and only pull from the closed list, if the proj exists in the first two.
77     ## Everything should already be in a matrix by catagory.
78     projectMatrix = {}
79     for i in mwePlate.keys():
80 nino.borges 505 for p in mwePlate[i]:
81     project = p[3]
82     if project == '""':
83     project = "Tasks"
84     if project in projectMatrix.keys():
85     projectMatrix[project].append(["MWE",p])
86     else:
87     projectMatrix[project] = [["MWE",p],]
88 nino.borges 504 for i in kpmgPlate.keys():
89 nino.borges 505 for p in kpmgPlate[i]:
90     project = p[3]
91     if project=='""':
92     project = "Tasks"
93     if project in projectMatrix.keys():
94     projectMatrix[project].append(["KPMG",p])
95     else:
96     projectMatrix[project] = [["KPMG",p],]
97     for i in closedPlate.keys():
98     for p in closedPlate[i]:
99     project = p[3]
100     if project in projectMatrix.keys():
101     projectMatrix[project].append(["Closed",p])
102     outputFile.write("""
103     <div id="menu">
104     <ul>
105     """)
106     outputFile.write('<li><a href="index2.html">%s</a></li>\n'% headdingList[0])
107     outputFile.write('<li><a href="KPMGs_Plate.html">%s</a></li>\n'% headdingList[1])
108     outputFile.write('<li><a href="Closed_Items.html">%s</a></li>\n'% headdingList[2])
109     outputFile.write("""
110     <li><a class="current" href="Project_View.html">Project View</a></li>
111     </ul>
112     </div>
113    
114     <div id="feature">
115     <div class="left">
116     <h2>About the Project View</h2>
117     <p>The project view takes the open items and formats them as a "project".</p>
118     </div>
119     <div class="clear">&nbsp;</div>
120     </div>
121     <div id="main">
122 nino.borges 506 <div id="sidebar">
123     <div class="sidebarbox">
124 nino.borges 507 <h2>Project Menu</h2>
125 nino.borges 506 <ul class="sidemenu">\n""")
126 nino.borges 507 for p in projectMatrix.keys():
127     prj = p.replace('"','')
128     outputFile.write(' <li><a href="#%s">%s</a></li>\n'%(prj,prj))
129 nino.borges 506 outputFile.write(""" </ul>
130     </div>
131    
132     <div class="sidebarbox">
133     <h2>Text box</h2>
134     <p>Important links:</p>
135     <ul>
136     <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
137     <li><a href="#">Another</a></li>
138     </ul>
139     </div>
140     </div>
141    
142 nino.borges 505 <div id="content">""")
143 nino.borges 504 for p in projectMatrix.keys():
144 nino.borges 507 prj = p.replace('"','')
145     outputFile.write('<ul><li id="%s">%s<ul>'%(prj,prj))
146 nino.borges 505 for i in projectMatrix[p]:
147     if i[0] == "Closed":
148     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]))
149     else:
150     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]))
151     outputFile.write("</ul></li></ul><hr 40%>")
152     outputFile.write("""</div></div>""")
153     outputFile.close()
154 nino.borges 504
155    
156 nino.borges 499 def SplitIntoPlates(exportFile):
157     openMWEList = []
158     openKPMGList = []
159     closedList = []
160    
161     contents = open(exportFile).readlines()
162     contents = contents[1:]
163    
164     for line in contents:
165     line = line.replace("\n","")
166     ID = line.split(",")[0]
167     ID = ID.replace('"',"")
168     if ID.isalpha():
169     pass
170     else:
171     KPMGStatus = line.split(",")[2]
172     MWEStatus = line.split(",")[3]
173 nino.borges 501 if KPMGStatus in ['"Resolved"', '"Sent to MWE"','"Closed"','"Transmit to Counsel"'] :
174     if MWEStatus in ['"Resolved"','"Closed"']:
175 nino.borges 499 closedList.append(line)
176     else:
177     openMWEList.append(line)
178     else:
179     openKPMGList.append(line)
180     return openMWEList,openKPMGList, closedList
181    
182     def SplitIntoSections(currentList):
183     """Splits into sections and returns matrix"""
184     matrix = {}
185     for i in currentList:
186     i = i.split(",")
187     writeList = [i[0],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]]
188     issueType = i[1]
189     issueType = issueType.replace('"',"")
190     if issueType in matrix.keys():
191     matrix[issueType].append(writeList)
192     else:
193     matrix[issueType] = [writeList,]
194     return matrix
195 nino.borges 502
196     def ProcessToHTML(currentMatrix,outputFile,headdingList,part):
197 nino.borges 499 """Converts the lists into HTML tables"""
198 nino.borges 502 outputFile.write("""
199     <div id="menu">
200     <ul>
201     """)
202     if part[:3] == "MWE":
203     outputFile.write('<li><a class="current" href="index2.html">%s</a></li>\n'% headdingList[0])
204 nino.borges 503 outputFile.write('<li><a href="KPMGs_Plate.html">%s</a></li>\n'% headdingList[1])
205     outputFile.write('<li><a href="Closed_Items.html">%s</a></li>\n'% headdingList[2])
206 nino.borges 502 outputFile.write("""
207     <li><a href="Project_View.html">Project View</a></li>
208     </ul>
209     </div>
210 nino.borges 499
211 nino.borges 502 <div id="feature">
212     <div class="left">
213     <h2>About the MWE Plate</h2>
214     <p>These are all of the tasks and projects, broken out by Issue type, that are currently assigned to the MWE team.</p>
215     </div>
216     <div class="clear">&nbsp;</div>
217     </div>
218     <div id="main">
219     <div id="sidebar">
220     <div class="sidebarbox">
221     <h2>Issue menu</h2>
222     <ul class="sidemenu">\n""")
223     for section in currentMatrix.keys():
224     outputFile.write(' <li><a href="#%s">%s</a></li>\n'%(section,section))
225     outputFile.write(""" </ul>
226     </div>
227    
228 nino.borges 505 <div class="sidebarbox">
229     <h2>Text box</h2>
230     <p>Important links:</p>
231     <ul>
232     <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
233     <li><a href="#">Another</a></li>
234     </ul>
235     </div>
236     </div>
237 nino.borges 502
238     <div id="content">
239     """)
240     for section in currentMatrix.keys():
241     outputFile.write('<h3 id="%s">%s</h3>\n'%(section,section))
242     outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=95%>\n")
243     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>")
244     for x in currentMatrix[section]:
245     outputFile.write("<tr>\n")
246 nino.borges 514 count = 0
247 nino.borges 502 for y in x:
248 nino.borges 514 if count == 0:
249     outputFile.write('<td><a href="data/%s.html">%s</a></td>'%(y.replace('"',""),y))
250     else:
251     outputFile.write("<td>%s</td>"%y)
252     count = count + 1
253 nino.borges 502 outputFile.write("</tr>\n")
254     outputFile.write("</table></center><br><br>\n")
255    
256     elif part[:3] == "KPM":
257 nino.borges 503 outputFile.write('<li><a href="index2.html">%s</a></li>\n'% headdingList[0])
258     outputFile.write('<li><a class="current" href="KPMGs_Plate.html">%s</a></li>\n'% headdingList[1])
259     outputFile.write('<li><a href="Closed_Items.html">%s</a></li>\n'% headdingList[2])
260     outputFile.write("""
261     <li><a href="Project_View.html">Project View</a></li>
262     </ul>
263     </div>
264    
265     <div id="feature">
266     <div class="left">
267     <h2>About the KPMG Plate</h2>
268     <p>These are all of the tasks and projects, broken out by Issue type, that are currently assigned to the KPMG team.</p>
269     </div>
270     <div class="clear">&nbsp;</div>
271     </div>
272     <div id="main">
273     <div id="sidebar">
274     <div class="sidebarbox">
275     <h2>Issue menu</h2>
276     <ul class="sidemenu">\n""")
277     for section in currentMatrix.keys():
278     outputFile.write(' <li><a href="#%s">%s</a></li>\n'%(section,section))
279     outputFile.write(""" </ul>
280     </div>
281    
282 nino.borges 505 <div class="sidebarbox">
283     <h2>Text box</h2>
284     <p>Important links:</p>
285     <ul>
286     <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
287     <li><a href="#">Another</a></li>
288     </ul>
289     </div>
290     </div>
291 nino.borges 503
292     <div id="content">
293     """)
294     for section in currentMatrix.keys():
295     outputFile.write('<h3 id="%s">%s</h3>\n'%(section,section))
296     outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=95%>\n")
297     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>")
298     for x in currentMatrix[section]:
299     outputFile.write("<tr>\n")
300 nino.borges 514 count = 0
301 nino.borges 503 for y in x:
302 nino.borges 514 if count == 0:
303     outputFile.write('<td><a href="data/%s.html">%s</a></td>'%(y.replace('"',""),y))
304     else:
305     outputFile.write("<td>%s</td>"%y)
306     count = count + 1
307 nino.borges 503 outputFile.write("</tr>\n")
308     outputFile.write("</table></center><br><br>\n")
309 nino.borges 502 elif part[:3] == "Clo":
310 nino.borges 503 outputFile.write('<li><a href="index2.html">%s</a></li>\n'% headdingList[0])
311     outputFile.write('<li><a href="KPMGs_Plate.html">%s</a></li>\n'% headdingList[1])
312     outputFile.write('<li><a class="current" href="Closed_Items.html">%s</a></li>\n'% headdingList[2])
313     outputFile.write("""
314     <li><a href="Project_View.html">Project View</a></li>
315     </ul>
316     </div>
317    
318     <div id="feature">
319     <div class="left">
320     <h2>About the Closed Items page</h2>
321     <p>These are all of the tasks and projects, broken out by Issue type, that are currently closed and marked complete.</p>
322     </div>
323     <div class="clear">&nbsp;</div>
324     </div>
325     <div id="main">
326     <div id="sidebar">
327     <div class="sidebarbox">
328     <h2>Issue menu</h2>
329     <ul class="sidemenu">\n""")
330     for section in currentMatrix.keys():
331     outputFile.write(' <li><a href="#%s">%s</a></li>\n'%(section,section))
332     outputFile.write(""" </ul>
333     </div>
334    
335 nino.borges 505 <div class="sidebarbox">
336     <h2>Text box</h2>
337     <p>Important links:</p>
338     <ul>
339     <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
340     <li><a href="#">Another</a></li>
341     </ul>
342     </div>
343     </div>
344 nino.borges 503
345     <div id="content">
346     """)
347     for section in currentMatrix.keys():
348     outputFile.write('<h3 id="%s">%s</h3>\n'%(section,section))
349     outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=95%>\n")
350     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>")
351     for x in currentMatrix[section]:
352     outputFile.write("<tr>\n")
353 nino.borges 514 count = 0
354 nino.borges 503 for y in x:
355 nino.borges 514 if count == 0:
356     outputFile.write('<td><a href="data/%s.html">%s</a></td>'%(y.replace('"',""),y))
357     else:
358     outputFile.write("<td>%s</td>"%y)
359     count = count + 1
360 nino.borges 503 outputFile.write("</tr>\n")
361     outputFile.write("</table></center><br><br>\n")
362 nino.borges 502 else:
363     pass
364     ##
365     ## outputFile.write('<h2>%s</h2>\n'% headdingList[0])
366     ## outputFile.write('''<hr width="40%">''')
367     ## for section in currentMatrix.keys():
368     ## outputFile.write("<h3>%s</h3>\n"%section)
369     ## outputFile.write("<center><table border=1 cellspacing=0 cellpadding=5 width=90%>\n")
370     ## 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>")
371     ## for x in currentMatrix[section]:
372     ## outputFile.write("<tr>\n")
373     ## for y in x:
374     ## outputFile.write("<td>%s</td>"%y)
375     ## outputFile.write("</tr>\n")
376     ## outputFile.write("</table></center>\n")
377     outputFile.close()
378    
379 nino.borges 514 def CreateDetailPages(dataDir,matrix):
380     """Creates all of the indv task detail pages"""
381     for i in matrix.keys():
382     for y in matrix[i]:
383     fileName = "%s.html"%y[0].replace('"','')
384     #fileName = "%s.html"%matrix[i][0][0].replace('"','')
385     outputFile = open(os.path.join(dataDir,fileName),'w')
386     CreateBaseReport(outputFile,"../main.css")
387    
388     outputFile = open(os.path.join(dataDir,fileName),'a')
389     outputFile.write("""
390     <div id="main">
391     <div id="sidebar">
392     <div class="sidebarbox">
393     <h2>Text box</h2>
394     <p>Important links:</p>
395     <ul>
396     <li><a href="https://fts.shs.us.kpmg.com/vpn/index.html">KPMG Relativity</a></li>
397     <li><a href="#">Another</a></li>
398     </ul>
399     </div>
400     </div>
401    
402     <div id="content">
403     """)
404     outputFile.write("<form>")
405     outputFile.write('<label for="id">Object ID:</label><input type="text" name="id" value=" %s" disabled="Disabled"><br><br>'%y[0].replace('"',''))
406     outputFile.write('<label for="kpmgStatus">KPMG Status:</label><input type="text" name="kpmgStatus" placeholder=" %s" disabled><br><br>'%y[1].replace('"',''))
407     outputFile.write('<label for="mweStatus">MWE Status:</label><input type="text" name="mweStatus" placeholder=" %s" disabled><br><br>'%y[2].replace('"',''))
408     outputFile.write('<label for="TE_Prefix">Time Entry Prefix:</label><input type="text" name="TE_Prefix" value=" %s" disabled><br><br>'%y[3].replace('"',''))
409    
410     outputFile.write('<label for="Requestor">Requestor:</label><input type="text" name="Requestor" value=" %s" disabled><br><br>'%y[5].replace('"',''))
411     outputFile.write('<label for="assignedTo">Assigned to:</label><input type="text" name="assignedTo" value=" %s" disabled><br><br>'%y[6].replace('"',''))
412     outputFile.write('<label for="Created">Created:</label><input type="text" name="Created" value=" %s" disabled><br><br>'%y[7].replace('"',''))
413     outputFile.write('<label for="Modified">Last Modified:</label><input type="text" name="Modified" value=" %s" disabled><br><br>'%y[8].replace('"',''))
414     outputFile.write('<label for="TE_Descr">Time Entry Description:</label><br><textarea rows="4" cols="50" name="TE_Descr" disabled>%s</textarea><br>'%y[4].replace('"',''))
415     outputFile.write("</form>")
416     outputFile.close()
417    
418     FinishReport(open(os.path.join(dataDir,fileName),'a'))
419    
420    
421 nino.borges 499 if __name__ == '__main__':
422 nino.borges 514 exportFile = "/Users/ninoborges/Dropbox/Misc/export_20140109_011143.csv"
423     indexFile = "/Users/ninoborges/Documents/ITO_Report/index2.html"
424     kpmgFile = "/Users/ninoborges/Documents/ITO_Report/KPMGs_Plate.html"
425     closedFile = "/Users/ninoborges/Documents/ITO_Report/Closed_Items.html"
426     projectViewFile = "/Users/ninoborges/Documents/ITO_Report/Project_View.html"
427     dataDir = "/Users/ninoborges/Documents/ITO_Report/Data"
428     #exportFile = "T:\honeywell\ITO_Report\Export\export.csv"
429     #indexFile= "T:\honeywell\ITO_Report\index2.html"
430     #kpmgFile = "T:\honeywell\ITO_Report\KPMGs_Plate.html"
431     #closedFile = "T:\honeywell\ITO_Report\Closed_Items.html"
432     #projectViewFile = "T:\honeywell\ITO_Report\Project_View.html"
433     #dataDir =
434 nino.borges 499 openMWEList,openKPMGList, closedList = SplitIntoPlates(exportFile)
435     print "mwe list %s"%len(openMWEList)
436     print "kpmg list %s"%len(openKPMGList)
437     print "closed list %s"%len(closedList)
438     mwePlate = SplitIntoSections(openMWEList)
439     kpmgPlate = SplitIntoSections(openKPMGList)
440     closedPlate = SplitIntoSections(closedList)
441    
442 nino.borges 502 headdingList = ["MWE's Plate (%s items)"%len(openMWEList),"KPMG's Plate (%s items)"%len(openKPMGList),"Closed Requests (%s items)"%len(closedList)]
443    
444 nino.borges 514 CreateDetailPages(dataDir,mwePlate)
445     CreateDetailPages(dataDir,kpmgPlate)
446     CreateDetailPages(dataDir,closedPlate)
447    
448 nino.borges 502 CreateBaseReport(open(indexFile,'w'))
449     CreateBaseReport(open(kpmgFile,'w'))
450     CreateBaseReport(open(closedFile,'w'))
451     CreateBaseReport(open(projectViewFile,'w'))
452    
453     ProcessToHTML(mwePlate,open(indexFile,'a'),headdingList,"MWE's List")
454     ProcessToHTML(kpmgPlate,open(kpmgFile,'a'),headdingList,"KPMG's List")
455     ProcessToHTML(closedPlate,open(closedFile,'a'),headdingList,"Closed List")
456 nino.borges 505 GetProjectList(mwePlate,kpmgPlate,closedPlate,open(projectViewFile,'a'),headdingList)
457 nino.borges 502
458     FinishReport(open(indexFile,'a'))
459     FinishReport(open(kpmgFile,'a'))
460     FinishReport(open(closedFile,'a'))
461 nino.borges 504 FinishReport(open(projectViewFile,'a'))
462 nino.borges 505