summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-12-25 16:07:39 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2014-12-25 16:07:39 -0800
commit20388ece86c91c7f2db112b6da38cfb2b8853196 (patch)
treef099eb9e999d8a07587e75f7ad629774aad58e7e
parent7b71e6fb5a5c8c73c71814ceaa756681afc73c61 (diff)
downloadspack-20388ece86c91c7f2db112b6da38cfb2b8853196.tar.gz
spack-20388ece86c91c7f2db112b6da38cfb2b8853196.tar.bz2
spack-20388ece86c91c7f2db112b6da38cfb2b8853196.tar.xz
spack-20388ece86c91c7f2db112b6da38cfb2b8853196.zip
Clearer code in filter_file.
-rw-r--r--lib/spack/llnl/util/filesystem.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index 6a04d98a18..24c77a80db 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -63,8 +63,11 @@ def filter_file(regex, repl, *filenames, **kwargs):
# Allow strings to use \1, \2, etc. for replacement, like sed
if not callable(repl):
unescaped = repl.replace(r'\\', '\\')
- repl = lambda m: re.sub(
- r'\\([0-9])', lambda x: m.group(int(x.group(1))), unescaped)
+ def replace_groups_with_groupid(m):
+ def groupid_to_group(x):
+ return m.group(int(x.group(1)))
+ return re.sub(r'\\([1-9])', groupid_to_group, unescaped)
+ repl = replace_groups_with_groupid
if string:
regex = re.escape(regex)