summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-05-04 15:22:16 (GMT)
committerSteven Knight <knight@baldmt.com>2003-05-04 15:22:16 (GMT)
commitabe3ed8cdeb3d5a16ab3448f768f43c6aa1feeca (patch)
treeff2b2541eba0a68e9dc56d6ea1be89f4e69e9e2d /src
parent8b2e2047624600d20e0ca2bd8235514aeaa9239b (diff)
downloadSCons-abe3ed8cdeb3d5a16ab3448f768f43c6aa1feeca.zip
SCons-abe3ed8cdeb3d5a16ab3448f768f43c6aa1feeca.tar.gz
SCons-abe3ed8cdeb3d5a16ab3448f768f43c6aa1feeca.tar.bz2
Add Node.FS.{Dir,File}.Entry() methods.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt2
-rw-r--r--src/engine/SCons/Node/FS.py14
-rw-r--r--src/engine/SCons/Node/FSTests.py44
3 files changed, 48 insertions, 12 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 0c23939..227ef59 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -72,6 +72,8 @@ RELEASE 0.14 - XXX
to {Target,Source}Signatures(). Deprecate the old names but support
them for backwards compatibility.
+ - Add internal SCons.Node.FS.{Dir,File}.Entry() methods.
+
From Damyan Pepper:
- Quote the "Entering directory" message like Make.
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index a2d9414..0a016ad 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -833,15 +833,19 @@ class Dir(Entry):
def __resetDuplicate(self, node):
if node != self:
node.duplicate = node.get_dir().duplicate
-
+
+ def Entry(self, name):
+ """Create an entry node named 'name' relative to this directory."""
+ return self.fs.Entry(name, self)
+
def Dir(self, name):
"""Create a directory node named 'name' relative to this directory."""
return self.fs.Dir(name, self)
def File(self, name):
- """Create file node named 'name' relatove to this directory."""
+ """Create a file node named 'name' relative to this directory."""
return self.fs.File(name, self)
-
+
def link(self, srcdir, duplicate):
"""Set this directory as the build directory for the
supplied source directory."""
@@ -976,6 +980,10 @@ class File(Entry):
Entry.__init__(self, name, directory, fs)
self._morph()
+ def Entry(self, name):
+ """Create an entry node named 'name' relative to
+ the SConscript directory of this file."""
+ return self.fs.Entry(name, self.cwd)
def Dir(self, name):
"""Create a directory node named 'name' relative to
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index b932896..f2d8dd9 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -509,50 +509,76 @@ class FSTestCase(unittest.TestCase):
fs = SCons.Node.FS.FS()
+ e1 = fs.Entry('e1')
+ assert isinstance(e1, SCons.Node.FS.Entry)
+
d1 = fs.Dir('d1')
+ assert isinstance(d1, SCons.Node.FS.Dir)
assert d1.cwd is d1, d1
f1 = fs.File('f1', directory = d1)
+ assert isinstance(f1, SCons.Node.FS.File)
d1_f1 = os.path.join('d1', 'f1')
assert f1.path == d1_f1, "f1.path %s != %s" % (f1.path, d1_f1)
assert str(f1) == d1_f1, "str(f1) %s != %s" % (str(f1), d1_f1)
x1 = d1.File('x1')
+ assert isinstance(x1, SCons.Node.FS.File)
assert str(x1) == os.path.join('d1', 'x1')
x2 = d1.Dir('x2')
+ assert isinstance(x2, SCons.Node.FS.Dir)
assert str(x2) == os.path.join('d1', 'x2')
+ x3 = d1.Entry('x3')
+ assert isinstance(x3, SCons.Node.FS.Entry)
+ assert str(x3) == os.path.join('d1', 'x3')
+
assert d1.File(x1) == x1
assert d1.Dir(x2) == x2
+ assert d1.Entry(x3) == x3
x1.cwd = d1
- x3 = x1.File('x3')
- assert str(x3) == os.path.join('d1', 'x3')
-
- x4 = x1.Dir('x4')
+ x4 = x1.File('x4')
assert str(x4) == os.path.join('d1', 'x4')
- assert x1.File(x3) == x3
- assert x1.Dir(x4) == x4
+ x5 = x1.Dir('x5')
+ assert str(x5) == os.path.join('d1', 'x5')
+ x6 = x1.Entry('x6')
+ assert str(x6) == os.path.join('d1', 'x6')
+ x7 = x1.Entry('x7')
+ assert str(x7) == os.path.join('d1', 'x7')
+
+ assert x1.File(x4) == x4
+ assert x1.Dir(x5) == x5
+ assert x1.Entry(x6) == x6
+ assert x1.Entry(x7) == x7
+
+ assert x1.Entry(x5) == x5
try:
- x1.File(x4)
+ x1.File(x5)
except TypeError:
pass
else:
assert 0
+ assert x1.Entry(x4) == x4
try:
- x1.Dir(x3)
+ x1.Dir(x4)
except TypeError:
pass
else:
assert 0
-
+ x6 = x1.File(x6)
+ assert isinstance(x6, SCons.Node.FS.File)
+
+ x7 = x1.Dir(x7)
+ assert isinstance(x7, SCons.Node.FS.Dir)
+
seps = [os.sep]
if os.sep != '/':
seps = seps + ['/']