diff options
author | Dirk Baechle <dl9obn@darc.de> | 2015-01-11 10:15:26 (GMT) |
---|---|---|
committer | Dirk Baechle <dl9obn@darc.de> | 2015-01-11 10:15:26 (GMT) |
commit | 2d33788ee03708960bee8899129c244d957ee2be (patch) | |
tree | 566ee0b709247c106d94312060d5c05c805ed7c2 | |
parent | b1bacbc9334e22ca08b6b090ea2029164ae945bb (diff) | |
parent | ad21677e236fb53db18f42402ec7f024f3e58a36 (diff) | |
download | SCons-2d33788ee03708960bee8899129c244d957ee2be.zip SCons-2d33788ee03708960bee8899129c244d957ee2be.tar.gz SCons-2d33788ee03708960bee8899129c244d957ee2be.tar.bz2 |
Merged in dirkbaechle/scons (pull request #193), new method rentry_exists_on_disk
-rw-r--r-- | src/engine/SCons/Node/FS.py | 33 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 26 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 219718c..e73dd92 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1830,6 +1830,12 @@ class Dir(Base): return self.tpath + OS_SEP + name def entry_exists_on_disk(self, name): + """ Searches through the file/dir entries of the current + directory, and returns True if a physical entry with the given + name could be found. + + @see rentry_exists_on_disk + """ try: d = self.on_disk_entries except AttributeError: @@ -1854,6 +1860,33 @@ class Dir(Base): else: return name in d + def rentry_exists_on_disk(self, name): + """ Searches through the file/dir entries of the current + *and* all its remote directories (repos), and returns + True if a physical entry with the given name could be found. + The local directory (self) gets searched first, so + repositories take a lower precedence regarding the + searching order. + + @see entry_exists_on_disk + """ + + rentry_exists = self.entry_exists_on_disk(name) + if not rentry_exists: + # Search through the repository folders + norm_name = _my_normcase(name) + for rdir in self.get_all_rdirs(): + try: + node = rdir.entries[norm_name] + if node: + rentry_exists = True + break + except KeyError: + if rdir.entry_exists_on_disk(name): + rentry_exists = True + break + return rentry_exists + memoizer_counters.append(SCons.Memoize.CountValue('srcdir_list')) def srcdir_list(self): diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index c4dc2ce..0326717 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -2052,6 +2052,32 @@ class DirTestCase(_tempdirTestCase): if os.path.normcase("TeSt") != os.path.normpath("TeSt") or sys.platform == "cygwin": assert d.entry_exists_on_disk('case-insensitive') + def test_rentry_exists_on_disk(self): + """Test the Dir.rentry_exists_on_disk() method + """ + test = self.test + + does_not_exist = self.fs.Dir('does_not_exist') + assert not does_not_exist.rentry_exists_on_disk('foo') + + test.subdir('d') + test.write(['d', 'exists'], "d/exists\n") + test.write(['d', 'Case-Insensitive'], "d/Case-Insensitive\n") + + test.subdir('r') + test.write(['r', 'rexists'], "r/rexists\n") + + d = self.fs.Dir('d') + r = self.fs.Dir('r') + d.addRepository(r) + + assert d.rentry_exists_on_disk('exists') + assert d.rentry_exists_on_disk('rexists') + assert not d.rentry_exists_on_disk('does_not_exist') + + if os.path.normcase("TeSt") != os.path.normpath("TeSt") or sys.platform == "cygwin": + assert d.rentry_exists_on_disk('case-insensitive') + def test_srcdir_list(self): """Test the Dir.srcdir_list() method """ |