From 83323dad7ee3deefd87858aa5d93e0bef16c65ae Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 15 Mar 2015 23:29:23 +0300 Subject: [PATCH] Add gen-sitemap.py --- gen-sitemap | 2 ++ gen-sitemap.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 gen-sitemap create mode 100755 gen-sitemap.py diff --git a/gen-sitemap b/gen-sitemap new file mode 100755 index 0000000..c78fcd9 --- /dev/null +++ b/gen-sitemap @@ -0,0 +1,2 @@ +#! /bin/sh +exec ./gen-sitemap.py ../htdocs/phdru.name diff --git a/gen-sitemap.py b/gen-sitemap.py new file mode 100755 index 0000000..d57d422 --- /dev/null +++ b/gen-sitemap.py @@ -0,0 +1,21 @@ +#! /usr/bin/env python + +import argparse +from fnmatch import fnmatch +import os + +parser = argparse.ArgumentParser(description='Generate sitemap') +parser.add_argument('root_dir', help='Root dicrectory') +args = parser.parse_args() + +os.chdir(args.root_dir) +fullpath = os.getcwd() +fp_len = len(fullpath) + +for dirpath, dirs, files in sorted(os.walk(fullpath)): + dirpath = dirpath[fp_len:] + if not dirpath: + continue + parts = dirpath.split('/') + level = len(parts) - 2 + print ' ' * level + parts[-1] -- 2.39.5