Created the index
authorGianluca Montecchi <gian@grys.it>
Sat, 18 Jul 2009 22:58:14 +0000 (00:58 +0200)
committerGianluca Montecchi <gian@grys.it>
Sat, 18 Jul 2009 22:58:14 +0000 (00:58 +0200)
becommands/html.py
becommands/html_data.py

index df7a99facc83514b7aa78e89bea721b555c46d9c..224c876e7aa2c752c7835a40b2c937fbd161cf47 100644 (file)
@@ -55,19 +55,19 @@ def execute(args, test=False):
     st = {}
     se = {}
     stime = {}
+    bugs = []
     for s in status_list:
         st[s] = 0
-    for s in severity_list:
-        se[s] = 0
-    
     for b in bd:
         stime[b.uuid]  = b.time
+        if b.status == "open":
+            bugs.append(b)
         st[b.status] += 1
-        se[b.severity] += 1
-    stime_sorted = sorted([(value,key) for (key,value) in stime.items()])
-
+    ordered_bug_list = sorted([(value,key) for (key,value) in stime.items()])
+    #open_bug_list = sorted([(value,key) for (key,value) in bugs.items()])
+    
     html_gen = BEHTMLGen()
-    html_gen.create_index_file(out_dir,  st,  se,  stime_sorted)
+    html_gen.create_index_file(out_dir,  st, bugs, ordered_bug_list)
     
 def get_parser():
     parser = cmdutil.CmdOptionParser("be open OUTPUT_DIR")
@@ -85,7 +85,7 @@ class BEHTMLGen():
     def __init__(self):
         self.index_value = ""        
         
-    def create_index_file(self, out_dir_path,  summary,  severity,  last_bug):
+    def create_index_file(self, out_dir_path,  summary,  bugs, ordered_bug):
         try:
             os.stat(out_dir_path)
         except:
@@ -99,38 +99,52 @@ class BEHTMLGen():
             FO.close()
         except:
             raise  cmdutil.UsageError, "Cannot create the style.css file."
-        value = html_index
-        for stat in summary:
-            rep = "_"+stat+"_"
-            val = str(summary[stat])
-            value = re.sub(rep,  val,  value)
-        for sev in severity:
-            rep = "_"+sev+"_"
-            val = str(severity[sev])
-            value = re.sub(rep,  val, value)
         
+        try:
+            os.mkdir(out_dir_path+"/bugs")
+        except:
+            pass
+        
+        try:
+            FO = open(out_dir_path+"/index.html", "w")
+        except:
+            raise  cmdutil.UsageError, "Cannot create the index.html file."
+        
+        FO.write(index_first)
         c = 0
-        t = len(last_bug)-1
+        t = len(bugs) - 1
         for l in range(t,  0,  -1):
-            line = ""
-            line = re.sub('_BUG_ID_', last_bug[l][1], last_activity)
-            line1 = re.sub('_BUG_', last_bug[l][1][0:3], line)
-            line2 = re.sub('_DATE_',  time.ctime(last_bug[l][0]),  line1)
+            line = bug_line
+            line1 = re.sub('_bug_id_link_', bugs[l].uuid, line)
+            line = line1
+            line1 = re.sub('_bug_id_', bugs[l].uuid[0:3], line)
+            line = line1
+            line1 = re.sub('_status_', bugs[l].status, line)
+            line = line1
+            line1 = re.sub('_sev_', bugs[l].severity, line)
+            line = line1
+            line1 = re.sub('_descr_', bugs[l].summary, line)
+            line = line1
+            line2 = re.sub('_time_',  time.ctime(bugs[l].time),  line1)
             if c%2 == 0:
                 linef = re.sub('_ROW_',  "even-row",  line2)
             else:
                 linef = re.sub('_ROW_',  "odd-row",  line2)
-            self.index_value += linef
+            FO.write(linef)
             c += 1
-            if c == 10:
-                break
-        
-        value = re.sub("_LAST_ACTVITY_", self.index_value, value)
+            self.CreateDetailFile(bugs[l], out_dir_path)
+        FO.write(index_last)
 
+
+    def CreateDetailFile(self, bug, out_dir_path):
+        f = "%s.html"%bug.uuid
+        p = out_dir_path+"/bugs/"+f
         try:
-            FO = open(out_dir_path+"/index.html", "w")
-            FO.write(value)
-            FO.close()
+            FD = open(p, "w")
         except:
-            raise  cmdutil.UsageError, "Cannot create the index.html file."
-            
+            raise  cmdutil.UsageError, "Cannot create the detail html file."
+        
+        FD.write(index_first)
+        
+        FD.write(index_last)
+        FD.close()
\ No newline at end of file
index 460daa8297bb75090b8cd52233ee02947210dc56..f9c966a1ec428500de7fa57140edd4b5f2f24b33 100644 (file)
@@ -18,6 +18,16 @@ margin-top: 1em;
 background-color: #fcfcfc;
 }
 
+.even-row {
+background-color: #e9e9e2;
+width: 5%;
+}
+
+.odd-row {
+
+background-color: #f9f9f9;
+width: 5%;
+}
 
 .person {
 font-family: courier;
@@ -207,7 +217,7 @@ background-color: #ddd;
 }
 """
 
-html_index = """
+index_first = """
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
 <title>BugsEverywhere Issue Tracker</title>
@@ -219,59 +229,32 @@ html_index = """
 
 <div class="main">
 <h1>BugsEverywhere Bug List</h1>
-<table>
+<h2>Open Bugs</h2>
+<table width=100%>
 <tbody>
-<tr>
-<td>
-  <h2>Bugs summary divided by status</h2>
-  <table  width=100%>
-    <tbody>
-        <tr>
-            <td class="plain-cell">
-                <a href="unconfirmed.html">_unconfirmed_ unconfirmed</a>
-            </td>
-            <td class="plain-cell">
-                <a href="open.html">_open_ open</a>
-            </td>
-            <td class="plain-cell">
-                <a href="assigned.html">_assigned_ assigned</a>
-            </td>
-            <td class="plain-cell">
-                <a href="test.html">_test_ test</a>
-            </td>
-            <td class="plain-cell">
-                <a href="closed.html">_closed_ closed</a>
-            </td>
-            <td class="plain-cell">
-                <a href="fixed.html">_fixed_ fixed</a>
-            </td>
-            <td class="plain-cell">
-                <a href="wontfix.html">_wontfix_ wontfix</a>
-            </td>
-            <td class="plain-cell">
-                <a href="disabled.html">_disabled_ disabled</a>
-            </td>
-        </tr>    
-    </tbody>
-  </table>
-</td>
+"""    
+
+bug_line ="""
+<tr class=_ROW_>
+    <td><a href="bugs/_bug_id_link_.html">_bug_id_</a></td>
+    <td><a href="bugs/_bug_id_link_.html">_status_</a></td>
+    <td><a href="bugs/_bug_id_link_.html">_sev_</a></td>
+    <td><a href="bugs/_bug_id_link_.html">_descr_</a></td>
+    <td><a href="bugs/_bug_id_link_.html">_time_</a></td>
 </tr>
+"""
+        
+index_last = """
 </tbody>
 </table>
 
 </div>
 
-<h2>Showing all bugs</h2>
+<h2>Show all bugs</h2>
 
 <div class="footer">Generated by <a href="http://www.bugseverywhere.org/">BugsEverywhere</a>.</div>
 
-
 </body>
 </html>
 """
 
-last_activity = """
-        <tr class="_ROW_">
-            <td><a href="_BUG_ID_.html">_BUG_ on _DATE_</a></td>
-        </tr>
-"""