diff options
author | Gianluca Montecchi <gian@grys.it> | 2009-10-08 01:17:03 +0200 |
---|---|---|
committer | Gianluca Montecchi <gian@grys.it> | 2009-10-08 01:17:03 +0200 |
commit | b4cb35d3ab73d50881b2ebac0a4368baf84ca2b7 (patch) | |
tree | 754316f503819d604f9a32a2939e31b9a36272d8 /becommands/html.py | |
parent | 32a16930caa09094b97069f08d504fa5d0f9514a (diff) | |
download | bugseverywhere-b4cb35d3ab73d50881b2ebac0a4368baf84ca2b7.tar.gz |
Partially moved to a newer, better and simpler template system
Diffstat (limited to 'becommands/html.py')
-rw-r--r-- | becommands/html.py | 148 |
1 files changed, 70 insertions, 78 deletions
diff --git a/becommands/html.py b/becommands/html.py index 084aa64..38b6012 100644 --- a/becommands/html.py +++ b/becommands/html.py @@ -386,7 +386,7 @@ class BEHTMLGen(): } """ - self.index_first = """ + self.index_file = """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> @@ -404,14 +404,26 @@ class BEHTMLGen(): <table> <tr> - <td class="%%s"><a href="index.html">Active Bugs</a></td> - <td class="%%s"><a href="index_inactive.html">Inactive Bugs</a></td> + <td class="%s"><a href="index.html">Active Bugs</a></td> + <td class="%s"><a href="index_inactive.html">Inactive Bugs</a></td> </tr> </table> <table class="table_bug"> <tbody> - """ % self.bd.encoding + + %s + + </tbody> + </table> + + </div> + + <div class="footer">Generated by <a href="http://www.bugseverywhere.org/">BugsEverywhere</a> on %s</div> + + </body> + </html> + """ self.bug_line =""" <tr class="%s-row"> @@ -423,7 +435,7 @@ class BEHTMLGen(): </tr> """ - self.detail_first = """ + self.detail_file = """ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> @@ -437,30 +449,32 @@ class BEHTMLGen(): <div class="main"> <h1>BugsEverywhere Bug List</h1> - <h5><a href="%%s">Back to Index</a></h5> + <h5><a href="%s">Back to Index</a></h5> <h2>Bug: _bug_id_</h2> <table > <tbody> - """ % self.bd.encoding - self.detail_line =""" - <tr> - <td align="right">%s</td><td>%s</td> - </tr> - """ + %s + - self.index_last = """ </tbody> </table> - </div> - - <div class="footer">Generated by <a href="http://www.bugseverywhere.org/">BugsEverywhere</a> on %s</div> - + <h5><a href="%s">Back to Index</a></h5> + <div class="footer">Generated by <a href="http://www.bugseverywhere.org/">BugsEverywhere</a>.</div> </body> </html> + """ + self.detail_line =""" + <tr> + <td align="right">%s</td><td>%s</td> + </tr> + """ + + + self.comment_section = """ """ @@ -476,17 +490,7 @@ class BEHTMLGen(): </td> </tr> """ - - self.detail_last = """ - </tbody> - </table> - </div> - <h5><a href="%s">Back to Index</a></h5> - <div class="footer">Generated by <a href="http://www.bugseverywhere.org/">BugsEverywhere</a>.</div> - </body> - </html> - """ - + if template != None: try: FI = open("%s/style.css"%self.template) @@ -495,39 +499,22 @@ class BEHTMLGen(): except: pass try: - FI = open("%s/index_first.tpl"%self.template) + FI = open("%s/index_file.tpl"%self.template) self.index_first = FI.read() FI.close() except: pass + try: - FI.open("%s/bug_line.tpl"%self.template) - self.bug_line = FI.read() - FI.close() - except: - pass - try: - FI.open("%s/detail_first.tpl"%self.template) + FI.open("%s/detail_file.tpl"%self.template) self.detail_first = FI.read() FI.close() except: pass - try: - FI = open("%s/index_last.tpl"%self.template) - self.index_last = FI.read() - FI.close() - except: - pass - try: - FI = open("%s/detail_last.tpl"%self.template) - self.d_last = FI.read() - FI.close() - except: - pass - - + def create_index_file(self, out_dir_path, summary, bugs, ordered_bug, fileid, encoding): + try: os.stat(out_dir_path) except: @@ -552,34 +539,43 @@ class BEHTMLGen(): if self.verbose: print "Creating active bug index..." FO = codecs.open(out_dir_path+"/index.html", "w", encoding) - FO.write(self.index_first%('td_sel','td_nsel')) if fileid == "inactive": if self.verbose: print "Creating inactive bug index..." FO = codecs.open(out_dir_path+"/index_inactive.html", "w", encoding) - FO.write(self.index_first%('td_nsel','td_sel')) except: raise cmdutil.UsageError, "Cannot create the index.html file." c = 0 t = len(bugs) - 1 + line = "" for l in range(t, -1, -1): if self.verbose: print "Creating bug entry: %s"%escape(bugs[l].uuid[0:3]) - line = self.bug_line%(escape(bugs[l].severity), + line += self.bug_line%(escape(bugs[l].severity), escape(bugs[l].uuid), escape(bugs[l].uuid[0:3]), escape(bugs[l].uuid), escape(bugs[l].status), escape(bugs[l].uuid), escape(bugs[l].severity), escape(bugs[l].uuid), escape(bugs[l].summary), escape(bugs[l].uuid), escape(bugs[l].time_string) ) - FO.write(line) c += 1 if self.verbose: print "\tCreating detail entry for bug: %s"%escape(bugs[l].uuid[0:3]) self.create_detail_file(bugs[l], out_dir_path, fileid, encoding) when = time.ctime() - FO.write(self.index_last%when) + + try: + if fileid == "active": + if self.verbose: + print "Writing active bug index..." + FO.write(self.index_file%(encoding, 'td_sel','td_nsel', line, when)) + if fileid == "inactive": + if self.verbose: + print "Writing inactive bug index..." + FO.write(self.index_file%(encoding,'td_nsel','td_sel', line, when)) + except: + raise cmdutil.UsageError, "Cannot create the index.html file." def create_detail_file(self, bug, out_dir_path, fileid, encoding): @@ -590,28 +586,28 @@ class BEHTMLGen(): except: raise cmdutil.UsageError, "Cannot create the detail html file." - detail_first_ = re.sub('_bug_id_', bug.uuid[0:3], self.detail_first) - if fileid == "active": - FD.write(detail_first_%"../index.html") - if fileid == "inactive": - FD.write(detail_first_%"../index_inactive.html") - - - + detail_file_ = re.sub('_bug_id_', bug.uuid[0:3], self.detail_file) + bug_ = self.bd.bug_from_shortname(bug.uuid) bug_.load_comments(load_full=True) + det_line = "" + det_line += self.detail_line%("ID : ", bug.uuid) + det_line += self.detail_line%("Short name : ", escape(bug.uuid[0:3])) + det_line += self.detail_line%("Severity : ", escape(bug.severity)) + det_line += self.detail_line%("Status : ", escape(bug.status)) + det_line += self.detail_line%("Assigned : ", escape(bug.assigned)) + det_line += self.detail_line%("Target : ", escape(bug.target)) + det_line += self.detail_line%("Reporter : ", escape(bug.reporter)) + det_line += self.detail_line%("Creator : ", escape(bug.creator)) + det_line += self.detail_line%("Created : ", escape(bug.time_string)) + det_line += self.detail_line%("Summary : ", escape(bug.summary)) + det_line += """<tr><td colspan="2"><hr /></td></tr>""" - FD.write(self.detail_line%("ID : ", bug.uuid)) - FD.write(self.detail_line%("Short name : ", escape(bug.uuid[0:3]))) - FD.write(self.detail_line%("Severity : ", escape(bug.severity))) - FD.write(self.detail_line%("Status : ", escape(bug.status))) - FD.write(self.detail_line%("Assigned : ", escape(bug.assigned))) - FD.write(self.detail_line%("Target : ", escape(bug.target))) - FD.write(self.detail_line%("Reporter : ", escape(bug.reporter))) - FD.write(self.detail_line%("Creator : ", escape(bug.creator))) - FD.write(self.detail_line%("Created : ", escape(bug.time_string))) - FD.write(self.detail_line%("Summary : ", escape(bug.summary))) - FD.write("<tr><td colspan=\"2\"><hr /></td></tr>") + if fileid == "active": + FD.write(detail_file_%(encoding, "../index.html", det_line, "../index.html")) + if fileid == "inactive": + FD.write(detail_file_%(encoding, "../index_inactive.html", det_line, "../index_inactive.html")) + FD.write(self.begin_comment_section) tr = [] b = '' @@ -638,10 +634,6 @@ class BEHTMLGen(): stack.pop(-1) FD.write("</div>\n") # close every remaining <div class="comment... FD.write(self.end_comment_section) - if fileid == "active": - FD.write(self.detail_last%"../index.html") - if fileid == "inactive": - FD.write(self.detail_last%"../index_inactive.html") FD.close() |