From b463eb4bf3bad5d79cb871942788c96cdf725ded Mon Sep 17 00:00:00 2001 From: richard Date: Sat, 28 Jul 2001 07:59:53 +0000 Subject: [PATCH] Replaced errno integers with their module values. De-tabbed templatebuilder.py git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@119 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/htmltemplate.py | 12 ++++++++--- roundup/init.py | 9 ++++++--- roundup/templatebuilder.py | 41 +++++++++++++++++++++----------------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index cdbdc3f..4f819a3 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -1,6 +1,6 @@ -# $Id: htmltemplate.py,v 1.3 2001-07-25 03:39:47 richard Exp $ +# $Id: htmltemplate.py,v 1.4 2001-07-28 07:59:53 richard Exp $ -import os, re, StringIO, urllib, cgi +import os, re, StringIO, urllib, cgi, errno import hyperdb, date @@ -514,7 +514,7 @@ def index(client, templates, db, classname, filterspec={}, filter=[], template = open(os.path.join(templates, classname+'.filter')).read() all_filters = col_re.findall(template) except IOError, error: - if error.errno != 2: raise + if error.errno != errno.ENOENT: raise template = None all_filters = [] if template and filter: @@ -795,6 +795,12 @@ def newitem(client, templates, db, classname, form, replace=re.compile( # # $Log: not supported by cvs2svn $ +# Revision 1.3 2001/07/25 03:39:47 richard +# Hrm - displaying links to classes that don't specify a key property. I've +# got it defaulting to 'name', then 'title' and then a "random" property (first +# one returned by getprops().keys(). +# Needs to be moved onto the Class I think... +# # Revision 1.2 2001/07/22 12:09:32 richard # Final commit of Grande Splite # diff --git a/roundup/init.py b/roundup/init.py index 946d93c..2667cd9 100644 --- a/roundup/init.py +++ b/roundup/init.py @@ -1,6 +1,6 @@ -# $Id: init.py,v 1.6 2001-07-24 11:18:25 anthonybaxter Exp $ +# $Id: init.py,v 1.7 2001-07-28 07:59:53 richard Exp $ -import os, shutil, sys +import os, shutil, sys, errno def copytree(src, dst, symlinks=0): """Recursively copy a directory tree using copy2(). @@ -19,7 +19,7 @@ def copytree(src, dst, symlinks=0): try: os.mkdir(dst) except OSError, error: - if error.errno != 17: raise + if error.errno != errno.EEXIST: raise for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) @@ -57,6 +57,9 @@ from roundup.backends.back_%s import Database'''%backend # # $Log: not supported by cvs2svn $ +# Revision 1.6 2001/07/24 11:18:25 anthonybaxter +# oops. left a print in +# # Revision 1.5 2001/07/24 10:54:11 anthonybaxter # oops. Html. # diff --git a/roundup/templatebuilder.py b/roundup/templatebuilder.py index 9f96673..4dedd14 100644 --- a/roundup/templatebuilder.py +++ b/roundup/templatebuilder.py @@ -1,3 +1,5 @@ +import errno + preamble = """ # Do Not Edit (Unless You Want To) # This file automagically generated by roundup.htmldata.makeHtmlBase @@ -15,10 +17,10 @@ def makeHtmlBase(templateDir): 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') + mangled_name = os.path.basename(re.sub(r'\.', 'DOT', file)) + fd.write('%s = """'%mangled_name) + fd.write(open(file).read()) + fd.write('"""\n\n') fd.close() def installHtmlBase(template, installDir): @@ -28,32 +30,35 @@ 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') - os.makedirs(installDir) + try: + os.makedirs(installDir) + except IOError, error: + if error.errno != errno.EEXIST: raise 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?" + -- 2.30.2