ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/IssueTrackerReporter.py
Revision: 504
Committed: Thu Jan 9 21:43:30 2014 UTC (12 years, 2 months ago) by nino.borges
Content type: text/x-python
File size: 13323 byte(s)
Log Message:
refactor more

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