[GRASS-SVN] r37116 - grass/branches/releasebranch_6_4/lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 10 14:46:56 EDT 2009
Author: martinl
Date: 2009-05-10 14:46:56 -0400 (Sun, 10 May 2009)
New Revision: 37116
Modified:
grass/branches/releasebranch_6_4/lib/python/grass.py
Log:
grass.region(): cast values to float
(merge trunk, r37114)
Modified: grass/branches/releasebranch_6_4/lib/python/grass.py
===================================================================
--- grass/branches/releasebranch_6_4/lib/python/grass.py 2009-05-10 18:39:56 UTC (rev 37115)
+++ grass/branches/releasebranch_6_4/lib/python/grass.py 2009-05-10 18:46:56 UTC (rev 37116)
@@ -219,7 +219,7 @@
# key-value parsers
-def parse_key_val(s, sep = '=', dflt = None):
+def parse_key_val(s, sep = '=', dflt = None, val_type = None):
"""Parse a string into a dictionary, where entries are separated
by newlines and the key and value are separated by `sep' (default: `=')
"""
@@ -231,7 +231,10 @@
v = kv[1]
else:
v = dflt
- result[k] = v
+ if val_type:
+ result[k] = val_type(v)
+ else:
+ result[k] = v
return result
# interface to g.gisenv
@@ -248,7 +251,7 @@
def region():
"""Returns the output from running "g.region -g", as a dictionary."""
s = read_command("g.region", flags='g')
- return parse_key_val(s)
+ return parse_key_val(s, val_type = float)
def use_temp_region():
"""Copies the current region to a temporary region with "g.region save=",
More information about the grass-commit
mailing list