# The subprocess module doesn't exist in this version of Python,
# so we're going to cobble up something that looks just enough
# like its API for our purposes below.
- import new
-
- subprocess = new.module('subprocess')
+ from types import ModuleType
+ class subprocess(ModuleType): pass
subprocess.PIPE = 'PIPE'
subprocess.STDOUT = 'STDOUT'
for root, dirs, files in os.walk(source_dir):
if '.svn' in dirs:
dirs.remove('.svn')
- # TODO(1.5)
- #dirs = [ d for d in dirs if not d.startswith('TimeSCons-') ]
- #files = [ f for f in files if not f.startswith('TimeSCons-') ]
- not_timescons_entries = lambda s: not s.startswith('TimeSCons-')
- dirs = list(filter(not_timescons_entries, dirs))
- files = list(filter(not_timescons_entries, files))
+ dirs = [ d for d in dirs if not d.startswith('TimeSCons-') ]
+ files = [ f for f in files if not f.startswith('TimeSCons-') ]
for dirname in dirs:
source = os.path.join(root, dirname)
destination = source.replace(source_dir, dest_dir)
testFnNames = testFnNames + \
getTestCaseNames(baseclass, prefix, sortUsing=None)
if sortUsing:
- testFnNames.sort(sortUsing)
+ # sortUsing is only either 'None' or 'cmp' so don't bother with arg
+ # which is not supported in Py3k.
+ #testFnNames.sort(sortUsing)
+ testFnNames.sort()
return testFnNames
if suffixes:
matchsuf = [S for S in suffixes if path[-len(S):] == S]
if matchsuf:
- suf = max(list(map(None, list(map(len, matchsuf)), matchsuf)))[1]
+ suf = max([(len(_f),_f) for _f in matchsuf])[1]
return [path[:-len(suf)], path[-len(suf):]]
return SCons.Util.splitext(path)
import SCons.compat
-import collections
import copy
import io
import os
import sys
import TestCmd
import unittest
+from collections import UserDict as UD, UserList as UL
from SCons.Environment import *
import SCons.Warnings
-class CLVar(collections.UserList):
+class CLVar(UL):
def __init__(self, seq):
if isinstance(seq, str):
seq = seq.split()
- collections.UserList.__init__(self, seq)
+ UL.__init__(self, seq)
def __add__(self, other):
- return collections.UserList.__add__(self, CLVar(other))
+ return UL.__add__(self, CLVar(other))
def __radd__(self, other):
- return collections.UserList.__radd__(self, CLVar(other))
+ return UL.__radd__(self, CLVar(other))
def __coerce__(self, other):
return (self, CLVar(other))
b2 = Environment()['BUILDERS']
assert b1 == b2, diff_dict(b1, b2)
- import UserDict
- UD = collections.UserDict
- import UserList
- UL = collections.UserList
-
cases = [
'a1', 'A1', 'a1A1',
'a2', ['A2'], ['a2', 'A2'],
def test_Prepend(self):
"""Test prepending to construction variables in an Environment
"""
- import UserDict
- UD = collections.UserDict
- import UserList
- UL = collections.UserList
-
cases = [
'a1', 'A1', 'A1a1',
'a2', ['A2'], ['A2', 'a2'],
if strings:
r = [os.path.join(str(dir), x) for x in r]
result.extend(r)
- result.sort(lambda a, b: cmp(str(a), str(b)))
- return result
+ return sorted(result, key=lambda a: str(a))
def _glob1(self, pattern, ondisk=True, source=False, strings=False):
"""
for input, string_expect, node_expect in cases:
r = self.fs.Glob(input, **kwargs)
if node_expect:
- r.sort(lambda a,b: cmp(a.path, b.path))
+ r = sorted(r, key=lambda a: a.path)
result = []
for n in node_expect:
if isinstance(n, str):
self.stats.append(SCons.Debug.memory())
def do_print(self):
fmt = 'Memory %-32s %12d\n'
- for label, stats in map(None, self.labels, self.stats):
+ for label, stats in zip(self.labels, self.stats):
self.outfp.write(fmt % (label, stats))
memory_stats = MemStats()
"%(build)3d "
def dump_stats():
- StatsNodes.sort(lambda a, b: cmp(str(a), str(b)))
- for n in StatsNodes:
+ for n in sorted(StatsNodes, key=lambda a: str(a)):
print (fmt % n.stats.__dict__) + str(n)
"""
if sort:
- options = sorted(self.options, cmp=lambda x,y: sort(x.key,y.key))
+ options = sorted(self.options, key=lambda x: x.key)
else:
options = self.options
os.path.lexists = lexists
-try:
- # Use the "imp" module to protect the import from fixers.
- import imp
- _cPickle = imp.load_module('cPickle', *imp.find_module('cPickle'))
-except ImportError, e:
- # The "cPickle" module has already been eliminated in favor of
- # having "import pickle" import the fast version when available.
- pass
-else:
- import sys
- sys.modules['pickle'] = _cPickle
- del _cPickle
+# When we're using the '-3' option during regression tests, importing
+# cPickle gives a warning no matter how it's done, so always use the
+# real profile module, whether it's fast or not.
+if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is None:
+ # Not a regression test with '-3', so try to use faster version.
+ try:
+ # Use the "imp" module to protect the import from fixers.
+ import imp
+ _cPickle = imp.load_module('cPickle', *imp.find_module('cPickle'))
+ except ImportError, e:
+ # The "cPickle" module has already been eliminated in favor of
+ # having "import pickle" import the fast version when available.
+ pass
+ else:
+ import sys
+ sys.modules['pickle'] = _cPickle
+ del _cPickle
try:
del mkstemp
+if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is not None:
+ # We can't apply the 'callable' fixer until the floor is 2.6, but the
+ # '-3' option to Python 2.6 and 2.7 generates almost ten thousand
+ # warnings. This hack allows us to run regression tests with the '-3'
+ # option by replacing the callable() built-in function with a hack
+ # that performs the same function but doesn't generate the warning.
+ # Note that this hack is ONLY intended to be used for regression
+ # testing, and should NEVER be used for real runs.
+ from types import ClassType
+ def callable(obj):
+ if hasattr(obj, '__call__'): return True
+ if isinstance(obj, (ClassType, type)): return True
+ return False
+ import builtins
+ builtins.callable = callable
+ del callable
+
+
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# Pre-2.2 Python has no False keyword.
builtins.False = not 1
# Assign to False in this module namespace so it shows up in pydoc output.
- False = False
+ #False = False
try:
True
# Pre-2.2 Python has no True keyword.
builtins.True = not 0
# Assign to True in this module namespace so it shows up in pydoc output.
- True = True
+ #True = True
try:
file
# re module, as late as version 2.2.2, empirically matches the
# "!" in "!=" first, instead of finding the longest match.
# What's up with that?
-l = sorted(CPP_to_Python_Ops_Dict.keys(), cmp=lambda a, b: cmp(len(b), len(a)))
+l = sorted(CPP_to_Python_Ops_Dict.keys(), key=lambda a: len(a), reverse=True)
# Turn the list of keys into one regular expression that will allow us
# to substitute all of the operators at once.
real1 = [os.path.exists(str(N)) for N in Nodes]
exists = [N.exists() for N in Nodes]
real2 = [os.path.exists(str(N)) for N in Nodes]
- for N,D,R,E,F in map(None, Nodes, derived, real1, exists, real2):
+ for N,D,R,E,F in zip(Nodes, derived, real1, exists, real2):
print '%%s: %%s %%s %%s %%s'%%(N,D,R,E,F)
foo.SharedLibrary(target = 'foo', source = 'foo%(_obj)s')
bar.SharedLibrary(target = 'bar', source = 'bar%(_obj)s')
def x1():
print "running x1"
def x2(n):
- print "running x2(%s)" % `n`
+ print "running x2(%s)" % repr(n)
def x3(n, kwd=None):
- print "running x3(%s, kwd=%s)" % (`n`, `kwd`)
+ print "running x3(%s, kwd=%s)" % (repr(n), repr(kwd))
register(x3, "no kwd args")
register(x1)