diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/listify.py	Thu Oct 15 11:41:26 2009 -0400
@@ -0,0 +1,20 @@
+def listify(listitems, ordered=False):
+    """ return an html list """
+    if not hasattr(listitems, '__iter__'):
+        thelist = ( listitems, )
+    if ordered:
+        tag, invtag = '<ol>\n', '</ol>'
+    else:
+        tag, invtag = '<ul>\n', '</ul>'
+
+    thelist = tag
+    
+    for i in listitems:
+        thelist += ' <li> ' + str(i) + ' <li>\n'
+
+    thelist += invtag
+    return thelist
+
+if __name__ == '__main__':
+    import sys
+    print listify(sys.argv)