瀏覽代碼

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__

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54947 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 12 年之前
父節點
當前提交
e378bad5d6
共有 1 個文件被更改,包括 3 次插入4 次删除
  1. 3 4
      lib/python/pygrass/vector/geometry.py

+ 3 - 4
lib/python/pygrass/vector/geometry.py

@@ -133,7 +133,7 @@ class Attrs(object):
         self.cond = "%s=%d" % (self.table.key, self.line)
         self.cond = "%s=%d" % (self.table.key, self.line)
         self.writable = writable
         self.writable = writable
 
 
-    def __getitem__(self, *args):
+    def __getitem__(self, key):
         """Return the value stored in the attribute table. ::
         """Return the value stored in the attribute table. ::
 
 
             >>> from grass.pygrass.vector import VectorTopo
             >>> from grass.pygrass.vector import VectorTopo
@@ -147,12 +147,11 @@ class Attrs(object):
 
 
         """
         """
         #SELECT {cols} FROM {tname} WHERE {condition};
         #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,
                                                          tname=self.table.name,
                                                          condition=self.cond))
                                                          condition=self.cond))
         results = cur.fetchone()
         results = cur.fetchone()
-        return results[0] if len(cols) == 1 else results
+        return results[0]
 
 
     def __setitem__(self, key, value):
     def __setitem__(self, key, value):
         """Set value of a given column of a table attribute. ::
         """Set value of a given column of a table attribute. ::