diff options
author | Alexandre Feblot <Alexandre Feblot@localhost> | 2015-04-29 22:19:55 (GMT) |
---|---|---|
committer | Alexandre Feblot <Alexandre Feblot@localhost> | 2015-04-29 22:19:55 (GMT) |
commit | 946f7a9674f6eef933e15e0441be0583c1d8fbe2 (patch) | |
tree | 82ffb939ef4eeef3fd9c7b67ed7e835258045404 | |
parent | 7844379242a7a511826fcc09d801af293df04c2c (diff) | |
download | SCons-946f7a9674f6eef933e15e0441be0583c1d8fbe2.zip SCons-946f7a9674f6eef933e15e0441be0583c1d8fbe2.tar.gz SCons-946f7a9674f6eef933e15e0441be0583c1d8fbe2.tar.bz2 |
Glob exclude parameter can now be a string or a list of strings
-rw-r--r-- | src/engine/SCons/Environment.xml | 2 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 9 | ||||
-rw-r--r-- | test/Glob/exclude.py | 4 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml index 069ad87..b90f1d8 100644 --- a/src/engine/SCons/Environment.xml +++ b/src/engine/SCons/Environment.xml @@ -1813,7 +1813,7 @@ directory.) <para> The <varname>exclude</varname> -argument may be set to a list of patterns +argument may be set to a pattern or a list of patterns (following the same Unix shell semantics) which must be filtered out of returned elements. Elements matching a least one pattern of diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 0156e27..eec4e42 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -2048,9 +2048,10 @@ class Dir(Base): The "strings" argument, when true, returns the matches as strings, not Nodes. The strings are path names relative to this directory. - The "exclude" argument, if not None, must be a list of patterns - following the same UNIX shell semantics. Elements matching a least - one pattern of this list will be excluded from the result. + The "exclude" argument, if not None, must be a pattern or a list + of patterns following the same UNIX shell semantics. + Elements matching a least one pattern of this list will be excluded + from the result. The underlying algorithm is adapted from the glob.glob() function in the Python library (but heavily modified), and uses fnmatch() @@ -2071,7 +2072,7 @@ class Dir(Base): r = [os.path.join(str(dir), x) for x in r] result.extend(r) if exclude: - result = filter(lambda x: not any(fnmatch.fnmatch(str(x), e) for e in exclude), result) + result = filter(lambda x: not any(fnmatch.fnmatch(str(x), e) for e in SCons.Util.flatten(exclude)), result) return sorted(result, key=lambda a: str(a)) def _glob1(self, pattern, ondisk=True, source=False, strings=False): diff --git a/test/Glob/exclude.py b/test/Glob/exclude.py index 2348cc2..56b58a8 100644 --- a/test/Glob/exclude.py +++ b/test/Glob/exclude.py @@ -50,8 +50,8 @@ env.Concatenate('fa.out', sorted(Glob('f*.in' , exclude=['f2.in', 'f4.*'] , env.Concatenate('fb.out', sorted(Glob('f*.in' , exclude=['f2.in', 'f4.*'] , strings=True))) env.Concatenate('fc.out', sorted(Glob('d?/f*.in', exclude=['d?/f1.*', 'f2.in'], strings=False), key=lambda t: t.path)) env.Concatenate('fd.out', sorted(Glob('d?/f*.in', exclude=['d?/f1.*', 'f2.in'], strings=True))) -env.Concatenate('fe.out', sorted(Glob('f*.in', exclude=['f1.in'] , strings=True))) -env.Concatenate('ff.out', sorted(Glob('f*.in', exclude=['other'] , strings=True))) +env.Concatenate('fe.out', sorted(Glob('f*.in', exclude='f1.in' , strings=True))) +env.Concatenate('ff.out', sorted(Glob('f*.in', exclude='other' , strings=True))) """) test.write('f1.in', "f1.in\n") |