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