Skip to content

Instantly share code, notes, and snippets.

@benui-dev
Created January 20, 2012 00:38
Show Gist options
  • Select an option

  • Save benui-dev/1644071 to your computer and use it in GitHub Desktop.

Select an option

Save benui-dev/1644071 to your computer and use it in GitHub Desktop.
Print the entire tree of a Wiki article using mwlib
# Print the entire tree of a Wiki article using mwlib
from mwlib import wiki
from mwlib.parser import nodes
def print_tree(node, indent):
tabs = indent * " "
print tabs + node.__class__.__name__
indent += 1
for child in node.children:
print_tree(child, indent)
env = wiki.makewiki('/home/ben/wiki/simple/wikiconf.txt')
a = env.wiki.getParsedArticle('mathematics')
print_tree(a, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment