Please review this at http://codereview.appspot.com/186207/show

Affected files:
  M trytond/backend/postgresql/database.py
  M trytond/backend/sqlite/database.py


Index: trytond/backend/postgresql/database.py
===================================================================
--- a/trytond/backend/postgresql/database.py
+++ b/trytond/backend/postgresql/database.py
@@ -241,10 +241,8 @@
 class _Cursor(cursor):

     def __build_dict(self, row):
-        res = {}
-        for i in range(len(self.description)):
-            res[self.description[i][0]] = row[i]
-        return res
+        return dict((self.description[i][0], row[i])
+                for i in xrange(len(self.description)))

     def dictfetchone(self):
         row = self.fetchone()
@@ -254,18 +252,12 @@
             return row

     def dictfetchmany(self, size):
-        res = []
         rows = self.fetchmany(size)
-        for row in rows:
-            res.append(self.__build_dict(row))
-        return res
+        return [self.__build_dict(row) for row in rows]

     def dictfetchall(self):
-        res = []
         rows = self.fetchall()
-        for row in rows:
-            res.append(self.__build_dict(row))
-        return res
+        return [self.__build_dict(row) for row in rows]


 class Cursor(CursorInterface):
Index: trytond/backend/sqlite/database.py
===================================================================
--- a/trytond/backend/sqlite/database.py
+++ b/trytond/backend/sqlite/database.py
@@ -233,10 +233,8 @@
 class _Cursor(sqlite.Cursor):

     def __build_dict(self, row):
-        res = {}
-        for i in range(len(self.description)):
-            res[self.description[i][0].strip('"')] = row[i]
-        return res
+        return dict((self.description[i][0], row[i])
+                for i in xrange(len(self.description)))

     def dictfetchone(self):
         row = self.fetchone()
@@ -246,18 +244,12 @@
             return row

     def dictfetchmany(self, size):
-        res = []
         rows = self.fetchmany(size)
-        for row in rows:
-            res.append(self.__build_dict(row))
-        return res
+        return [self.__build_dict(row) for row in rows]

     def dictfetchall(self):
-        res = []
         rows = self.fetchall()
-        for row in rows:
-            res.append(self.__build_dict(row))
-        return res
+        return [self.__build_dict(row) for row in rows]


 class Cursor(CursorInterface):



-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email: [email protected]
Jabber: [email protected]
Website: http://www.b2ck.com/
twitter: http://twitter.com/cedrickrier
identi.ca: http://identi.ca/cedrickrier

Attachment: pgpbliqcil2Wp.pgp
Description: PGP signature

Reply via email to