[Mpuls-commits] r4205 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 16 20:39:05 CET 2010


Author: bh
Date: 2010-11-16 20:39:04 +0100 (Tue, 16 Nov 2010)
New Revision: 4205

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/export.py
Log:
* mpulsweb/lib/export.py (Table): New.  Extracted from CSVTable to
contain the code useful for both XLS and CSV tables.
(CSVTable): Inherit the new Table class.  Remove methods now
defined in the base class.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-11-16 19:25:26 UTC (rev 4204)
+++ base/trunk/ChangeLog	2010-11-16 19:39:04 UTC (rev 4205)
@@ -1,5 +1,12 @@
 2010-11-16  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/lib/export.py (Table): New.  Extracted from CSVTable to
+	contain the code useful for both XLS and CSV tables.
+	(CSVTable): Inherit the new Table class.  Remove methods now
+	defined in the base class.
+
+2010-11-16  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/export.py (Export): Move more to be beginning of
 	the file to start a section with base classes for the export
 	functionality shared by the XLS and CSV exports.

Modified: base/trunk/mpulsweb/lib/export.py
===================================================================
--- base/trunk/mpulsweb/lib/export.py	2010-11-16 19:25:26 UTC (rev 4204)
+++ base/trunk/mpulsweb/lib/export.py	2010-11-16 19:39:04 UTC (rev 4205)
@@ -55,8 +55,27 @@
     pass
 
 
+class Table(object):
 
+    """A single Table for tabular output formats like XLS or CSV"""
 
+    def __init__(self, columns):
+        """Initialize the table.
+        The parameter columns is a list defining the column names"""
+        self.title = title
+        self.columns = columns
+        self.rows = []
+
+    def append(self, row):
+        """Append a row to the table.
+        The parameter row should be a dictionary mapping column names to
+        values.
+        """
+        self.rows.append(row)
+
+
+
+
 def to_str(x):
     t = type(x)
     if t in (IntType, LongType):
@@ -177,23 +196,10 @@
             out.real_close()
 
 
-class CSVTable:
+class CSVTable(Table):
 
     """A single Table that can be serialized as CSV"""
 
-    def __init__(self, columns):
-        """Initialize the table.
-        The parameter columns is a list defining the column names"""
-        self.columns = columns
-        self.rows = []
-
-    def append(self, row):
-        """Append a row to the table.
-        The parameter row should be a dictionary mapping column names to
-        values.
-        """
-        self.rows.append(row)
-
     def serialize(self, sep):
         """Return the table as a string in CSV format.
 



More information about the Mpuls-commits mailing list