diff options
| author | Gary Oberbrunner <garyo@oberbrunner.com> | 2010-11-21 14:08:15 (GMT) |
|---|---|---|
| committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2010-11-21 14:08:15 (GMT) |
| commit | 32d4ab409272ef6f2958527a291ac0867f2239a1 (patch) | |
| tree | 651663e5e202ae84ebe5ebbceb9be237272fbd40 /src/engine | |
| parent | 4dfe1846ccb7b528bf3cdfd157ecaa9dcd1bb99b (diff) | |
| download | SCons-32d4ab409272ef6f2958527a291ac0867f2239a1.zip SCons-32d4ab409272ef6f2958527a291ac0867f2239a1.tar.gz SCons-32d4ab409272ef6f2958527a291ac0867f2239a1.tar.bz2 | |
Fix last commit for python 2.3; no string.rsplit(). Use rindex instead.
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/SCons/Node/FS.py | 14 | ||||
| -rw-r--r-- | src/engine/SCons/Node/FSTests.py | 9 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 7f3bd8e..bb49f95 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2178,7 +2178,7 @@ class RootDir(Dir): normalized absolute path; we merely let Python's dictionary look up and return the One True Node.FS object for the path. - If no Node for the specified "p" doesn't already exist, and + If a Node for the specified "p" doesn't already exist, and "create" is specified, the Node may be created after recursive invocation to find or create the parent directory or directories. """ @@ -2191,7 +2191,17 @@ class RootDir(Dir): raise SCons.Errors.UserError(msg) # There is no Node for this path name, and we're allowed # to create it. - dir_name, file_name = p.rsplit('/',1) + # (note: would like to use p.rsplit('/',1) here but + # that's not in python 2.3) + # e.g.: dir_name, file_name = p.rsplit('/',1) + last_slash = p.rindex('/') + if (last_slash >= 0): + dir_name = p[:last_slash] + file_name = p[last_slash+1:] + else: + dir_name = p # shouldn't happen, just in case + file_name = '' + dir_node = self._lookup_abs(dir_name, Dir) result = klass(file_name, dir_node, self.fs) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index cef8f69..e68bcd5 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1794,6 +1794,15 @@ class FSTestCase(_tempdirTestCase): above_path = os.path.join(*['..']*len(dirs) + ['above']) above = d2.Dir(above_path) + def test_lookup_abs(self): + """Exercise the _lookup_abs function""" + test = self.test + fs = self.fs + + root = fs.Dir('/') + d = root._lookup_abs('/tmp/foo/nonexistent-dir', SCons.Node.FS.Dir) + assert d.__class__ == SCons.Node.FS.Dir, str(d.__class__) + def test_lookup_uncpath(self): """Testing looking up a UNC path on Windows""" if sys.platform not in ('win32',): |
