]> git.phdru.name Git - phdru.name/phdru.name.git/commitdiff
Add gen-sitemap.py
authorOleg Broytman <phd@phdru.name>
Sun, 15 Mar 2015 20:29:23 +0000 (23:29 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 23 Dec 2015 15:54:10 +0000 (18:54 +0300)
gen-sitemap [new file with mode: 0755]
gen-sitemap.py [new file with mode: 0755]

diff --git a/gen-sitemap b/gen-sitemap
new file mode 100755 (executable)
index 0000000..c78fcd9
--- /dev/null
@@ -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 (executable)
index 0000000..d57d422
--- /dev/null
@@ -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]