From b4cb35d3ab73d50881b2ebac0a4368baf84ca2b7 Mon Sep 17 00:00:00 2001 From: Gianluca Montecchi Date: Thu, 8 Oct 2009 01:17:03 +0200 Subject: Partially moved to a newer, better and simpler template system --- becommands/html.py | 148 +++++++++++++++++++++++++---------------------------- 1 file changed, 70 insertions(+), 78 deletions(-) (limited to 'becommands/html.py') 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 = """ @@ -404,14 +404,26 @@ class BEHTMLGen(): - - + +
Active BugsInactive BugsActive BugsInactive Bugs
- """ % self.bd.encoding + + %s + + +
+ + + + + + + + """ self.bug_line =""" @@ -423,7 +435,7 @@ class BEHTMLGen(): """ - self.detail_first = """ + self.detail_file = """ @@ -437,30 +449,32 @@ class BEHTMLGen():

BugsEverywhere Bug List

-
Back to Index
+
Back to Index

Bug: _bug_id_

- """ % self.bd.encoding - self.detail_line =""" - - - - """ + %s + - self.index_last = """
%s%s
-
- - - +
Back to Index
+ + """ + self.detail_line =""" + + %s%s + + """ + + + self.comment_section = """ """ @@ -476,17 +490,7 @@ class BEHTMLGen(): """ - - self.detail_last = """ - - - -
Back to Index
- - - - """ - + 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 += """
""" - 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("
") + 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("\n") # close every remaining