[GRASS-SVN] r42153 - grass/branches/releasebranch_6_4/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 8 07:42:30 EDT 2010


Author: martinl
Date: 2010-05-08 07:42:29 -0400 (Sat, 08 May 2010)
New Revision: 42153

Modified:
   grass/branches/releasebranch_6_4/lib/python/core.py
Log:
pythonlib: implement percent() as wrapper for g.message -p
(merge r42148 from trunk)


Modified: grass/branches/releasebranch_6_4/lib/python/core.py
===================================================================
--- grass/branches/releasebranch_6_4/lib/python/core.py	2010-05-08 11:38:39 UTC (rev 42152)
+++ grass/branches/releasebranch_6_4/lib/python/core.py	2010-05-08 11:42:29 UTC (rev 42153)
@@ -311,6 +311,25 @@
     """
     message(msg, flag = 'i')
 
+def percent(i, n, s):
+    """!Display a progress info message using g.message -p
+    
+    @code
+    message(_("Percent complete..."))
+    n = 100
+    for i in range(n):
+        percent(i, n, 1)
+    percent(1, 1, 1)
+    @endcode
+    
+    @param i current item
+    @param n total number of items
+    @param s increment size
+    
+    @return g.message's exit code
+    """
+    message("%d %d %d" % (i, n, s), flag = 'p')
+
 def warning(msg):
     """!Display a warning message using g.message -w
 



More information about the grass-commit mailing list