Add FileFilter convenience class to llnl.util.filesystem.
This commit is contained in:
parent
1f0246f970
commit
5d7a6c0c46
@ -25,7 +25,7 @@
|
|||||||
__all__ = ['set_install_permissions', 'install', 'install_tree', 'traverse_tree',
|
__all__ = ['set_install_permissions', 'install', 'install_tree', 'traverse_tree',
|
||||||
'expand_user', 'working_dir', 'touch', 'touchp', 'mkdirp',
|
'expand_user', 'working_dir', 'touch', 'touchp', 'mkdirp',
|
||||||
'force_remove', 'join_path', 'ancestor', 'can_access', 'filter_file',
|
'force_remove', 'join_path', 'ancestor', 'can_access', 'filter_file',
|
||||||
'change_sed_delimiter', 'is_exe', 'force_symlink']
|
'FileFilter', 'change_sed_delimiter', 'is_exe', 'force_symlink']
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -96,6 +96,15 @@ def groupid_to_group(x):
|
|||||||
shutil.rmtree(backup, ignore_errors=True)
|
shutil.rmtree(backup, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
class FileFilter(object):
|
||||||
|
"""Convenience class for calling filter_file a lot."""
|
||||||
|
def __init__(self, *filenames):
|
||||||
|
self.filenames = filenames
|
||||||
|
|
||||||
|
def filter(self, regex, repl, **kwargs):
|
||||||
|
return filter_file(regex, repl, *self.filenames, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def change_sed_delimiter(old_delim, new_delim, *filenames):
|
def change_sed_delimiter(old_delim, new_delim, *filenames):
|
||||||
"""Find all sed search/replace commands and change the delimiter.
|
"""Find all sed search/replace commands and change the delimiter.
|
||||||
e.g., if the file contains seds that look like 's///', you can
|
e.g., if the file contains seds that look like 's///', you can
|
||||||
|
Loading…
Reference in New Issue
Block a user