comparison mercurial/hgweb/common.py @ 4461:12e4d9524951

hgweb: use generator to count parity of horizontal stripes for easier reading. - use web.stripes in all places and consistently - start with parity0 for lists generated in reverse (e.g. changelog)
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 29 May 2007 16:42:05 +0200
parents 5ae460b1f6f0
children
comparison
equal deleted inserted replaced
4460:3e679426dd7f 4461:12e4d9524951
58 mapfile = os.path.join(templatepath, location) 58 mapfile = os.path.join(templatepath, location)
59 if os.path.isfile(mapfile): 59 if os.path.isfile(mapfile):
60 return mapfile 60 return mapfile
61 raise RuntimeError("No hgweb templates found in %r" % templatepath) 61 raise RuntimeError("No hgweb templates found in %r" % templatepath)
62 62
63 def paritygen(stripecount, offset=0):
64 """count parity of horizontal stripes for easier reading"""
65 if stripecount and offset:
66 # account for offset, e.g. due to building the list in reverse
67 count = (stripecount + offset) % stripecount
68 parity = (stripecount + offset) / stripecount & 1
69 else:
70 count = 0
71 parity = 0
72 while True:
73 yield parity
74 count += 1
75 if stripecount and count >= stripecount:
76 parity = 1 - parity
77 count = 0
78