Mercurial > hg > config
comparison python/listify.py @ 0:f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
| author | k0s <k0scist@gmail.com> |
|---|---|
| date | Thu, 15 Oct 2009 11:41:26 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f3ab51c79813 |
|---|---|
| 1 def listify(listitems, ordered=False): | |
| 2 """ return an html list """ | |
| 3 if not hasattr(listitems, '__iter__'): | |
| 4 thelist = ( listitems, ) | |
| 5 if ordered: | |
| 6 tag, invtag = '<ol>\n', '</ol>' | |
| 7 else: | |
| 8 tag, invtag = '<ul>\n', '</ul>' | |
| 9 | |
| 10 thelist = tag | |
| 11 | |
| 12 for i in listitems: | |
| 13 thelist += ' <li> ' + str(i) + ' <li>\n' | |
| 14 | |
| 15 thelist += invtag | |
| 16 return thelist | |
| 17 | |
| 18 if __name__ == '__main__': | |
| 19 import sys | |
| 20 print listify(sys.argv) |
