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

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