summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Util.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2001-12-31 02:51:50 (GMT)
committerSteven Knight <knight@baldmt.com>2001-12-31 02:51:50 (GMT)
commit74bc0282241e4d35b225660fe783955629ed234a (patch)
treecf4b0175cee4670e6b366e7a4c2218dc3bce508f /src/engine/SCons/Util.py
parent19ece17e5e025b7b9278a846eea60c8d12be438a (diff)
downloadSCons-74bc0282241e4d35b225660fe783955629ed234a.zip
SCons-74bc0282241e4d35b225660fe783955629ed234a.tar.gz
SCons-74bc0282241e4d35b225660fe783955629ed234a.tar.bz2
General performance tweaks
Diffstat (limited to 'src/engine/SCons/Util.py')
-rw-r--r--src/engine/SCons/Util.py51
1 files changed, 34 insertions, 17 deletions
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 7687250..a517407 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -224,9 +224,9 @@ def scons_subst(strSubst, locals, globals):
return string.join(map(string.join, cmd_list), '\n')
def find_files(filenames, paths,
- node_factory = SCons.Node.FS.default_fs.File):
+ node_factory = SCons.Node.FS.default_fs.File):
"""
- find_files([str], [str]) -> [nodes]
+ find_files([str], [Dir()]) -> [nodes]
filenames - a list of filenames to find
paths - a list of directory path *nodes* to search in
@@ -239,22 +239,39 @@ def find_files(filenames, paths,
Only the first file found is returned for each filename,
and any files that aren't found are ignored.
"""
- nodes = []
- for filename in filenames:
- for dir in paths:
- try:
- node = node_factory(filename, dir)
- # Return true of the node exists or is a derived node.
- if node.builder or \
- (isinstance(node, SCons.Node.FS.Entry) and node.exists()):
- nodes.append(node)
- break
- except TypeError:
- # If we find a directory instead of a file, we
- # don't care
- pass
+ nodes = map(lambda x, paths=paths, node_factory=node_factory: find_file(x, paths, node_factory), filenames)
+ return filter(lambda x: x != None, nodes)
- return nodes
+def find_file(filename, paths,
+ node_factory = SCons.Node.FS.default_fs.File):
+ """
+ find_file(str, [Dir()]) -> [nodes]
+
+ filename - a filename to find
+ paths - a list of directory path *nodes* to search in
+
+ returns - the node created from the found file.
+
+ Find a node corresponding to either a derived file or a file
+ that exists already.
+
+ Only the first file found is returned, and none is returned
+ if no file is found.
+ """
+ retval = None
+ for dir in paths:
+ try:
+ node = node_factory(filename, dir)
+ # Return true of the node exists or is a derived node.
+ if node.builder or \
+ (isinstance(node, SCons.Node.FS.Entry) and node.exists()):
+ retval = node
+ break
+ except TypeError:
+ # If we find a directory instead of a file, we don't care
+ pass
+
+ return retval
class VarInterpolator:
def __init__(self, dest, src, prefix, suffix):