[Mpuls-commits] r5504 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Oct 27 15:37:50 CEST 2011


Author: ludwig
Date: 2011-10-27 15:37:49 +0200 (Thu, 27 Oct 2011)
New Revision: 5504

Modified:
   base/trunk/mpulsweb/lib/helpers.py
Log:
Issue 2418: formed_number uses precision 0 for integers.
In libmpuls formed_number is used to format. If an integer float is given, it
should be formated as integer, als the normal precision should be used. 


Modified: base/trunk/mpulsweb/lib/helpers.py
===================================================================
--- base/trunk/mpulsweb/lib/helpers.py	2011-10-26 15:35:46 UTC (rev 5503)
+++ base/trunk/mpulsweb/lib/helpers.py	2011-10-27 13:37:49 UTC (rev 5504)
@@ -229,10 +229,17 @@
 # Format functions
 
 def format_number(number, precision=2):
+    if is_integer(number):
+        precision = 0
     fmt = "%%.%sf" % precision
     retval = locale.format(fmt, (number), 1)
     return retval
 
+def is_integer(number):
+    if number == float(int(number)):
+        return True
+    return False
+
 def format_date(dt):
     if dt is None:
         return ''



More information about the Mpuls-commits mailing list