summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-12-28 07:17:31 (GMT)
committerSteven Knight <knight@baldmt.com>2002-12-28 07:17:31 (GMT)
commitee46aa600c5aa266f0904c686e656ab545375820 (patch)
tree733a58e6a58301011d17feb2054dba6c9b981aa4
parent474383d6f14d1594ad394c22afd837d1522175e9 (diff)
downloadSCons-ee46aa600c5aa266f0904c686e656ab545375820.zip
SCons-ee46aa600c5aa266f0904c686e656ab545375820.tar.gz
SCons-ee46aa600c5aa266f0904c686e656ab545375820.tar.bz2
Change the Action object execute() methods to __call__() methods.
-rw-r--r--src/engine/SCons/Action.py13
-rw-r--r--src/engine/SCons/ActionTests.py52
-rw-r--r--src/engine/SCons/Node/FS.py16
-rw-r--r--src/engine/SCons/Node/FSTests.py16
-rw-r--r--src/engine/SCons/Node/NodeTests.py2
-rw-r--r--src/engine/SCons/Node/__init__.py2
6 files changed, 50 insertions, 51 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index d36c860..d8a08be 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -197,7 +197,7 @@ class CommandAction(ActionBase):
def __init__(self, cmd):
self.cmd_list = cmd
- def execute(self, target, source, env):
+ def __call__(self, target, source, env):
"""Execute a command action.
This will handle lists of commands as well as individual commands,
@@ -286,11 +286,12 @@ class CommandGeneratorAction(ActionBase):
raise SCons.Errors.UserError("Object returned from command generator: %s cannot be used to create an Action." % repr(ret))
return gen_cmd
- def execute(self, target, source, env):
+ def __call__(self, target, source, env):
if not SCons.Util.is_List(source):
source = [source]
rsources = map(rfile, source)
- return self.__generate(target, source, env, 0).execute(target, rsources, env)
+ act = self.__generate(target, source, env, 0)
+ return act(target, rsources, env)
def get_contents(self, target, source, env):
"""Return the signature contents of this action's command line.
@@ -342,7 +343,7 @@ class FunctionAction(ActionBase):
return "%s(%s, %s)" % (name, tstr, sstr)
self.strfunction = strfunction
- def execute(self, target, source, env):
+ def __call__(self, target, source, env):
r = 0
if not SCons.Util.is_List(target):
target = [target]
@@ -381,9 +382,9 @@ class ListAction(ActionBase):
def get_actions(self):
return self.list
- def execute(self, target, source, env):
+ def __call__(self, target, source, env):
for l in self.list:
- r = l.execute(target, source, env)
+ r = l(target, source, env)
if r:
return r
return 0
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 6c3f779..134f8ae 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -246,7 +246,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd1 = r'%s %s %s xyzzy' % (python, act_py, outfile)
act = SCons.Action.CommandAction(cmd1)
- r = act.execute([], [], Environment())
+ r = act([], [], Environment())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'xyzzy'\n", c
@@ -254,7 +254,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd2 = r'%s %s %s $TARGET' % (python, act_py, outfile)
act = SCons.Action.CommandAction(cmd2)
- r = act.execute('foo', [], Environment())
+ r = act('foo', [], Environment())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'foo'\n", c
@@ -262,7 +262,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd3 = r'%s %s %s ${TARGETS}' % (python, act_py, outfile)
act = SCons.Action.CommandAction(cmd3)
- r = act.execute(['aaa', 'bbb'], [], Environment())
+ r = act(['aaa', 'bbb'], [], Environment())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'aaa' 'bbb'\n", c
@@ -270,7 +270,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd4 = r'%s %s %s $SOURCES' % (python, act_py, outfile)
act = SCons.Action.CommandAction(cmd4)
- r = act.execute([], ['one', 'two'], Environment())
+ r = act([], ['one', 'two'], Environment())
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'one' 'two'\n", c
@@ -278,7 +278,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd4 = r'%s %s %s ${SOURCES[:2]}' % (python, act_py, outfile)
act = SCons.Action.CommandAction(cmd4)
- r = act.execute([],
+ r = act([],
source = ['three', 'four', 'five'],
env = Environment())
assert r == 0
@@ -288,7 +288,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd5 = r'%s %s %s $TARGET XYZZY' % (python, act_py, outfile)
act = SCons.Action.CommandAction(cmd5)
- r = act.execute(target = 'out5',
+ r = act(target = 'out5',
source = [],
env = Environment(ENV = {'XYZZY' : 'xyzzy'}))
assert r == 0
@@ -304,7 +304,7 @@ class CommandActionTestCase(unittest.TestCase):
cmd6 = r'%s %s %s ${TARGETS[1]} $TARGET ${SOURCES[:2]}' % (python, act_py, outfile)
act = SCons.Action.CommandAction(cmd6)
- r = act.execute(target = [Obj('111'), Obj('222')],
+ r = act(target = [Obj('111'), Obj('222')],
source = [Obj('333'), Obj('444'), Obj('555')],
env = Environment())
assert r == 0
@@ -325,7 +325,7 @@ class CommandActionTestCase(unittest.TestCase):
show_string = show_string + string + "\n"
act.show = my_show
- r = act.execute([], [], Environment())
+ r = act([], [], Environment())
assert r == 0
assert show_string == expect7, show_string
@@ -340,18 +340,18 @@ class CommandActionTestCase(unittest.TestCase):
# Test that a nonexistent command returns 127
act = SCons.Action.CommandAction(python + "_XyZzY_")
- r = act.execute([], [], Environment(out = outfile))
+ r = act([], [], Environment(out = outfile))
assert r == expect_nonexistent, "r == %d" % r
# Test that trying to execute a directory returns 126
dir, tail = os.path.split(python)
act = SCons.Action.CommandAction(dir)
- r = act.execute([], [], Environment(out = outfile))
+ r = act([], [], Environment(out = outfile))
assert r == expect_nonexecutable, "r == %d" % r
# Test that trying to execute a non-executable file returns 126
act = SCons.Action.CommandAction(outfile)
- r = act.execute([], [], Environment(out = outfile))
+ r = act([], [], Environment(out = outfile))
assert r == expect_nonexecutable, "r == %d" % r
def test_set_handler(self):
@@ -384,16 +384,16 @@ class CommandActionTestCase(unittest.TestCase):
assert 0, "should have gotten user error"
a = SCons.Action.CommandAction(["xyzzy"])
- a.execute([], [], Environment(SPAWN = func))
+ a([], [], Environment(SPAWN = func))
assert t.executed == [ 'xyzzy' ]
a = SCons.Action.CommandAction(["xyzzy"])
- a.execute([], [], Environment(SPAWN = func, SHELL = 'fake shell'))
+ a([], [], Environment(SPAWN = func, SHELL = 'fake shell'))
assert t.executed == [ 'xyzzy' ]
assert t.shell == 'fake shell'
a = SCons.Action.CommandAction([ LiteralStr("xyzzy") ])
- a.execute([], [], Environment(SPAWN = func, ESCAPE = escape_func))
+ a([], [], Environment(SPAWN = func, ESCAPE = escape_func))
assert t.executed == [ '**xyzzy**' ], t.executed
def test_get_raw_contents(self):
@@ -449,7 +449,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase):
self.dummy = 0
self.cmd = []
self.args = []
- a.execute([], [], env=Environment(FOO = 'foo baz\nbar ack',
+ a([], [], env=Environment(FOO = 'foo baz\nbar ack',
dummy = 1,
SPAWN = ch))
assert self.dummy == 1, self.dummy
@@ -458,7 +458,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase):
b = SCons.Action.CommandGeneratorAction(f2)
self.dummy = 0
- b.execute(target=[], source=[], env=Environment(foo = 'bar',
+ b(target=[], source=[], env=Environment(foo = 'bar',
dummy = 2 ))
assert self.dummy==2, self.dummy
del self.dummy
@@ -471,7 +471,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase):
def f3(target, source, env, for_signature):
return ''
c = SCons.Action.CommandGeneratorAction(f3)
- c.execute(target=[], source=DummyFile(self), env=Environment())
+ c(target=[], source=DummyFile(self), env=Environment())
assert self.rfile_called
def test_get_contents(self):
@@ -531,7 +531,7 @@ class FunctionActionTestCase(unittest.TestCase):
assert env.subst("$BAR") == 'foo bar', env.subst("$BAR")
return 0
a = SCons.Action.FunctionAction(f)
- a.execute(target=1, source=2, env=Environment(BAR = 'foo bar',
+ a(target=1, source=2, env=Environment(BAR = 'foo bar',
s = self))
assert self.inc == 1, self.inc
assert self.source == [2], self.source
@@ -549,9 +549,7 @@ class FunctionActionTestCase(unittest.TestCase):
act = SCons.Action.FunctionAction(function1)
r = None
try:
- r = act.execute(target = [outfile, outfile2],
- source=[],
- env=Environment())
+ r = act(target = [outfile, outfile2], source=[], env=Environment())
except SCons.Errors.BuildError:
pass
assert r == 1
@@ -566,7 +564,7 @@ class FunctionActionTestCase(unittest.TestCase):
open(env['out'], 'w').write("class1a\n")
act = SCons.Action.FunctionAction(class1a)
- r = act.execute([], [], Environment(out = outfile))
+ r = act([], [], Environment(out = outfile))
assert r.__class__ == class1a
c = test.read(outfile, 'r')
assert c == "class1a\n", c
@@ -577,7 +575,7 @@ class FunctionActionTestCase(unittest.TestCase):
return 2
act = SCons.Action.FunctionAction(class1b())
- r = act.execute([], [], Environment(out = outfile))
+ r = act([], [], Environment(out = outfile))
assert r == 2
c = test.read(outfile, 'r')
assert c == "class1b\n", c
@@ -589,7 +587,7 @@ class FunctionActionTestCase(unittest.TestCase):
self.string_it = 1
return None
act = SCons.Action.FunctionAction(build_it, string_it)
- r = act.execute([], [], Environment())
+ r = act([], [], Environment())
assert r == 0, r
assert self.build_it
assert self.string_it
@@ -635,7 +633,7 @@ class ListActionTestCase(unittest.TestCase):
s = env['s']
s.inc = s.inc + 1
a = SCons.Action.ListAction([f, f, f])
- a.execute([], [], Environment(s = self))
+ a([], [], Environment(s = self))
assert self.inc == 3, self.inc
cmd2 = r'%s %s %s syzygy' % (python, act_py, outfile)
@@ -653,7 +651,7 @@ class ListActionTestCase(unittest.TestCase):
def __init__(self, target, source, env):
open(env['out'], 'a').write("class2b\n")
act = SCons.Action.ListAction([cmd2, function2, class2a(), class2b])
- r = act.execute([], [], Environment(out = outfile))
+ r = act([], [], Environment(out = outfile))
assert r.__class__ == class2b
c = test.read(outfile, 'r')
assert c == "act.py: 'syzygy'\nfunction2\nclass2a\nclass2b\n", c
@@ -696,7 +694,7 @@ class LazyActionTestCase(unittest.TestCase):
s.test=1
return 0
a = SCons.Action.Action('$BAR')
- a.execute([], [], env=Environment(BAR = f, s = self))
+ a([], [], env=Environment(BAR = f, s = self))
assert self.test == 1, self.test
def test_get_contents(self):
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 626a22a..dee50df 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -83,7 +83,7 @@ def LinkFunc(target, source, env):
os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
return 0
-LinkAction = SCons.Action.Action(LinkFunc, None)
+Link = SCons.Action.Action(LinkFunc, None)
def LocalString(target, source):
return 'Local copy of %s from %s' % (target[0], source[0])
@@ -94,13 +94,13 @@ def UnlinkFunc(target, source, env):
os.unlink(target[0].path)
return 0
-UnlinkAction = SCons.Action.Action(UnlinkFunc, None)
+Unlink = SCons.Action.Action(UnlinkFunc, None)
def MkdirFunc(target, source, env):
os.mkdir(target[0].path)
return 0
-MkdirAction = SCons.Action.Action(MkdirFunc, None)
+Mkdir = SCons.Action.Action(MkdirFunc, None)
#
class ParentOfRoot:
@@ -882,7 +882,7 @@ class File(Entry):
for dirnode in listDirs:
dirnode._exists = 1
try:
- MkdirAction.execute(dirnode, None, None)
+ Mkdir(dirnode, None, None)
except OSError:
pass
@@ -905,7 +905,7 @@ class File(Entry):
if self.exists():
if self.builder and not self.precious:
- UnlinkAction.execute(self, None, None)
+ Unlink(self, None, None)
if hasattr(self, '_exists'):
delattr(self, '_exists')
else:
@@ -929,10 +929,10 @@ class File(Entry):
if src.exists() and src.abspath != self.abspath:
self._createDir()
try:
- UnlinkAction.execute(self, None, None)
+ Unlink(self, None, None)
except OSError:
pass
- LinkAction.execute(self, src, None)
+ Link(self, src, None)
self.created = 1
# Set our exists cache accordingly
@@ -952,7 +952,7 @@ class File(Entry):
# ...and it's even up-to-date...
if self._local:
# ...and they'd like a local copy.
- LocalCopy.execute(self, r, None)
+ LocalCopy(self, r, None)
self.set_bsig(bsig)
self.store_bsig()
return 1
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 98857bf..a624d97 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -50,7 +50,7 @@ class Builder:
def get_actions(self):
class Action:
- def execute(self, targets, sources, env):
+ def __call__(self, targets, sources, env):
global built_it
built_it = 1
return 0
@@ -255,13 +255,13 @@ class BuildDirTestCase(unittest.TestCase):
assert f8.rfile().path == os.path.normpath(test.workpath('rep1/build/var2/test2.out')),\
f8.rfile().path
- # Test to see if LinkAction() works...
+ # Test to see if Link() works...
test.subdir('src','build')
test.write('src/foo', 'src/foo\n')
os.chmod(test.workpath('src/foo'), stat.S_IRUSR)
- SCons.Node.FS.LinkAction.execute(fs.File(test.workpath('build/foo')),
- fs.File(test.workpath('src/foo')),
- None)
+ SCons.Node.FS.Link(fs.File(test.workpath('build/foo')),
+ fs.File(test.workpath('src/foo')),
+ None)
os.chmod(test.workpath('src/foo'), stat.S_IRUSR | stat.S_IWRITE)
st=os.stat(test.workpath('build/foo'))
assert (stat.S_IMODE(st[stat.ST_MODE]) & stat.S_IWRITE), \
@@ -356,9 +356,9 @@ class BuildDirTestCase(unittest.TestCase):
test.write('src/foo', 'src/foo\n')
os.chmod(test.workpath('src/foo'), stat.S_IRUSR)
- SCons.Node.FS.LinkAction.execute(fs.File(test.workpath('build/foo')),
- fs.File(test.workpath('src/foo')),
- None)
+ SCons.Node.FS.Link(fs.File(test.workpath('build/foo')),
+ fs.File(test.workpath('src/foo')),
+ None)
test.unlink( "src/foo" )
test.unlink( "build/foo" )
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index abfbe1c..a2b95a5 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -39,7 +39,7 @@ built_source = None
cycle_detected = None
class MyAction:
- def execute(self, target, source, env):
+ def __call__(self, target, source, env):
global built_it, built_target, built_source, built_args
built_it = 1
built_target = target
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index ca6e8eb..e5aae5c 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -122,7 +122,7 @@ class Node:
targets = self.builder.targets(self)
env = self.generate_build_env()
for action in action_list:
- stat = action.execute(targets, self.sources, env)
+ stat = action(targets, self.sources, env)
if stat:
raise SCons.Errors.BuildError(node = self,
errstr = "Error %d" % stat)