Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
import sys import elementtree.ElementTree as et users = {} map = et.parse(sys.argv[1]) for node in map.getiterator(): if "user" in node.attrib: user = node.attrib["user"] users.setdefault(user, 0) users[user] += 1 contribs = users.items() contribs.sort(lambda x, y: y[1] - x[1]) # HTML ordered list out = et.fromstring(''' <ol><li><b>Korisnik</b><b>Broj doprinosa</b></li></ol> ''' ) for contrib in contribs: ul = et.SubElement(out, "li") ul.text = "%s, %d"%(contrib[0], contrib[1]) print et.tostring(out)
This paste will be private.
From the Design Piracy series on my blog: