changeset 493:9b22669a0690

CollectLists: improved sorting of decimal values
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 04 Feb 2010 23:44:49 +0100
parents 000965a6e265
children 1294c1c0ec56 0fc6d8edd693
files data/plugin/macro/CollectLists.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/CollectLists.py	Thu Feb 04 11:05:31 2010 +0100
+++ b/data/plugin/macro/CollectLists.py	Thu Feb 04 23:44:49 2010 +0100
@@ -25,6 +25,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 import operator, re
+from decimal import Decimal, InvalidOperation
 from MoinMoin import wikiutil, search
 from MoinMoin.Page import Page
 from MoinMoin.util.dataset import TupleDataset, Column
@@ -50,9 +51,15 @@
         tmp = []
         for element in line:
             if isinstance(element, tuple):
-                tmp.append(element[1])
+                try:
+                    tmp.append(Decimal(element[1]))
+                except InvalidOperation:
+                    tmp.append(element[1])
             else:
-                tmp.append(element)
+                try:
+                    tmp.append(Decimal(element))
+                except InvalidOperation:
+                    tmp.append(element)
         rows.append(tmp)
     return rows
 
@@ -62,10 +69,11 @@
     """
     table_data = []
     for line in rows:
-        tmp = [(element, element) for element in line]
+        tmp = [(str(element), str(element)) for element in line]
         table_data.append(tmp)
     return table_data
 
+
 def macro_CollectLists(macro, pagename=unicode,
                       align=("left", "center", "right"),
                       column_heading=u'',