[GRASS-SVN] r54947 - grass/trunk/lib/python/pygrass/vector

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 6 00:47:57 PST 2013


Author: zarch
Date: 2013-02-06 00:47:57 -0800 (Wed, 06 Feb 2013)
New Revision: 54947

Modified:
   grass/trunk/lib/python/pygrass/vector/geometry.py
Log:
Change the behaviour not support multiple kys because it is not consistent with python dictionary and it was not possible to be consistent with the __setitem__

Modified: grass/trunk/lib/python/pygrass/vector/geometry.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/geometry.py	2013-02-06 03:14:39 UTC (rev 54946)
+++ grass/trunk/lib/python/pygrass/vector/geometry.py	2013-02-06 08:47:57 UTC (rev 54947)
@@ -133,7 +133,7 @@
         self.cond = "%s=%d" % (self.table.key, self.line)
         self.writable = writable
 
-    def __getitem__(self, *args):
+    def __getitem__(self, key):
         """Return the value stored in the attribute table. ::
 
             >>> from grass.pygrass.vector import VectorTopo
@@ -147,12 +147,11 @@
 
         """
         #SELECT {cols} FROM {tname} WHERE {condition};
-        cols = args if isinstance(args[0], str) else args[0]
-        cur = self.table.execute(sql.SELECT_WHERE.format(cols=','.join(cols),
+        cur = self.table.execute(sql.SELECT_WHERE.format(key,
                                                          tname=self.table.name,
                                                          condition=self.cond))
         results = cur.fetchone()
-        return results[0] if len(cols) == 1 else results
+        return results[0]
 
     def __setitem__(self, key, value):
         """Set value of a given column of a table attribute. ::



More information about the grass-commit mailing list