1 |
#!/usr/bin/env python |
#!/usr/bin/env python |
2 |
|
|
3 |
# updatepages.py - Simple web site templating system |
# updatepages.py - Simple web site templating system |
4 |
# Copyright (C) 2006 Torsten Irl�nder |
# Copyright (C) 2006 Torsten Irlaender |
5 |
# Copyright (C) 2004 Joonas Paalasmaa |
# Copyright (C) 2004 Joonas Paalasmaa |
6 |
|
|
7 |
# This script is based on a script developed by Joonas Paalasmaa |
# This script is based on a script developed by Joonas Paalasmaa |
61 |
import glob, os, time, string, getopt, sys, shutil, re |
import glob, os, time, string, getopt, sys, shutil, re |
62 |
|
|
63 |
templatefile = "pages/template.xhtml" |
templatefile = "pages/template.xhtml" |
|
template = file(templatefile).read() |
|
64 |
includeformat = "<!--%s-->" |
includeformat = "<!--%s-->" |
65 |
destdir = "skencil-website" |
destdir = "skencil-website" |
66 |
|
|
74 |
global destdir |
global destdir |
75 |
|
|
76 |
try: |
try: |
77 |
opts, args = getopt.getopt(sys.argv[1:], "fd:", |
opts, args = getopt.getopt(sys.argv[1:], "fhd:", |
78 |
["force","dest-dir","gen-screenshots","gen-gallery"]) |
["force","dest-dir","gen-screenshots","gen-gallery","help"]) |
79 |
except getopt.GetoptError: |
except getopt.GetoptError: |
80 |
sys.exit(2) |
sys.exit(2) |
81 |
|
|
|
if len (args) < 1: |
|
|
usage(1) |
|
|
|
|
82 |
force = False |
force = False |
83 |
gen_gallery = False |
gen_gallery = False |
84 |
gen_screenshots = False |
gen_screenshots = False |
85 |
|
|
86 |
for o, a in opts: |
for o, a in opts: |
87 |
|
if o in ("-h", "--help"): |
88 |
|
usage(1) |
89 |
if o in ("-f", "--force"): |
if o in ("-f", "--force"): |
90 |
force = True |
force = True |
91 |
if o in ("-d", "--dest-dir"): |
if o in ("-d", "--dest-dir"): |
94 |
gen_gallery = True |
gen_gallery = True |
95 |
if o == "--gen-screenshots": |
if o == "--gen-screenshots": |
96 |
gen_screenshots = True |
gen_screenshots = True |
97 |
|
|
98 |
|
if len (args) < 1: |
99 |
|
usage(1) |
100 |
|
|
101 |
doit(force,gen_gallery,gen_screenshots,args) |
doit(force,gen_gallery,gen_screenshots,args) |
102 |
|
|
103 |
|
|
147 |
|
|
148 |
#generate pages |
#generate pages |
149 |
if genpages_flag: |
if genpages_flag: |
150 |
print("Generating html files... "), |
if os.path.isdir("screenshots"): |
151 |
genpages(force) |
print("Generating html files... "), |
152 |
print("Done.") |
genpages(force) |
153 |
#copy common file (.css,license...) |
print("Done.") |
154 |
copycommon() |
#copy common file (.css,license...) |
155 |
|
copycommon() |
156 |
|
else: |
157 |
|
print("No pages directory found. Nothing to be done") |
158 |
|
|
159 |
#copy screenshots |
#copy screenshots |
160 |
if genscreens_flag: |
if genscreens_flag: |
182 |
shutil.copy(file,destdir) |
shutil.copy(file,destdir) |
183 |
|
|
184 |
def genpages(force): |
def genpages(force): |
185 |
|
template = file(templatefile).read() |
186 |
faq_xml = 'pages/faq/faq.xml' |
faq_xml = 'pages/faq/faq.xml' |
187 |
#generate faq |
#generate faq |
188 |
faq_html = os.path.join('pages/','faq.html') |
faq_html = os.path.join('pages/','faq.html') |