]> git.phdru.name Git - phdru.name/phdru.name.git/blob - gen-sitemap.py
Add gen-sitemap.py
[phdru.name/phdru.name.git] / gen-sitemap.py
1 #! /usr/bin/env python
2
3 import argparse
4 from fnmatch import fnmatch
5 import os
6
7 parser = argparse.ArgumentParser(description='Generate sitemap')
8 parser.add_argument('root_dir', help='Root dicrectory')
9 args = parser.parse_args()
10
11 os.chdir(args.root_dir)
12 fullpath = os.getcwd()
13 fp_len = len(fullpath)
14
15 for dirpath, dirs, files in sorted(os.walk(fullpath)):
16     dirpath = dirpath[fp_len:]
17     if not dirpath:
18         continue
19     parts = dirpath.split('/')
20     level = len(parts) - 2
21     print '    ' * level + parts[-1]