import argparse
from fnmatch import fnmatch
import os
+from news import write_if_changed
parser = argparse.ArgumentParser(description='Generate sitemap')
parser.add_argument('-x', '--exclude', action='append',
save_level = level
except StopIteration:
pass
+
+def _tree2html(tree, level=0):
+ indent = " " * level
+ strings = []
+ strings.append(indent + "<ul>")
+
+ level += 1
+ indent2 = " " * level
+
+ for title, subtree in tree:
+ if subtree:
+ strings.append(indent2 + "<li>%s" % title)
+ strings.append(_tree2html(subtree, level+1))
+ strings.append(indent2 + "</li>")
+ else:
+ strings.append(indent2 + "<li>%s</li>" % title)
+
+ strings.append(indent + "</ul>")
+ return '\n'.join(strings)
+
+write_if_changed("sitemap.html", _tree2html(tree[1]))