Skip to content

Commit b840f9c

Browse files
author
Richard Jones
committed
Replaced errno integers with their module values.
De-tabbed templatebuilder.py
1 parent d4b2f7b commit b840f9c

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

roundup/htmltemplate.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# $Id: htmltemplate.py,v 1.3 2001-07-25 03:39:47 richard Exp $
1+
# $Id: htmltemplate.py,v 1.4 2001-07-28 07:59:53 richard Exp $
22

3-
import os, re, StringIO, urllib, cgi
3+
import os, re, StringIO, urllib, cgi, errno
44

55
import hyperdb, date
66

@@ -514,7 +514,7 @@ def index(client, templates, db, classname, filterspec={}, filter=[],
514514
template = open(os.path.join(templates, classname+'.filter')).read()
515515
all_filters = col_re.findall(template)
516516
except IOError, error:
517-
if error.errno != 2: raise
517+
if error.errno != errno.ENOENT: raise
518518
template = None
519519
all_filters = []
520520
if template and filter:
@@ -795,6 +795,12 @@ def newitem(client, templates, db, classname, form, replace=re.compile(
795795

796796
#
797797
# $Log: not supported by cvs2svn $
798+
# Revision 1.3 2001/07/25 03:39:47 richard
799+
# Hrm - displaying links to classes that don't specify a key property. I've
800+
# got it defaulting to 'name', then 'title' and then a "random" property (first
801+
# one returned by getprops().keys().
802+
# Needs to be moved onto the Class I think...
803+
#
798804
# Revision 1.2 2001/07/22 12:09:32 richard
799805
# Final commit of Grande Splite
800806
#

roundup/init.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# $Id: init.py,v 1.6 2001-07-24 11:18:25 anthonybaxter Exp $
1+
# $Id: init.py,v 1.7 2001-07-28 07:59:53 richard Exp $
22

3-
import os, shutil, sys
3+
import os, shutil, sys, errno
44

55
def copytree(src, dst, symlinks=0):
66
"""Recursively copy a directory tree using copy2().
@@ -19,7 +19,7 @@ def copytree(src, dst, symlinks=0):
1919
try:
2020
os.mkdir(dst)
2121
except OSError, error:
22-
if error.errno != 17: raise
22+
if error.errno != errno.EEXIST: raise
2323
for name in names:
2424
srcname = os.path.join(src, name)
2525
dstname = os.path.join(dst, name)
@@ -57,6 +57,9 @@ def init(instance, template, backend, adminpw):
5757

5858
#
5959
# $Log: not supported by cvs2svn $
60+
# Revision 1.6 2001/07/24 11:18:25 anthonybaxter
61+
# oops. left a print in
62+
#
6063
# Revision 1.5 2001/07/24 10:54:11 anthonybaxter
6164
# oops. Html.
6265
#

roundup/templatebuilder.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import errno
2+
13
preamble = """
24
# Do Not Edit (Unless You Want To)
35
# This file automagically generated by roundup.htmldata.makeHtmlBase
@@ -15,10 +17,10 @@ def makeHtmlBase(templateDir):
1517
fd = open(os.path.join(templateDir, 'htmlbase.py'), 'w')
1618
fd.write(preamble)
1719
for file in filelist:
18-
mangled_name = os.path.basename(re.sub(r'\.', 'DOT', file))
19-
fd.write('%s = """'%mangled_name)
20-
fd.write(open(file).read())
21-
fd.write('"""\n\n')
20+
mangled_name = os.path.basename(re.sub(r'\.', 'DOT', file))
21+
fd.write('%s = """'%mangled_name)
22+
fd.write(open(file).read())
23+
fd.write('"""\n\n')
2224
fd.close()
2325

2426
def installHtmlBase(template, installDir):
@@ -28,32 +30,35 @@ def installHtmlBase(template, installDir):
2830

2931
tdir = __import__('roundup.templates.%s.htmlbase'%template).templates
3032
if hasattr(tdir, template):
31-
tmod = getattr(tdir, template)
33+
tmod = getattr(tdir, template)
3234
else:
33-
raise "TemplateError", \
34-
"couldn't find roundup.template.%s.htmlbase"%template
35+
raise "TemplateError", "couldn't find roundup.template.%s.htmlbase"%template
3536
htmlbase = tmod.htmlbase
3637
installDir = os.path.join(installDir, 'html')
37-
os.makedirs(installDir)
38+
try:
39+
os.makedirs(installDir)
40+
except IOError, error:
41+
if error.errno != errno.EEXIST: raise
3842

3943
print "installing from", htmlbase.__file__, "into", installDir
4044
modulecontents = dir(htmlbase)
4145
for mangledfile in modulecontents:
42-
if mangledfile[0] == "_":
43-
continue
44-
filename = re.sub('DOT', '.', mangledfile)
45-
outfile = os.path.join(installDir, filename)
46-
outfd = open(outfile, 'w')
47-
data = getattr(htmlbase, mangledfile)
48-
outfd.write(data)
46+
if mangledfile[0] == "_":
47+
continue
48+
filename = re.sub('DOT', '.', mangledfile)
49+
outfile = os.path.join(installDir, filename)
50+
outfd = open(outfile, 'w')
51+
data = getattr(htmlbase, mangledfile)
52+
outfd.write(data)
4953

5054

5155

5256
if __name__ == "__main__":
5357
import sys
5458
if len(sys.argv) == 2:
55-
makeHtmlBase(sys.argv[1])
59+
makeHtmlBase(sys.argv[1])
5660
elif len(sys.argv) == 3:
57-
installHtmlBase(sys.argv[1], sys.argv[2])
61+
installHtmlBase(sys.argv[1], sys.argv[2])
5862
else:
59-
raise "what you talkin about willis?"
63+
raise "what you talkin about willis?"
64+

0 commit comments

Comments
 (0)