Created
January 20, 2012 00:38
-
-
Save benui-dev/1644071 to your computer and use it in GitHub Desktop.
Print the entire tree of a Wiki article using mwlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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