annotate roundup/templatebuilder.py @ 571:2998d683e2cf

Fixed status change in mail gateway.
author Roche Compaan <rochecompaan@users.sourceforge.net>
date Tue, 22 Jan 2002 11:54:45 +0000
parents bdc2ea127ae9
children b55fb6d88a0d c242455d9b46
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
1 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
3 # This module is free software, and you may redistribute it and/or modify
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
4 # under the same terms as Python, so long as this copyright message and
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
5 # disclaimer are retained in their original form.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
6 #
214
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
10 # POSSIBILITY OF SUCH DAMAGE.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
11 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
17 #
406
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 390
diff changeset
18 # $Id: templatebuilder.py,v 1.13 2001-11-22 15:46:42 jhermann Exp $
174
2775f6727070 htmlbase doesn't have extraneous $Foo$ in it any more
Richard Jones <richard@users.sourceforge.net>
parents: 167
diff changeset
19 import errno, re
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
20
406
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 390
diff changeset
21 __doc__ = """
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 390
diff changeset
22 Collect template parts and create instance template files.
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 390
diff changeset
23 """
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 390
diff changeset
24
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
25 preamble = """
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
26 # Do Not Edit (Unless You Want To)
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
27 # This file automagically generated by roundup.htmldata.makeHtmlBase
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
28 #
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
29 """
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
30
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
31 def makeHtmlBase(templateDir):
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
32 """ make a htmlbase.py file in the given templateDir, from the
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
33 contents of templateDir/html """
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
34 import os, glob, re
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
35 print "packing up templates in", templateDir
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
36 filelist = glob.glob(os.path.join(templateDir, 'html', '*'))
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
37 filelist = filter(os.path.isfile, filelist) # only want files
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
38 filelist.sort()
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
39 fd = open(os.path.join(templateDir, 'htmlbase.py'), 'w')
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
40 fd.write(preamble)
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
41 for file in filelist:
167
a49c8a2ddd26 Added time logging and file uploading to the templates.
Richard Jones <richard@users.sourceforge.net>
parents: 139
diff changeset
42 # skip the backup files created by richard's vim
a49c8a2ddd26 Added time logging and file uploading to the templates.
Richard Jones <richard@users.sourceforge.net>
parents: 139
diff changeset
43 if file[-1] == '~': continue
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
44 mangled_name = os.path.basename(re.sub(r'\.', 'DOT', file))
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
45 fd.write('%s = """'%mangled_name)
174
2775f6727070 htmlbase doesn't have extraneous $Foo$ in it any more
Richard Jones <richard@users.sourceforge.net>
parents: 167
diff changeset
46 fd.write(re.sub(r'\$((Id|File|Log).*?)\$', r'dollar\1dollar',
2775f6727070 htmlbase doesn't have extraneous $Foo$ in it any more
Richard Jones <richard@users.sourceforge.net>
parents: 167
diff changeset
47 open(file).read(), re.I))
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
48 fd.write('"""\n\n')
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
49 fd.close()
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
50
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
51 def installHtmlBase(template, installDir):
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
52 """ passed a template package and an installDir, unpacks the html files into
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
53 the installdir """
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
54 import os,sys,re
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
55
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
56 tdir = __import__('roundup.templates.%s.htmlbase'%template).templates
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
57 if hasattr(tdir, template):
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
58 tmod = getattr(tdir, template)
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
59 else:
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
60 raise "TemplateError", "couldn't find roundup.template.%s.htmlbase"%template
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
61 htmlbase = tmod.htmlbase
69
0eed07d99b98 oops. Html.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents: 68
diff changeset
62 installDir = os.path.join(installDir, 'html')
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
63 try:
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
64 os.makedirs(installDir)
139
16fdc86183fe Hrm - had IOError instead of OSError. Not sure why there's two. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
65 except OSError, error:
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
66 if error.errno != errno.EEXIST: raise
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
67
114
caca379e12d3 commented out print
Richard Jones <richard@users.sourceforge.net>
parents: 113
diff changeset
68 # print "installing from", htmlbase.__file__, "into", installDir
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
69 modulecontents = dir(htmlbase)
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
70 for mangledfile in modulecontents:
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
71 if mangledfile[0] == "_":
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
72 continue
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
73 filename = re.sub('DOT', '.', mangledfile)
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
74 outfile = os.path.join(installDir, filename)
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
75 outfd = open(outfile, 'w')
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
76 data = getattr(htmlbase, mangledfile)
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
77 outfd.write(data)
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
78
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
79
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
80
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
81 if __name__ == "__main__":
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
82 import sys
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
83 if len(sys.argv) == 2:
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
84 makeHtmlBase(sys.argv[1])
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
85 elif len(sys.argv) == 3:
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
86 installHtmlBase(sys.argv[1], sys.argv[2])
68
5e71aaa87e5b Added templatebuilder module.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff changeset
87 else:
390
a74ea8489896 users may attach files to issues (and support in ext) through the web now
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
88 print "Usage: %s <template directory>"%sys.argv[0]
113
2ab86442799a Replaced errno integers with their module values.
Richard Jones <richard@users.sourceforge.net>
parents: 102
diff changeset
89
127
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 114
diff changeset
90 #
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 114
diff changeset
91 # $Log: not supported by cvs2svn $
406
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 390
diff changeset
92 # Revision 1.12 2001/11/14 21:35:21 richard
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 390
diff changeset
93 # . users may attach files to issues (and support in ext) through the web now
bdc2ea127ae9 Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents: 390
diff changeset
94 #
390
a74ea8489896 users may attach files to issues (and support in ext) through the web now
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
95 # Revision 1.11 2001/08/07 00:24:42 richard
a74ea8489896 users may attach files to issues (and support in ext) through the web now
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
96 # stupid typo
a74ea8489896 users may attach files to issues (and support in ext) through the web now
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
97 #
214
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
98 # Revision 1.10 2001/08/07 00:15:51 richard
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
99 # Added the copyright/license notice to (nearly) all files at request of
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
100 # Bizar Software.
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
101 #
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
102 # Revision 1.9 2001/08/01 05:06:10 richard
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
103 # htmlbase doesn't have extraneous $Foo$ in it any more
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 174
diff changeset
104 #
174
2775f6727070 htmlbase doesn't have extraneous $Foo$ in it any more
Richard Jones <richard@users.sourceforge.net>
parents: 167
diff changeset
105 # Revision 1.8 2001/07/30 08:12:17 richard
2775f6727070 htmlbase doesn't have extraneous $Foo$ in it any more
Richard Jones <richard@users.sourceforge.net>
parents: 167
diff changeset
106 # Added time logging and file uploading to the templates.
2775f6727070 htmlbase doesn't have extraneous $Foo$ in it any more
Richard Jones <richard@users.sourceforge.net>
parents: 167
diff changeset
107 #
167
a49c8a2ddd26 Added time logging and file uploading to the templates.
Richard Jones <richard@users.sourceforge.net>
parents: 139
diff changeset
108 # Revision 1.7 2001/07/30 00:06:52 richard
a49c8a2ddd26 Added time logging and file uploading to the templates.
Richard Jones <richard@users.sourceforge.net>
parents: 139
diff changeset
109 # Hrm - had IOError instead of OSError. Not sure why there's two. Ho hum.
a49c8a2ddd26 Added time logging and file uploading to the templates.
Richard Jones <richard@users.sourceforge.net>
parents: 139
diff changeset
110 #
139
16fdc86183fe Hrm - had IOError instead of OSError. Not sure why there's two. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
111 # Revision 1.6 2001/07/29 07:01:39 richard
16fdc86183fe Hrm - had IOError instead of OSError. Not sure why there's two. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
112 # Added vim command to all source so that we don't get no steenkin' tabs :)
16fdc86183fe Hrm - had IOError instead of OSError. Not sure why there's two. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
113 #
127
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 114
diff changeset
114 #
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 114
diff changeset
115 #
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 114
diff changeset
116 # vim: set filetype=python ts=4 sw=4 et si

Roundup Issue Tracker: http://roundup-tracker.org/