index 1cc06edfc96f340a81c5abb368d5d950890b67b1..a4c29125f5d2b892801dbe0f33a4199311ca1638 100644 (file)
+#
+# Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
+# This module is free software, and you may redistribute it and/or modify
+# under the same terms as Python, so long as this copyright message and
+# disclaimer are retained in their original form.
+#
+# IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
+# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
+# OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
+# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
+# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+#
+# $Id: templatebuilder.py,v 1.11 2001-08-07 00:24:42 richard Exp $
+import errno, re
+
preamble = """
# Do Not Edit (Unless You Want To)
# This file automagically generated by roundup.htmldata.makeHtmlBase
fd = open(os.path.join(templateDir, 'htmlbase.py'), 'w')
fd.write(preamble)
for file in filelist:
- mangled_name = os.path.basename(re.sub(r'\.', 'DOT', file))
- fd.write('%s = """'%mangled_name)
- fd.write(open(file).read())
- fd.write('"""\n\n')
+ # skip the backup files created by richard's vim
+ if file[-1] == '~': continue
+ mangled_name = os.path.basename(re.sub(r'\.', 'DOT', file))
+ fd.write('%s = """'%mangled_name)
+ fd.write(re.sub(r'\$((Id|File|Log).*?)\$', r'dollar\1dollar',
+ open(file).read(), re.I))
+ fd.write('"""\n\n')
fd.close()
def installHtmlBase(template, installDir):
tdir = __import__('roundup.templates.%s.htmlbase'%template).templates
if hasattr(tdir, template):
- tmod = getattr(tdir, template)
+ tmod = getattr(tdir, template)
else:
- raise "TemplateError", \
- "couldn't find roundup.template.%s.htmlbase"%template
+ raise "TemplateError", "couldn't find roundup.template.%s.htmlbase"%template
htmlbase = tmod.htmlbase
+ installDir = os.path.join(installDir, 'html')
+ try:
+ os.makedirs(installDir)
+ except OSError, error:
+ if error.errno != errno.EEXIST: raise
- print "installing from", htmlbase.__file__, "into", installDir
+# print "installing from", htmlbase.__file__, "into", installDir
modulecontents = dir(htmlbase)
for mangledfile in modulecontents:
- if mangledfile[0] == "_":
- continue
- filename = re.sub('DOT', '.', mangledfile)
- outfile = os.path.join(installDir, filename)
- outfd = open(outfile, 'w')
- data = getattr(htmlbase, mangledfile)
- outfd.write(data)
+ if mangledfile[0] == "_":
+ continue
+ filename = re.sub('DOT', '.', mangledfile)
+ outfile = os.path.join(installDir, filename)
+ outfd = open(outfile, 'w')
+ data = getattr(htmlbase, mangledfile)
+ outfd.write(data)
if __name__ == "__main__":
import sys
if len(sys.argv) == 2:
- makeHtmlBase(sys.argv[1])
+ makeHtmlBase(sys.argv[1])
elif len(sys.argv) == 3:
- installHtmlBase(sys.argv[1], sys.argv[2])
+ installHtmlBase(sys.argv[1], sys.argv[2])
else:
- raise "what you talkin about willis?"
+ raise "what you talkin about willis?"
+
+#
+# $Log: not supported by cvs2svn $
+# Revision 1.10 2001/08/07 00:15:51 richard
+# Added the copyright/license notice to (nearly) all files at request of
+# Bizar Software.
+#
+# Revision 1.9 2001/08/01 05:06:10 richard
+# htmlbase doesn't have extraneous $Foo$ in it any more
+#
+# Revision 1.8 2001/07/30 08:12:17 richard
+# Added time logging and file uploading to the templates.
+#
+# Revision 1.7 2001/07/30 00:06:52 richard
+# Hrm - had IOError instead of OSError. Not sure why there's two. Ho hum.
+#
+# Revision 1.6 2001/07/29 07:01:39 richard
+# Added vim command to all source so that we don't get no steenkin' tabs :)
+#
+#
+#
+# vim: set filetype=python ts=4 sw=4 et si