def __call__(self):
pass
+import collections
import io
import os
import re
import sys
import types
import unittest
-import UserDict
import SCons.Action
import SCons.Environment
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import UserDict
-import UserList
+import collections
import SCons.Action
from SCons.Debug import logInstanceCreation
target, source = emitter(target, source, env)
return (target, source)
-class ListEmitter(UserList.UserList):
+class ListEmitter(collections.UserList):
"""A callable list of emitters that calls each in sequence,
returning the result.
"""
'sources' : 'source',
}
-class OverrideWarner(UserDict.UserDict):
+class OverrideWarner(collections.UserDict):
"""A class for warning about keyword arguments that we use as
overrides in a Builder call.
warnings once, no matter how many Builders are invoked.
"""
def __init__(self, dict):
- UserDict.UserDict.__init__(self, dict)
+ collections.UserDict.__init__(self, dict)
if __debug__: logInstanceCreation(self, 'Builder.OverrideWarner')
self.already_warned = None
def warn(self):
def Func():
pass
+import collections
import io
import os.path
import re
import sys
import unittest
-import UserList
import TestCmd
assert not hasattr(n2, 'env')
l = [1]
- ul = UserList.UserList([2])
+ ul = collections.UserList([2])
try:
l.extend(ul)
except TypeError:
assert env['CNT'][0] == 2
tgts = builder(env, None, infiles[2:4])
try:
- [].extend(UserList.UserList())
+ [].extend(collections.UserList())
except TypeError:
# Old Python version (1.5.2) that can't handle extending
# a list with list-like objects. That means the return
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import SCons.compat
+
import os
import os.path
import StringIO
import sys
import unittest
-from UserDict import UserDict
+from collections import UserDict
import TestCmd
import sys
import re
import shlex
-from UserDict import UserDict
+from collections import UserDict
import SCons.Action
import SCons.Builder
import SCons.compat
+import collections
import copy
import io
import os
import sys
import TestCmd
import unittest
-import UserList
from SCons.Environment import *
import SCons.Warnings
-class CLVar(UserList.UserList):
+class CLVar(collections.UserList):
def __init__(self, seq):
if isinstance(seq, str):
seq = seq.split()
- UserList.UserList.__init__(self, seq)
+ collections.UserList.__init__(self, seq)
def __add__(self, other):
- return UserList.UserList.__add__(self, CLVar(other))
+ return collections.UserList.__add__(self, CLVar(other))
def __radd__(self, other):
- return UserList.UserList.__radd__(self, CLVar(other))
+ return collections.UserList.__radd__(self, CLVar(other))
def __coerce__(self, other):
return (self, CLVar(other))
assert b1 == b2, diff_dict(b1, b2)
import UserDict
- UD = UserDict.UserDict
+ UD = collections.UserDict
import UserList
- UL = UserList.UserList
+ UL = collections.UserList
cases = [
'a1', 'A1', 'a1A1',
"""Test prepending to construction variables in an Environment
"""
import UserDict
- UD = UserDict.UserDict
+ UD = collections.UserDict
import UserList
- UL = UserList.UserList
+ UL = collections.UserList
cases = [
'a1', 'A1', 'A1a1',
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import UserList
+import collections
from SCons.Debug import logInstanceCreation
import SCons.Errors
-class TSList(UserList.UserList):
+class TSList(collections.UserList):
"""A class that implements $TARGETS or $SOURCES expansions by wrapping
an executor Method. This class is used in the Executor.lvars()
to delay creation of NodeList objects until they're needed.
- Note that we subclass UserList.UserList purely so that the
+ Note that we subclass collections.UserList purely so that the
is_Sequence() function will identify an object of this class as
a list during variable expansion. We're not really using any
- UserList.UserList methods in practice.
+ collections.UserList methods in practice.
"""
def __init__(self, func):
self.func = func
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import UserDict
+import collections
import SCons.Errors
import SCons.Node
import SCons.Util
-class AliasNameSpace(UserDict.UserDict):
+class AliasNameSpace(collections.UserDict):
def Alias(self, name, **kw):
if isinstance(name, SCons.Node.Alias.Alias):
return name
try:
eval('test_string = u"Con\x1aTents\n"')
except SyntaxError:
- import UserString
- class FakeUnicodeString(UserString.UserString):
+ import collections
+ class FakeUnicodeString(collections.UserString):
def encode(self, encoding):
return str(self)
test_string = FakeUnicodeString("Con\x1aTents\n")
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import collections
import os
import re
import sys
import unittest
-import UserList
import SCons.Errors
import SCons.Node
nl = SCons.Node.NodeList([n3, n2, n1])
l = [1]
- ul = UserList.UserList([2])
+ ul = collections.UserList([2])
try:
l.extend(ul)
except TypeError:
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import collections
import copy
from itertools import chain, izip
-import UserList
from SCons.Debug import logInstanceCreation
import SCons.Executor
return ( ' '*11).join(lines)
try:
- [].extend(UserList.UserList([]))
+ [].extend(collections.UserList([]))
except TypeError:
# Python 1.5.2 doesn't allow a list to be extended by list-like
# objects (such as UserList instances), so just punt and use
def NodeList(l):
return l
else:
- class NodeList(UserList.UserList):
+ class NodeList(collections.UserList):
def __str__(self):
return str(list(map(str, self.data)))
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import collections
import sys
import unittest
import SCons.Errors
import SCons.Platform
-import UserDict
-class Environment(UserDict.UserDict):
+class Environment(collections.UserDict):
def Detect(self, cmd):
return cmd
def AppendENVPath(self, key, value):
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import collections
import os
-import os.path
import sys
import TestCmd
import unittest
-import UserDict
import SCons.Node.FS
import SCons.Warnings
# define some helpers:
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
def __init__(self, **kw):
- UserDict.UserDict.__init__(self)
+ collections.UserDict.__init__(self)
self.data.update(kw)
self.fs = SCons.Node.FS.FS(test.workpath(''))
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import os.path
+import collections
+import os
import sys
import unittest
-import UserDict
import TestCmd
import SCons.Node.FS
# define some helpers:
# copied from CTest.py
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
def __init__(self, **kw):
- UserDict.UserDict.__init__(self)
+ collections.UserDict.__init__(self)
self.data.update(kw)
self.fs = SCons.Node.FS.FS(test.workpath(''))
import SCons.Scanner.RC
import unittest
import sys
+import collections
import os
-import os.path
import SCons.Node.FS
import SCons.Warnings
-import UserDict
test = TestCmd.TestCmd(workdir = '')
# define some helpers:
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
def __init__(self,**kw):
- UserDict.UserDict.__init__(self)
+ collections.UserDict.__init__(self)
self.data.update(kw)
self.fs = SCons.Node.FS.FS(test.workpath(''))
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import collections
import sys
import unittest
-import UserDict
import SCons.Scanner
def File(self, name):
return DummyNode(name)
-class DummyEnvironment(UserDict.UserDict):
+class DummyEnvironment(collections.UserDict):
def __init__(self, dict=None, **kw):
- UserDict.UserDict.__init__(self, dict)
+ collections.UserDict.__init__(self, dict)
self.data.update(kw)
self.fs = DummyFS()
def subst(self, strSubst, target=None, source=None, conv=None):
import SCons.Tool
import SCons.Util
+import collections
import os
import os.path
import re
import sys
import traceback
-import UserList
# The following variables used to live in this module. Some
# SConscript files out there may have referred to them directly as
import time
start_time = time.time()
+import collections
import os
import sys
-import UserList
# Special chicken-and-egg handling of the "--debug=memoizer" flag:
#
DefaultEnvironment = SCons.Defaults.DefaultEnvironment
# Other variables we provide.
-class TargetList(UserList.UserList):
+class TargetList(collections.UserList):
def _do_nothing(self, *args, **kw):
pass
def _add_Default(self, list):
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import collections
import re
-import UserList
-import UserString
import SCons.Errors
else:
return str(arg)
-class CmdStringHolder(UserString.UserString):
+class CmdStringHolder(collections.UserString):
"""This is a special class used to hold strings generated by
scons_subst() and scons_subst_list(). It defines a special method
escape(). When passed a function with an escape algorithm for a
proper escape sequences inserted.
"""
def __init__(self, cmd, literal=None):
- UserString.UserString.__init__(self, cmd)
+ collections.UserString.__init__(self, cmd)
self.literal = literal
def is_literal(self):
_create_nodelist = _gen_nodelist
-class Targets_or_Sources(UserList.UserList):
+class Targets_or_Sources(collections.UserList):
"""A class that implements $TARGETS or $SOURCES expansions by in turn
wrapping a NLWrapper. This class handles the different methods used
to access the list, calling the NLWrapper to create proxies on demand.
- Note that we subclass UserList.UserList purely so that the
+ Note that we subclass collections.UserList purely so that the
is_Sequence() function will identify an object of this class as
a list during variable expansion. We're not really using any
- UserList.UserList methods in practice.
+ collections.UserList methods in practice.
"""
def __init__(self, nl):
self.nl = nl
# Subst_List_Strings[strSubst] = 1
# import SCons.Debug
# SCons.Debug.caller_trace(1)
- class ListSubber(UserList.UserList):
+ class ListSubber(collections.UserList):
"""A class to construct the results of a scons_subst_list() call.
Like StringSubber, this class binds a specific construction
internally.
"""
def __init__(self, env, mode, conv, gvars):
- UserList.UserList.__init__(self, [])
+ collections.UserList.__init__(self, [])
self.env = env
self.mode = mode
self.conv = conv
"""Arrange for the next word to start a new line. This
is like starting a new word, except that we have to append
another line to the result."""
- UserList.UserList.append(self, [])
+ collections.UserList.append(self, [])
self.next_word()
def this_word(self):
import sys
import unittest
-from UserDict import UserDict
+from collections import UserDict
import SCons.Errors
'T' : ('x', 'y'),
'CS' : cs,
'CL' : cl,
- 'US' : UserString.UserString('us'),
+ 'US' : collections.UserString('us'),
# Test function calls within ${}.
'FUNCCALL' : '${FUNC1("$AAA $FUNC2 $BBB")}',
'$CL', 'cl',
# Various uses of UserString.
- UserString.UserString('x'), 'x',
- UserString.UserString('$X'), 'x',
- UserString.UserString('$US'), 'us',
+ collections.UserString('x'), 'x',
+ collections.UserString('$X'), 'x',
+ collections.UserString('$US'), 'us',
'$US', 'us',
# Test function calls within ${}.
['$CL'], [['cl']],
# Various uses of UserString.
- UserString.UserString('x'), [['x']],
- [UserString.UserString('x')], [['x']],
- UserString.UserString('$X'), [['x']],
- [UserString.UserString('$X')], [['x']],
- UserString.UserString('$US'), [['us']],
- [UserString.UserString('$US')], [['us']],
+ collections.UserString('x'), [['x']],
+ [collections.UserString('x')], [['x']],
+ collections.UserString('$X'), [['x']],
+ [collections.UserString('$X')], [['x']],
+ collections.UserString('$US'), [['us']],
+ [collections.UserString('$US')], [['us']],
'$US', [['us']],
['$US'], [['us']],
import sys
import types
-from UserDict import UserDict
-from UserList import UserList
-from UserString import UserString
+from collections import UserDict, UserList, UserString
# Don't "from types import ..." these because we need to get at the
# types module later to look for UnicodeType.
import SCons.compat
+import collections
import io
import os
-import os.path
import sys
import unittest
-from UserDict import UserDict
import TestCmd
def test_is_Dict(self):
assert is_Dict({})
- assert is_Dict(UserDict())
+ assert is_Dict(collections.UserDict())
try:
class mydict(dict):
pass
def test_is_List(self):
assert is_List([])
import UserList
- assert is_List(UserList.UserList())
+ assert is_List(collections.UserList())
try:
class mylist(list):
pass
except:
pass
else:
- assert is_String(UserString.UserString(''))
+ assert is_String(collections.UserString(''))
try:
class mystr(str):
pass
try:
import UserString
- s1=UserString.UserString('blah')
+ s1=collections.UserString('blah')
assert to_String(s1) == s1, s1
assert to_String(s1) == 'blah', s1
- class Derived(UserString.UserString):
+ class Derived(collections.UserString):
pass
s2 = Derived('foo')
assert to_String(s2) == s2, s2
assert to_String(s2) == 'foo', s2
if HasUnicode:
- s3=UserString.UserString(unicode('bar'))
+ s3=collections.UserString(unicode('bar'))
assert to_String(s3) == s3, s3
assert to_String(s3) == unicode('bar'), s3
assert isinstance(to_String(s3), unicode), \
s['c'] = 'CCC'
assert s['c'] == 'CCC', s['c']
- class DummyEnv(UserDict):
+ class DummyEnv(collections.UserDict):
def subst(self, key):
if key[0] == '$':
return self[key[1:]]
__all__ = ['ListVariable',]
-import UserList
+import collections
import SCons.Util
-class _ListVariable(UserList.UserList):
+class _ListVariable(collections.UserList):
def __init__(self, initlist=[], allowedElems=[]):
- UserList.UserList.__init__(self, [_f for _f in initlist if _f])
+ collections.UserList.__init__(self, [_f for _f in initlist if _f])
self.allowedElems = sorted(allowedElems)
def __cmp__(self, other):
import __builtin__, sets
__builtin__.set = sets.Set
+
+import collections
+try:
+ collections.UserDict
+except AttributeError:
+ import UserDict
+ collections.UserDict = UserDict.UserDict
+ del UserDict
+try:
+ collections.UserList
+except AttributeError:
+ import UserList
+ collections.UserList = UserList.UserList
+ del UserList
+try:
+ collections.UserString
+except AttributeError:
+ import UserString
+ collections.UserString = UserString.UserString
+ del UserString
+
+
import fnmatch
try:
fnmatch.filter
# Wrapping sys in () is silly, but protects it from 2to3 renames fixer
sys.maxsize = (sys).maxint
-try:
- import UserString
-except ImportError:
- # Pre-1.6 Python has no UserString module.
- import_as('_scons_UserString', 'UserString')
import tempfile
try:
+++ /dev/null
-#
-# __COPYRIGHT__
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-__doc__ = """
-A user-defined wrapper around string objects
-
-This class is "borrowed" from the Python 2.2 UserString and modified
-slightly for use with SCons. It is *NOT* guaranteed to be fully compliant
-with the standard UserString class from all later versions of Python.
-In particular, it does not necessarily contain all of the methods found
-in later versions.
-"""
-
-try: unicode
-except NameError:
- def is_String(obj):
- return isinstance(obj, str)
-else:
- def is_String(obj):
- return type(obj) in (str, unicode)
-
-class UserString:
- def __init__(self, seq):
- if is_String(seq):
- self.data = seq
- elif isinstance(seq, UserString):
- self.data = seq.data[:]
- else:
- self.data = str(seq)
- def __str__(self): return str(self.data)
- def __repr__(self): return repr(self.data)
- def __int__(self): return int(self.data)
- def __long__(self): return long(self.data)
- def __float__(self): return float(self.data)
- def __complex__(self): return complex(self.data)
- def __hash__(self): return hash(self.data)
-
- def __cmp__(self, str):
- if isinstance(string, UserString):
- return cmp(self.data, str.data)
- else:
- return cmp(self.data, string)
- def __contains__(self, char):
- return char in self.data
-
- def __len__(self): return len(self.data)
- def __getitem__(self, index): return self.__class__(self.data[index])
- def __getslice__(self, start, end):
- start = max(start, 0); end = max(end, 0)
- return self.__class__(self.data[start:end])
-
- def __add__(self, other):
- if isinstance(other, UserString):
- return self.__class__(self.data + other.data)
- elif is_String(other):
- return self.__class__(self.data + other)
- else:
- return self.__class__(self.data + str(other))
- def __radd__(self, other):
- if is_String(other):
- return self.__class__(other + self.data)
- else:
- return self.__class__(str(other) + self.data)
- def __mul__(self, n):
- return self.__class__(self.data*n)
- __rmul__ = __mul__
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:
SConscript('SConscript5')
-import UserList
+try:
+ from io import UserList
+except ImportError:
+ from UserList import UserList
x7 = "SConstruct x7"
x8 = "SConstruct x8"
-x9 = SConscript('SConscript6', UserList.UserList(["x7", "x8"]))
+x9 = SConscript('SConscript6', UserList(["x7", "x8"]))
assert x9 == "SConscript6 x9", x9
SConscript('SConscript7')
env = my_Environment()
env.Command('f0.out', 'f0.in', copy_action)
-from UserString import UserString
+try:
+ from io import UserString
+except ImportError:
+ from UserString import UserString
try:
class mystr(str):
pass