[GRASS-SVN] r42148 - grass/trunk/lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 8 07:28:34 EDT 2010
Author: martinl
Date: 2010-05-08 07:28:34 -0400 (Sat, 08 May 2010)
New Revision: 42148
Modified:
grass/trunk/lib/python/core.py
Log:
pythonlib: implement percent() as wrapper for `g.message -p`
Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py 2010-05-08 11:26:34 UTC (rev 42147)
+++ grass/trunk/lib/python/core.py 2010-05-08 11:28:34 UTC (rev 42148)
@@ -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