summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-03-25 04:14:28 +0000
committerGreg Noel <GregNoel@tigris.org>2010-03-25 04:14:28 +0000
commitaf6d7c35464bb75dcabc72094b4bd84154dde50d (patch)
tree0984fd581082c27cfbfbb7f94d5751b0e6fd2741 /bin
parent55ef7fe83e3211be3045f089767ca8e198db1c2c (diff)
downloadscons-af6d7c35464bb75dcabc72094b4bd84154dde50d.tar.gz
Move 2.0 changes collected in branches/pending back to trunk for further
development. Note that this set of changes is NOT backward-compatible; the trunk no longer works with Python 1.5.2, 2.0, or 2.1.
Diffstat (limited to 'bin')
-rw-r--r--bin/SConsDoc.py5
-rw-r--r--bin/import-test.py2
-rw-r--r--bin/linecount.py6
-rw-r--r--bin/memoicmp.py25
-rw-r--r--bin/objcounts.py2
-rw-r--r--bin/scons-diff.py8
-rw-r--r--bin/scons-doc.py79
-rw-r--r--bin/scons-proc.py31
-rw-r--r--bin/scons-test.py5
-rw-r--r--bin/scons-unzip.py2
-rw-r--r--bin/sconsexamples.py52
-rw-r--r--bin/sfsum3
12 files changed, 109 insertions, 111 deletions
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py
index 3f64a258..d164d11e 100644
--- a/bin/SConsDoc.py
+++ b/bin/SConsDoc.py
@@ -2,6 +2,7 @@
#
# Module for handling SCons documentation processing.
#
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
__doc__ = """
This module parses home-brew XML files that document various things
@@ -218,8 +219,8 @@ class SConsDocHandler(xml.sax.handler.ContentHandler,
self._start_dispatch = {}
self._end_dispatch = {}
keys = self.__class__.__dict__.keys()
- start_tag_method_names = filter(lambda k: k[:6] == 'start_', keys)
- end_tag_method_names = filter(lambda k: k[:4] == 'end_', keys)
+ start_tag_method_names = [k for k in keys if k[:6] == 'start_']
+ end_tag_method_names = [k for k in keys if k[:4] == 'end_']
for method_name in start_tag_method_names:
tag = method_name[6:]
self._start_dispatch[tag] = getattr(self, method_name)
diff --git a/bin/import-test.py b/bin/import-test.py
index 839d2ad3..fe5ea2fd 100644
--- a/bin/import-test.py
+++ b/bin/import-test.py
@@ -78,7 +78,7 @@ def print_files(dir):
if not d:
l = dir.path + [n]
sys.stdout.write('\ntest.write(%s, """\\\n' % l)
- p = os.path.join(*([directory] + l))
+ p = os.path.join(directory, *l)
sys.stdout.write(open(p, 'r').read())
sys.stdout.write('""")\n')
dir.call_for_each_entry(print_a_file)
diff --git a/bin/linecount.py b/bin/linecount.py
index 33f9f737..715d2072 100644
--- a/bin/linecount.py
+++ b/bin/linecount.py
@@ -22,11 +22,11 @@
# non-comment lines. The last figure (non-comment) lines is the most
# interesting one for most purposes.
#
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os.path
-import string
fmt = "%-16s %5s %7s %9s %11s %11s"
@@ -85,8 +85,8 @@ sources = Collection('sources', pred=is_source)
def t(arg, dirname, names):
try: names.remove('.svn')
except ValueError: pass
- names = filter(arg, names)
- arg.extend(map(lambda n, d=dirname: os.path.join(d, n), names))
+ names = list(filter(arg, names))
+ arg.extend([os.path.join(dirname, n) for n in names])
os.path.walk('src', t, src_Tests_py_tests)
os.path.walk('src', t, src_test_tests)
diff --git a/bin/memoicmp.py b/bin/memoicmp.py
index f45ecb09..812af665 100644
--- a/bin/memoicmp.py
+++ b/bin/memoicmp.py
@@ -1,21 +1,24 @@
#!/usr/bin/env python
#
-# A script to compare the --debug=memoizer output found int
+# A script to compare the --debug=memoizer output found in
# two different files.
-import sys,string
+import sys
def memoize_output(fname):
- mout = {}
- lines=filter(lambda words:
- len(words) == 5 and
- words[1] == 'hits' and words[3] == 'misses',
- map(string.split, open(fname,'r').readlines()))
- for line in lines:
- mout[line[-1]] = ( int(line[0]), int(line[2]) )
- return mout
+ mout = {}
+ #lines=filter(lambda words:
+ # len(words) == 5 and
+ # words[1] == 'hits' and words[3] == 'misses',
+ # map(string.split, open(fname,'r').readlines()))
+ #for line in lines:
+ # mout[line[-1]] = ( int(line[0]), int(line[2]) )
+ for line in open(fname,'r').readlines():
+ words = line.split()
+ if len(words) == 5 and words[1] == 'hits' and words[3] == 'misses':
+ mout[words[-1]] = ( int(words[0]), int(words[2]) )
+ return mout
-
def memoize_cmp(filea, fileb):
ma = memoize_output(filea)
mb = memoize_output(fileb)
diff --git a/bin/objcounts.py b/bin/objcounts.py
index ca814b44..c1f2dd56 100644
--- a/bin/objcounts.py
+++ b/bin/objcounts.py
@@ -40,7 +40,7 @@ def fetch_counts(fname):
list = [l.split() for l in lines if re.match('\s+\d', l)]
d = {}
for l in list:
- d[l[-1]] = map(int, l[:-1])
+ d[l[-1]] = list(map(int, l[:-1]))
return d
c1 = fetch_counts(sys.argv[1])
diff --git a/bin/scons-diff.py b/bin/scons-diff.py
index 7c603083..d1e48cf5 100644
--- a/bin/scons-diff.py
+++ b/bin/scons-diff.py
@@ -97,15 +97,15 @@ def simple_diff(a, b, fromfile='', tofile='',
for op, a1, a2, b1, b2 in sm.get_opcodes():
if op == 'delete':
result.append("%sd%d\n" % (comma(a1, a2), b1))
- result.extend(map(lambda l: '< ' + l, a[a1:a2]))
+ result.extend(['< ' + l for l in a[a1:a2]])
elif op == 'insert':
result.append("%da%s\n" % (a1, comma(b1, b2)))
- result.extend(map(lambda l: '> ' + l, b[b1:b2]))
+ result.extend(['> ' + l for l in b[b1:b2]])
elif op == 'replace':
result.append("%sc%s\n" % (comma(a1, a2), comma(b1, b2)))
- result.extend(map(lambda l: '< ' + l, a[a1:a2]))
+ result.extend(['< ' + l for l in a[a1:a2]])
result.append('---\n')
- result.extend(map(lambda l: '> ' + l, b[b1:b2]))
+ result.extend(['> ' + l for l in b[b1:b2]])
return result
diff_map = {
diff --git a/bin/scons-doc.py b/bin/scons-doc.py
index e385b081..f140743e 100644
--- a/bin/scons-doc.py
+++ b/bin/scons-doc.py
@@ -88,12 +88,12 @@
# Error output gets passed through to your error output so you
# can see if there are any problems executing the command.
#
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
import optparse
import os
import re
import sgmllib
-import string
import sys
import time
@@ -185,7 +185,6 @@ Prompt = {
Stdin = """\
import os
import re
-import string
import SCons.Action
import SCons.Defaults
import SCons.Node.FS
@@ -231,7 +230,7 @@ class Curry:
else:
kw = kwargs or self.kwargs
- return apply(self.fun, self.pending + args, kw)
+ return self.fun(*self.pending + args, **kw)
def Str(target, source, env, cmd=""):
result = []
@@ -304,7 +303,7 @@ def JavaCCom(target, source, env):
# public class FooBar
# lines in the source file(s) and spits those out
# to .class files named after the class.
- tlist = map(str, target)
+ tlist = list(map(str, target))
not_copied = {}
for t in tlist:
not_copied[t] = 1
@@ -312,7 +311,7 @@ def JavaCCom(target, source, env):
contents = open(src, "rb").read()
classes = public_class_re.findall(contents)
for c in classes:
- for t in filter(lambda x: string.find(x, c) != -1, tlist):
+ for t in [x for x in tlist if x.find(c) != -1]:
open(t, "wb").write(contents)
del not_copied[t]
for t in not_copied.keys():
@@ -326,7 +325,7 @@ def JavaHCom(target, source, env):
def find_class_files(arg, dirname, names):
class_files = filter(lambda n: n[-6:] == '.class', names)
- paths = map(lambda n, d=dirname: os.path.join(d, n), class_files)
+ paths = map(lambda n: os.path.join(dirname, n), class_files)
arg.extend(paths)
def JarCom(target, source, env):
@@ -382,9 +381,9 @@ ToolList = {
toollist = ToolList[platform]
filter_tools = string.split('%(tools)s')
if filter_tools:
- toollist = filter(lambda x, ft=filter_tools: x[0] in ft, toollist)
+ toollist = [x for x in toollist if x[0] in filter_tools]
-toollist = map(lambda t: apply(ToolSurrogate, t), toollist)
+toollist = [ToolSurrogate(*t) for t in toollist]
toollist.append('install')
@@ -413,8 +412,8 @@ def command_scons(args, c, test, dict):
except AttributeError:
pass
else:
- for arg in string.split(c.environment):
- key, val = string.split(arg, '=')
+ for arg in c.environment.split():
+ key, val = arg.split('=')
try:
save_vals[key] = os.environ[key]
except KeyError:
@@ -427,17 +426,17 @@ def command_scons(args, c, test, dict):
# warnings that come from the new revamped VS support so
# we can build doc on (Linux) systems that don't have
# Visual C installed.
- arguments = '--warn=no-visual-c-missing -f - ' + string.join(args),
+ arguments = '--warn=no-visual-c-missing -f - ' + ' '.join(args),
chdir = test.workpath('WORK'),
stdin = Stdin % dict)
os.environ.update(save_vals)
for key in delete_keys:
del(os.environ[key])
out = test.stdout()
- out = string.replace(out, test.workpath('ROOT'), '')
- out = string.replace(out, test.workpath('WORK/SConstruct'),
+ out = out.replace(test.workpath('ROOT'), '')
+ out = out.replace(test.workpath('WORK/SConstruct'),
'/home/my/project/SConstruct')
- lines = string.split(out, '\n')
+ lines = out.split('\n')
if lines:
while lines[-1] == '':
lines = lines[:-1]
@@ -479,9 +478,9 @@ def command_edit(args, c, test, dict):
def command_ls(args, c, test, dict):
def ls(a):
files = os.listdir(a)
- files = filter(lambda x: x[0] != '.', files)
+ files = [x for x in files if x[0] != '.']
files.sort()
- return [string.join(files, ' ')]
+ return [' '.join(files)]
if args:
l = []
for a in args:
@@ -569,7 +568,7 @@ class MySGML(sgmllib.SGMLParser):
# handle the begin-end tags of our SCons examples.
def start_scons_example(self, attrs):
- t = filter(lambda t: t[0] == 'name', attrs)
+ t = [t for t in attrs if t[0] == 'name']
if t:
name = t[0][1]
try:
@@ -585,7 +584,7 @@ class MySGML(sgmllib.SGMLParser):
def end_scons_example(self):
e = self.e
- files = filter(lambda f: f.printme, e.files)
+ files = [f for f in e.files if f.printme]
if files:
self.outfp.write('<programlisting>')
for f in files:
@@ -593,9 +592,9 @@ class MySGML(sgmllib.SGMLParser):
i = len(f.data) - 1
while f.data[i] == ' ':
i = i - 1
- output = string.replace(f.data[:i+1], '__ROOT__', '')
- output = string.replace(output, '<', '&lt;')
- output = string.replace(output, '>', '&gt;')
+ output = f.data[:i+1].replace('__ROOT__', '')
+ output = output.replace('<', '&lt;')
+ output = output.replace('>', '&gt;')
self.outfp.write(output)
if e.data and e.data[0] == '\n':
e.data = e.data[1:]
@@ -608,7 +607,7 @@ class MySGML(sgmllib.SGMLParser):
e = self.e
except AttributeError:
self.error("<file> tag outside of <scons_example>")
- t = filter(lambda t: t[0] == 'name', attrs)
+ t = [t for t in attrs if t[0] == 'name']
if not t:
self.error("no <file> name attribute found")
try:
@@ -632,7 +631,7 @@ class MySGML(sgmllib.SGMLParser):
e = self.e
except AttributeError:
self.error("<directory> tag outside of <scons_example>")
- t = filter(lambda t: t[0] == 'name', attrs)
+ t = [t for t in attrs if t[0] == 'name']
if not t:
self.error("no <directory> name attribute found")
try:
@@ -651,7 +650,7 @@ class MySGML(sgmllib.SGMLParser):
self.afunclist = self.afunclist[:-1]
def start_scons_example_file(self, attrs):
- t = filter(lambda t: t[0] == 'example', attrs)
+ t = [t for t in attrs if t[0] == 'example']
if not t:
self.error("no <scons_example_file> example attribute found")
exname = t[0][1]
@@ -659,11 +658,11 @@ class MySGML(sgmllib.SGMLParser):
e = self.examples[exname]
except KeyError:
self.error("unknown example name '%s'" % exname)
- fattrs = filter(lambda t: t[0] == 'name', attrs)
+ fattrs = [t for t in attrs if t[0] == 'name']
if not fattrs:
self.error("no <scons_example_file> name attribute found")
fname = fattrs[0][1]
- f = filter(lambda f, fname=fname: f.name == fname, e.files)
+ f = [f for f in e.files if f.name == fname]
if not f:
self.error("example '%s' does not have a file named '%s'" % (exname, fname))
self.f = f[0]
@@ -675,7 +674,7 @@ class MySGML(sgmllib.SGMLParser):
delattr(self, 'f')
def start_scons_output(self, attrs):
- t = filter(lambda t: t[0] == 'example', attrs)
+ t = [t for t in attrs if t[0] == 'example']
if not t:
self.error("no <scons_output> example attribute found")
exname = t[0][1]
@@ -704,7 +703,7 @@ class MySGML(sgmllib.SGMLParser):
if o.preserve:
t.preserve()
t.subdir('ROOT', 'WORK')
- t.rootpath = string.replace(t.workpath('ROOT'), '\\', '\\\\')
+ t.rootpath = t.workpath('ROOT').replace('\\', '\\\\')
for d in e.dirs:
dir = t.workpath('WORK', d.name)
@@ -715,19 +714,19 @@ class MySGML(sgmllib.SGMLParser):
i = 0
while f.data[i] == '\n':
i = i + 1
- lines = string.split(f.data[i:], '\n')
+ lines = f.data[i:].split('\n')
i = 0
while lines[0][i] == ' ':
i = i + 1
- lines = map(lambda l, i=i: l[i:], lines)
- path = string.replace(f.name, '__ROOT__', t.rootpath)
+ lines = [l[i:] for l in lines]
+ path = f.name.replace('__ROOT__', t.rootpath)
if not os.path.isabs(path):
path = t.workpath('WORK', path)
dir, name = os.path.split(path)
if dir and not os.path.exists(dir):
os.makedirs(dir)
- content = string.join(lines, '\n')
- content = string.replace(content, '__ROOT__', t.rootpath)
+ content = '\n'.join(lines)
+ content = content.replace('__ROOT__', t.rootpath)
path = t.workpath('WORK', path)
t.write(path, content)
if hasattr(f, 'chmod'):
@@ -761,24 +760,24 @@ class MySGML(sgmllib.SGMLParser):
for c in o.commandlist:
self.outfp.write(p + Prompt[o.os])
- d = string.replace(c.data, '__ROOT__', '')
+ d = c.data.replace('__ROOT__', '')
self.outfp.write('<userinput>' + d + '</userinput>\n')
- e = string.replace(c.data, '__ROOT__', t.workpath('ROOT'))
- args = string.split(e)
+ e = c.data.replace('__ROOT__', t.workpath('ROOT'))
+ args = e.split()
lines = ExecuteCommand(args, c, t, {'osname':o.os, 'tools':o.tools})
content = None
if c.output:
content = c.output
elif lines:
- content = string.join(lines, '\n' + p)
+ content = ( '\n' + p).join(lines)
if content:
content = address_re.sub(r' at 0x700000&gt;', content)
content = engine_re.sub(r' File "bootstrap/src/engine/SCons/', content)
content = file_re.sub(r'\1 <module>', content)
content = nodelist_re.sub(r"\1 'NodeList' object \2", content)
- content = string.replace(content, '<', '&lt;')
- content = string.replace(content, '>', '&gt;')
+ content = content.replace('<', '&lt;')
+ content = content.replace('>', '&gt;')
self.outfp.write(p + content + '\n')
if o.data[0] == '\n':
@@ -815,7 +814,7 @@ class MySGML(sgmllib.SGMLParser):
def end_sconstruct(self):
f = self.f
self.outfp.write('<programlisting>')
- output = string.replace(f.data, '__ROOT__', '')
+ output = f.data.replace('__ROOT__', '')
self.outfp.write(output + '</programlisting>')
delattr(self, 'f')
self.afunclist = self.afunclist[:-1]
diff --git a/bin/scons-proc.py b/bin/scons-proc.py
index 15f22b76..52d326c0 100644
--- a/bin/scons-proc.py
+++ b/bin/scons-proc.py
@@ -13,7 +13,6 @@
import getopt
import os.path
import re
-import string
import StringIO
import sys
import xml.sax
@@ -140,7 +139,7 @@ class SCons_XML:
class SCons_XML_to_XML(SCons_XML):
def write(self, files):
- gen, mod = string.split(files, ',')
+ gen, mod = files.split(',')
g.write_gen(gen)
g.write_mod(mod)
def write_gen(self, filename):
@@ -157,12 +156,12 @@ class SCons_XML_to_XML(SCons_XML):
for chunk in v.summary.body:
f.write(str(chunk))
if v.sets:
- s = map(lambda x: '&cv-link-%s;' % x, v.sets)
+ s = ['&cv-link-%s;' % x for x in v.sets]
f.write('<para>\n')
f.write('Sets: ' + ', '.join(s) + '.\n')
f.write('</para>\n')
if v.uses:
- u = map(lambda x: '&cv-link-%s;' % x, v.uses)
+ u = ['&cv-link-%s;' % x for x in v.uses]
f.write('<para>\n')
f.write('Uses: ' + ', '.join(u) + '.\n')
f.write('</para>\n')
@@ -216,15 +215,15 @@ class SCons_XML_to_man(SCons_XML):
for v in self.values:
chunks.extend(v.mansep())
chunks.extend(v.initial_chunks())
- chunks.extend(map(str, v.summary.body))
+ chunks.extend(list(map(str, v.summary.body)))
body = ''.join(chunks)
- body = string.replace(body, '<programlisting>', '.ES')
- body = string.replace(body, '</programlisting>', '.EE')
- body = string.replace(body, '\n</para>\n<para>\n', '\n\n')
- body = string.replace(body, '<para>\n', '')
- body = string.replace(body, '<para>', '\n')
- body = string.replace(body, '</para>\n', '')
+ body = body.replace('<programlisting>', '.ES')
+ body = body.replace('</programlisting>', '.EE')
+ body = body.replace('\n</para>\n<para>\n', '\n\n')
+ body = body.replace('<para>\n', '')
+ body = body.replace('<para>', '\n')
+ body = body.replace('</para>\n', '')
body = string.replace(body, '<variablelist>\n', '.RS 10\n')
# Handling <varlistentry> needs to be rationalized and made
@@ -241,9 +240,9 @@ class SCons_XML_to_man(SCons_XML):
body = string.replace(body, '\n.IP\n\'\\"', '\n\n\'\\"')
body = re.sub('&(scons|SConstruct|SConscript|jar|Make|lambda);', r'\\fB\1\\fP', body)
body = re.sub('&(TARGET|TARGETS|SOURCE|SOURCES);', r'\\fB$\1\\fP', body)
- body = string.replace(body, '&Dir;', r'\fBDir\fP')
- body = string.replace(body, '&target;', r'\fItarget\fP')
- body = string.replace(body, '&source;', r'\fIsource\fP')
+ body = body.replace('&Dir;', r'\fBDir\fP')
+ body = body.replace('&target;', r'\fItarget\fP')
+ body = body.replace('&source;', r'\fIsource\fP')
body = re.sub('&b(-link)?-([^;]*);', r'\\fB\2\\fP()', body)
body = re.sub('&cv(-link)?-([^;]*);', r'$\2', body)
body = re.sub('&f(-link)?-env-([^;]*);', r'\\fBenv.\2\\fP()', body)
@@ -258,8 +257,8 @@ class SCons_XML_to_man(SCons_XML):
body = re.compile(r'^(\S+)\\f([BI])(.*)\\fP$', re.M).sub(r'.R\2 \1 \3', body)
body = re.compile(r'^(\S+)\\f([BI])(.*)\\fP([^\s\\]+)$', re.M).sub(r'.R\2 \1 \3 \4', body)
body = re.compile(r'^(\.R[BI].*[\S])\s+$;', re.M).sub(r'\1', body)
- body = string.replace(body, '&lt;', '<')
- body = string.replace(body, '&gt;', '>')
+ body = body.replace('&lt;', '<')
+ body = body.replace('&gt;', '>')
body = re.sub(r'\\([^f])', r'\\\\\1', body)
body = re.compile("^'\\\\\\\\", re.M).sub("'\\\\", body)
body = re.compile(r'^\.([BI]R?) --', re.M).sub(r'.\1 \-\-', body)
diff --git a/bin/scons-test.py b/bin/scons-test.py
index aa03d72e..8d1950f1 100644
--- a/bin/scons-test.py
+++ b/bin/scons-test.py
@@ -19,7 +19,6 @@ import getopt
import imp
import os
import os.path
-import string
import sys
import tempfile
import time
@@ -90,7 +89,7 @@ def outname(n, outdir=outdir):
l.append(tail)
l.append(outdir)
l.reverse()
- return apply(os.path.join, l)
+ return os.path.join(*l)
for name in zf.namelist():
dest = outname(name)
@@ -135,7 +134,7 @@ fp.close()
if not args:
runtest_args = '-a'
else:
- runtest_args = string.join(args)
+ runtest_args = ' '.join(args)
if format == '--xml':
diff --git a/bin/scons-unzip.py b/bin/scons-unzip.py
index 28c73f88..c0eb8aa9 100644
--- a/bin/scons-unzip.py
+++ b/bin/scons-unzip.py
@@ -52,7 +52,7 @@ def outname(n, outdir=outdir):
l.append(tail)
l.append(outdir)
l.reverse()
- return apply(os.path.join, l)
+ return os.path.join(*l)
for name in zf.namelist():
dest = outname(name)
diff --git a/bin/sconsexamples.py b/bin/sconsexamples.py
index 0a409bcd..6f20ae96 100644
--- a/bin/sconsexamples.py
+++ b/bin/sconsexamples.py
@@ -67,12 +67,12 @@
# Error output gets passed through to your error output so you
# can see if there are any problems executing the command.
#
+from __future__ import generators ### KEEP FOR COMPATIBILITY FIXERS
import os
import os.path
import re
import sgmllib
-import string
import sys
sys.path.append(os.path.join(os.getcwd(), 'etc'))
@@ -156,7 +156,6 @@ Prompt = {
# command output.
Stdin = """\
-import string
import SCons.Defaults
platform = '%s'
@@ -174,13 +173,13 @@ class Curry:
else:
kw = kwargs or self.kwargs
- return apply(self.fun, self.pending + args, kw)
+ return self.fun(*self.pending + args, **kw)
def Str(target, source, env, cmd=""):
result = []
for cmd in env.subst_list(cmd, target=target, source=source):
- result.append(string.join(map(str, cmd)))
- return string.join(result, '\\n')
+ result.append(" ".join(map(str, cmd)))
+ return '\\n'.join(result)
class ToolSurrogate:
def __init__(self, tool, variable, func):
@@ -212,7 +211,7 @@ ToolList = {
('mslink', 'LINKCOM', Cat)]
}
-tools = map(lambda t: apply(ToolSurrogate, t), ToolList[platform])
+tools = map(lambda t: ToolSurrogate(*t), ToolList[platform])
SCons.Defaults.ConstructionEnvironment.update({
'PLATFORM' : platform,
@@ -270,7 +269,7 @@ class MySGML(sgmllib.SGMLParser):
sys.stdout.write('&#' + ref + ';')
def start_scons_example(self, attrs):
- t = filter(lambda t: t[0] == 'name', attrs)
+ t = [t for t in attrs if t[0] == 'name']
if t:
name = t[0][1]
try:
@@ -286,7 +285,7 @@ class MySGML(sgmllib.SGMLParser):
def end_scons_example(self):
e = self.e
- files = filter(lambda f: f.printme, e.files)
+ files = [f for f in e.files if f.printme]
if files:
sys.stdout.write('<programlisting>')
for f in files:
@@ -294,7 +293,7 @@ class MySGML(sgmllib.SGMLParser):
i = len(f.data) - 1
while f.data[i] == ' ':
i = i - 1
- output = string.replace(f.data[:i+1], '__ROOT__', '')
+ output = f.data[:i+1].replace('__ROOT__', '')
sys.stdout.write(output)
if e.data and e.data[0] == '\n':
e.data = e.data[1:]
@@ -307,7 +306,7 @@ class MySGML(sgmllib.SGMLParser):
e = self.e
except AttributeError:
self.error("<file> tag outside of <scons_example>")
- t = filter(lambda t: t[0] == 'name', attrs)
+ t = [t for t in attrs if t[0] == 'name']
if not t:
self.error("no <file> name attribute found")
try:
@@ -331,7 +330,7 @@ class MySGML(sgmllib.SGMLParser):
e = self.e
except AttributeError:
self.error("<directory> tag outside of <scons_example>")
- t = filter(lambda t: t[0] == 'name', attrs)
+ t = [t for t in attrs if t[0] == 'name']
if not t:
self.error("no <directory> name attribute found")
try:
@@ -350,7 +349,7 @@ class MySGML(sgmllib.SGMLParser):
self.afunclist = self.afunclist[:-1]
def start_scons_example_file(self, attrs):
- t = filter(lambda t: t[0] == 'example', attrs)
+ t = [t for t in attrs if t[0] == 'example']
if not t:
self.error("no <scons_example_file> example attribute found")
exname = t[0][1]
@@ -358,11 +357,11 @@ class MySGML(sgmllib.SGMLParser):
e = self.examples[exname]
except KeyError:
self.error("unknown example name '%s'" % exname)
- fattrs = filter(lambda t: t[0] == 'name', attrs)
+ fattrs = [t for t in attrs if t[0] == 'name']
if not fattrs:
self.error("no <scons_example_file> name attribute found")
fname = fattrs[0][1]
- f = filter(lambda f, fname=fname: f.name == fname, e.files)
+ f = [f for f in e.files if f.name == fname]
if not f:
self.error("example '%s' does not have a file named '%s'" % (exname, fname))
self.f = f[0]
@@ -377,7 +376,7 @@ class MySGML(sgmllib.SGMLParser):
delattr(self, 'f')
def start_scons_output(self, attrs):
- t = filter(lambda t: t[0] == 'example', attrs)
+ t = [t for t in attrs if t[0] == 'example']
if not t:
self.error("no <scons_output> example attribute found")
exname = t[0][1]
@@ -408,20 +407,19 @@ class MySGML(sgmllib.SGMLParser):
i = 0
while f.data[i] == '\n':
i = i + 1
- lines = string.split(f.data[i:], '\n')
+ lines = f.data[i:].split('\n')
i = 0
while lines[0][i] == ' ':
i = i + 1
- lines = map(lambda l, i=i: l[i:], lines)
- path = string.replace(f.name, '__ROOT__', t.workpath('ROOT'))
+ lines = [l[i:] for l in lines]
+ path = f.name.replace('__ROOT__', t.workpath('ROOT'))
dir, name = os.path.split(f.name)
if dir:
dir = t.workpath('WORK', dir)
if not os.path.exists(dir):
os.makedirs(dir)
- content = string.join(lines, '\n')
- content = string.replace(content,
- '__ROOT__',
+ content = '\n'.join(lines)
+ content = content.replace('__ROOT__',
t.workpath('ROOT'))
t.write(t.workpath('WORK', f.name), content)
i = len(o.prefix)
@@ -431,19 +429,19 @@ class MySGML(sgmllib.SGMLParser):
p = o.prefix[i:]
for c in o.commandlist:
sys.stdout.write(p + Prompt[o.os])
- d = string.replace(c.data, '__ROOT__', '')
+ d = c.data.replace('__ROOT__', '')
sys.stdout.write('<userinput>' + d + '</userinput>\n')
- e = string.replace(c.data, '__ROOT__', t.workpath('ROOT'))
- args = string.split(e)[1:]
+ e = c.data.replace('__ROOT__', t.workpath('ROOT'))
+ args = e.split()[1:]
os.environ['SCONS_LIB_DIR'] = scons_lib_dir
t.run(interpreter = sys.executable,
program = scons_py,
- arguments = '-f - ' + string.join(args),
+ arguments = '-f - ' + ' '.join(args),
chdir = t.workpath('WORK'),
stdin = Stdin % o.os)
- out = string.replace(t.stdout(), t.workpath('ROOT'), '')
+ out = t.stdout().replace(t.workpath('ROOT'), '')
if out:
- lines = string.split(out, '\n')
+ lines = out.split('\n')
if lines:
while lines[-1] == '':
lines = lines[:-1]
diff --git a/bin/sfsum b/bin/sfsum
index a560b7da..22f43d77 100644
--- a/bin/sfsum
+++ b/bin/sfsum
@@ -25,7 +25,6 @@
import xml.sax
import xml.sax.saxutils
-import string
import sys
SFName = {
@@ -51,7 +50,7 @@ Artifacts = {}
def nws(text):
"""Normalize white space. This will become important if/when
we enhance this to search for arbitrary fields."""
- return string.join(string.split(text), ' ')
+ return ' '.join(text.split())
class ClassifyArtifacts(xml.sax.saxutils.DefaultHandler):
"""