hgweb: simplify return value creation in for navgen
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 14 Jan 2013 16:52:35 +0100
changeset 18388 083daee1b749
parent 18387 39616410aa32
child 18389 82572533bc00
hgweb: simplify return value creation in for navgen We now have access to better syntax allowing a clearer version.
mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py	Thu Jan 10 18:55:50 2013 +0100
+++ b/mercurial/hgweb/webutil.py	Mon Jan 14 16:52:35 2013 +0100
@@ -70,13 +70,9 @@
     except error.RepoError:
         pass
 
-    def gen(l):
-        def f(**map):
-            for label, node in l:
-                yield {"label": label, "node": node}
-        return f
-
-    return (dict(before=gen(navbefore), after=gen(navafter)),)
+    data = lambda i: {"label": i[0], "node": i[1]}
+    return ({'before': lambda **map: (data(i) for i in navbefore),
+             'after':  lambda **map: (data(i) for i in navafter)},)
 
 def _siblings(siblings=[], hiderev=None):
     siblings = [s for s in siblings if s.node() != nullid]