language: added full translation support
[treecutter.git] / treecutter / main.py
index 92055d20050d0af57254b0618991c3c75b629a56..c12184d3fd309471f5cecc6345c0ab6fed6c0610 100644 (file)
@@ -4,6 +4,7 @@ from time import time
 import argparse
 from treecutter.directory import Directory
 from treecutter.sitemap import Sitemap
+from treecutter.tools import translate
 
 def main():
 
@@ -12,37 +13,59 @@ def main():
                         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='')
+    parser.add_argument('--draft', action='store_true')
+    parser.add_argument('--level', type=int, choices=[1, 2, 3, 4, 5], default=0)
+
     args = parser.parse_args()
 
     ts = time()
+    print "--= Treecutter =--"
     dir_ = Directory()
-    sitemap = Sitemap()
+    t1 = time()
+    totrans = dir_.translations(args.style)
+    print "Translate [%d] : [" % (len(totrans)),
+    translate(totrans)
+    print "]"
+    t2 = time()
+    print "Translate[%5.2f s]" % (round(t2-t1,2))
+
+
+    sitemap = Sitemap(args)
 
     # Scanning current directory and subdirectory for docbook articles
-    dir_.scan()
+    dir_.scan(args.draft, args.level)
     # 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()
+    dirset = dir_.set()
+    missing = dirset - sitemap.set()
+    removed = sitemap.set() - dirset
     for page in removed:
-        print page+' pages missing!!'
+        print page+' page not availible in this config'
     for page in missing:
         print 'adding missing page '+page
         sitemap.add_link(page)
-    if len(missing)+len(removed) != 0:
+    if len(missing) != 0:
         print 'writing new sitemap - please adjust if needed'
         sitemap.write_map()
 
+    dirsitemap = Sitemap(args)
+    for l in sitemap.linklist():
+        if l in dirset:
+            dirsitemap.add_link(l)
+
+
     # Generate a pygraphviz image of the site (TODO: currently not used)
-    sitemap.graph()
+    dirsitemap.graph()
     # Start processing the docbook articles to static html
-    sitemap.process(args.style)
+    dirsitemap.process()
 
     # Publish static html and style data (css, images, fonts) to destination dir
     t1 = time()
-    sitemap.publish(args.output,args.style)
+    dirsitemap.publish()
     t2 = time()
     print "Publish  [%5.2f s]" % (round(t2-t1,2))
     print "Total    [%5.2f s]" % (round(t2-ts,2))