[Skencil-commits] r670 - website/trunk

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Apr 11 18:36:36 CEST 2006


Author: torsten
Date: 2006-04-11 18:36:36 +0200 (Tue, 11 Apr 2006)
New Revision: 670

Modified:
   website/trunk/updatepages.py
Log:
Added help option an fixed some issues on missing directorys



Modified: website/trunk/updatepages.py
===================================================================
--- website/trunk/updatepages.py	2006-04-11 16:20:37 UTC (rev 669)
+++ website/trunk/updatepages.py	2006-04-11 16:36:36 UTC (rev 670)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 # updatepages.py - Simple web site templating system
-# Copyright (C) 2006 Torsten Irländer
+# Copyright (C) 2006 Torsten Irlaender
 # Copyright (C) 2004  Joonas Paalasmaa
 
 # This script is based on a script developed by Joonas Paalasmaa
@@ -61,7 +61,6 @@
 import glob, os, time, string, getopt, sys, shutil, re
 
 templatefile = "pages/template.xhtml"
-template = file(templatefile).read()
 includeformat = "<!--%s-->"
 destdir = "skencil-website"
 
@@ -75,19 +74,18 @@
     global destdir
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "fd:",
-        ["force","dest-dir","gen-screenshots","gen-gallery"])
+        opts, args = getopt.getopt(sys.argv[1:], "fhd:",
+        ["force","dest-dir","gen-screenshots","gen-gallery","help"])
     except getopt.GetoptError:
         sys.exit(2)
     
-    if len (args) < 1:
-        usage(1)
-        
     force = False
     gen_gallery = False
     gen_screenshots = False
     
     for o, a in opts:
+        if o in ("-h", "--help"):
+            usage(1)
         if o in ("-f", "--force"):
             force = True
         if o in ("-d", "--dest-dir"):
@@ -96,6 +94,10 @@
             gen_gallery = True
         if o == "--gen-screenshots":
             gen_screenshots = True
+    
+    if len (args) < 1:
+        usage(1)
+    
     doit(force,gen_gallery,gen_screenshots,args)
 
 
@@ -145,11 +147,14 @@
 
     #generate pages
     if genpages_flag:
-        print("Generating html files... "),
-        genpages(force)
-        print("Done.")
-        #copy common file (.css,license...)
-        copycommon()
+        if os.path.isdir("screenshots"):
+            print("Generating html files... "),
+            genpages(force)
+            print("Done.")
+            #copy common file (.css,license...)
+            copycommon()
+        else: 
+            print("No pages directory found. Nothing to be done")
 
     #copy screenshots
     if genscreens_flag:
@@ -177,7 +182,7 @@
         shutil.copy(file,destdir)
 
 def genpages(force):
-    
+    template = file(templatefile).read()
     faq_xml = 'pages/faq/faq.xml'
     #generate faq
     faq_html = os.path.join('pages/','faq.html')



More information about the Skencil-commits mailing list