[py3k] tuple unpacking in function args
authorSamuel Trégouët <samuel.tregouet@logilab.fr>
Fri, 11 Sep 2015 16:01:10 +0200
changeset 10593 03ce3d24db87
parent 10592 dfa1dcf4d7f1
child 10594 6a55853f14c9
[py3k] tuple unpacking in function args
rset.py
sobjects/supervising.py
web/http_headers.py
web/views/autoform.py
web/views/startup.py
--- a/rset.py	Fri Sep 11 15:52:18 2015 +0200
+++ b/rset.py	Fri Sep 11 16:01:10 2015 +0200
@@ -215,10 +215,10 @@
         rset = self.copy(rows, descr)
         if col >= 0:
             entities = sorted(enumerate(self.entities(col)),
-                              key=lambda (i, e): keyfunc(e), reverse=reverse)
+                              key=lambda t: keyfunc(t[1]), reverse=reverse)
         else:
             entities = sorted(enumerate(self),
-                              key=lambda (i, e): keyfunc(e), reverse=reverse)
+                              key=lambda t: keyfunc(t[1]), reverse=reverse)
         for index, _ in entities:
             rows.append(self.rows[index])
             descr.append(self.description[index])
--- a/sobjects/supervising.py	Fri Sep 11 15:52:18 2015 +0200
+++ b/sobjects/supervising.py	Fri Sep 11 16:01:10 2015 +0200
@@ -128,13 +128,15 @@
         # XXX print changes
         self.w(u'  %s' % changedescr.entity.absolute_url())
 
-    def delete_entity(self, (eid, etype, title)):
+    def delete_entity(self, args):
+        eid, etype, title = args
         msg = self._cw._('deleted %(etype)s #%(eid)s (%(title)s)')
         etype = display_name(self._cw, etype).lower()
         self.w(msg % locals())
 
-    def change_state(self, (entity, fromstate, tostate)):
+    def change_state(self, args):
         _ = self._cw._
+        entity, fromstate, tostate = args
         msg = _('changed state of %(etype)s #%(eid)s (%(title)s)')
         self.w(u'%s\n' % (msg % self._entity_context(entity)))
         self.w(_('  from state %(fromstate)s to state %(tostate)s\n' %
--- a/web/http_headers.py	Fri Sep 11 15:52:18 2015 +0200
+++ b/web/http_headers.py	Fri Sep 11 16:01:10 2015 +0200
@@ -766,7 +766,8 @@
             v = [field.strip().lower() for field in v.split(',')]
     return k, v
 
-def generateCacheControl((k, v)):
+def generateCacheControl(args):
+    k, v = args
     if v is None:
         return str(k)
     else:
--- a/web/views/autoform.py	Fri Sep 11 15:52:18 2015 +0200
+++ b/web/views/autoform.py	Fri Sep 11 16:01:10 2015 +0200
@@ -490,7 +490,8 @@
     pendings.remove( (int(eidfrom), rel, int(eidto)) )
 
 @ajaxfunc(output_type='json')
-def remove_pending_insert(self, (eidfrom, rel, eidto)):
+def remove_pending_insert(self, args):
+    eidfrom, rel, eidto = args
     _remove_pending(self._cw, eidfrom, rel, eidto, 'insert')
 
 @ajaxfunc(output_type='json')
@@ -499,11 +500,13 @@
         _add_pending(self._cw, eidfrom, rel, eidto, 'insert')
 
 @ajaxfunc(output_type='json')
-def remove_pending_delete(self, (eidfrom, rel, eidto)):
+def remove_pending_delete(self, args):
+    eidfrom, rel, eidto = args
     _remove_pending(self._cw, eidfrom, rel, eidto, 'delete')
 
 @ajaxfunc(output_type='json')
-def add_pending_delete(self, (eidfrom, rel, eidto)):
+def add_pending_delete(self, args):
+    eidfrom, rel, eidto = args
     _add_pending(self._cw, eidfrom, rel, eidto, 'delete')
 
 
--- a/web/views/startup.py	Fri Sep 11 15:52:18 2015 +0200
+++ b/web/views/startup.py	Fri Sep 11 16:01:10 2015 +0200
@@ -106,7 +106,7 @@
 
     def entity_types_table(self, eschemas):
         infos = sorted(self.entity_types(eschemas),
-                       key=lambda (l,a,e): unormalize(l))
+                       key=lambda t: unormalize(t[0]))
         q, r = divmod(len(infos), 2)
         if r:
             infos.append( (None, '&#160;', '&#160;') )