comparison hgext/churn.py @ 7076:c29d3f4ed967

churn: py2.3 compatibility fix - generator expressions appeared in py2.4 - sort doesn't have any arguments except sorting function
author Alexander Solovyov <piranha@piranha.org.ua>
date Fri, 10 Oct 2008 15:53:49 +0300
parents 2627ef59195d
children 9df67ee30ef5
comparison
equal deleted inserted replaced
7075:6db6f6db026a 7076:c29d3f4ed967
151 151
152 rate = countrate(ui, repo, amap, *pats, **opts).items() 152 rate = countrate(ui, repo, amap, *pats, **opts).items()
153 if not rate: 153 if not rate:
154 return 154 return
155 155
156 keyfn = (not opts.get('sort')) and (lambda (k,v): (v,k)) or None 156 sortfn = ((not opts.get('sort')) and (lambda a, b: cmp(b[1], a[1])) or None)
157 rate.sort(key=keyfn, reverse=not opts.get('sort')) 157 rate.sort(sortfn)
158 158
159 maxcount = float(max(v for k, v in rate)) 159 maxcount = float(max([v for k, v in rate]))
160 maxname = max(len(k) for k, v in rate) 160 maxname = max([len(k) for k, v in rate])
161 161
162 ttywidth = get_tty_width() 162 ttywidth = get_tty_width()
163 ui.debug(_("assuming %i character terminal\n") % ttywidth) 163 ui.debug(_("assuming %i character terminal\n") % ttywidth)
164 width = ttywidth - maxname - 2 - 6 - 2 - 2 164 width = ttywidth - maxname - 2 - 6 - 2 - 2
165 165