[GRASS-SVN] r57914 - grass/trunk/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 2 08:27:45 PDT 2013


Author: annakrat
Date: 2013-10-02 08:27:45 -0700 (Wed, 02 Oct 2013)
New Revision: 57914

Modified:
   grass/trunk/lib/python/script/vector.py
Log:
pythonlib: v.db.select wrapper: do not add key column when we don't want it 

Modified: grass/trunk/lib/python/script/vector.py
===================================================================
--- grass/trunk/lib/python/script/vector.py	2013-10-02 10:12:45 UTC (rev 57913)
+++ grass/trunk/lib/python/script/vector.py	2013-10-02 15:27:45 UTC (rev 57914)
@@ -239,9 +239,11 @@
                   { 'layer' : layer, 'map' : map })
         return { 'columns' : [], 'values' : {} }
         
+    include_key = True
     if 'columns' in kwargs:
         if key not in kwargs['columns'].split(','):
             # add key column if missing
+            include_key = False
             debug("Adding key column to the output")
             kwargs['columns'] += ',' + key
     
@@ -260,11 +262,18 @@
         if not columns:
             columns = line.split('|')
             key_index = columns.index(key)
+            # discard key column
+            if not include_key:
+                 columns = columns[:-1]
             continue
         
         value = line.split('|')
         key_value = int(value[key_index])
-        values[key_value] = line.split('|')
+        if not include_key:
+            # discard key column
+            values[key_value] = value[:-1]
+        else:
+            values[key_value] = value
     
     return { 'columns' : columns,
              'values' : values }



More information about the grass-commit mailing list