[GRASS-SVN] r36556 - grass/branches/develbranch_6/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 31 17:44:29 EDT 2009


Author: martinl
Date: 2009-03-31 17:44:29 -0400 (Tue, 31 Mar 2009)
New Revision: 36556

Modified:
   grass/branches/develbranch_6/lib/python/grass.py
Log:
grass.py synchronized with trunk


Modified: grass/branches/develbranch_6/lib/python/grass.py
===================================================================
--- grass/branches/develbranch_6/lib/python/grass.py	2009-03-31 21:42:33 UTC (rev 36555)
+++ grass/branches/develbranch_6/lib/python/grass.py	2009-03-31 21:44:29 UTC (rev 36556)
@@ -19,11 +19,11 @@
 	    shell = (sys.platform == "win32")
 
 	subprocess.Popen.__init__(self, args, bufsize, executable,
-                 stdin, stdout, stderr,
-                 preexec_fn, close_fds, shell,
-                 cwd, env, universal_newlines,
-                 startupinfo, creationflags)
-
+                                  stdin, stdout, stderr,
+                                  preexec_fn, close_fds, shell,
+                                  cwd, env, universal_newlines,
+                                  startupinfo, creationflags)
+        
 PIPE = subprocess.PIPE
 STDOUT = subprocess.STDOUT
 
@@ -216,7 +216,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: `=')
     """
@@ -228,7 +228,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
@@ -542,6 +545,13 @@
     """
     run_command('v.support', map = map, cmdhist = os.environ['CMDLINE'])
 
+# run "v.info -t" and parse output
+
+def vector_info_topo(map):
+    """Return information about a vector map (interface to `v.info -t')."""
+    s = read_command('v.info', flags = 't', map = map)
+    return parse_key_val(s, val_type = int)
+    
 # add raster history
 
 def raster_history(map):



More information about the grass-commit mailing list