Added subdir argument, cleaned up arg handling
[treecutter.git] / treecutter / main.py
index b53a92fc8618165fad4c013b4e2a7a9aeb295309..6d7b7ddcecbd679f4775cebaaa55f54e7a288fce 100644 (file)
@@ -1,25 +1,31 @@
 #!/usr/bin/python
 import os
-import time
+from time import time
 import argparse
 from treecutter.directory import Directory
 from treecutter.sitemap import Sitemap
 
 def main():
+
     parser = argparse.ArgumentParser(description='Process docbook article tree.')
     parser.add_argument('--style', nargs='?',
                         default=os.path.dirname(os.getcwd())+'/style/default/')
     parser.add_argument('--output', nargs='?',
                         default=os.path.dirname(os.getcwd())+'/htdocs/')
+    parser.add_argument('--subdir', nargs='?',
+                        default='')
     args = parser.parse_args()
 
-    ts = time.time()
+    ts = time()
     dir_ = Directory()
-    sitemap = Sitemap()
+    sitemap = Sitemap(args)
 
+    # Scanning current directory and subdirectory for docbook articles
     dir_.scan()
+    # Reading the sitemap.txt building a Trie structure
     sitemap.read_map()
 
+    # Comparing the current state of the dir with the sitemap
     missing = dir_.set() - sitemap.set()
     removed = sitemap.set() - dir_.set()
     for page in removed:
@@ -30,13 +36,16 @@ def main():
     if len(missing)+len(removed) != 0:
         print 'writing new sitemap - please adjust if needed'
         sitemap.write_map()
-    sitemap.graph()
 
-    sitemap.process(args.style)
+    # Generate a pygraphviz image of the site (TODO: currently not used)
+    sitemap.graph()
+    # Start processing the docbook articles to static html
+    sitemap.process()
 
-    t1 = time.time()
-    sitemap.publish(args.output,args.style)
-    t2 = time.time()
+    # Publish static html and style data (css, images, fonts) to destination dir
+    t1 = time()
+    sitemap.publish()
+    t2 = time()
     print "Publish  [%5.2f s]" % (round(t2-t1,2))
     print "Total    [%5.2f s]" % (round(t2-ts,2))
     return 0