diff options
author | Shwetha K Acharya <sacharya@redhat.com> | 2018-12-31 10:55:21 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-01-23 03:16:52 +0000 |
commit | d193ed84ae2886d89b899e02e9642e61bdab462a (patch) | |
tree | 6c7836d3271680e9201203bcbbf6521fcd357952 /tools/glusterfind/src/utils.py | |
parent | 86d4eac6c6f2d774a579ef134f6526f75504c46e (diff) |
tools/glusterfind: option to display only files/directories
Updated full find to filter for files and directories.
--full --type f lists only the files,
--full --type d lists only the directories,
--full (by default) lists both files and directories.
fixes: #579
Change-Id: If2c91a21a131667d5de34635c1846013e8fa20b7
Signed-off-by: Shwetha K Acharya <sacharya@redhat.com>
Diffstat (limited to 'tools/glusterfind/src/utils.py')
-rw-r--r-- | tools/glusterfind/src/utils.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/glusterfind/src/utils.py b/tools/glusterfind/src/utils.py index b376241820b..cc099031ef8 100644 --- a/tools/glusterfind/src/utils.py +++ b/tools/glusterfind/src/utils.py @@ -58,12 +58,13 @@ def find(path, callback_func=lambda x: True, filter_func=lambda x: True, # Capture filter_func output and pass it to callback function filter_result = filter_func(path) if filter_result is not None: - callback_func(path, filter_result) + callback_func(path, filter_result, os.path.isdir(path)) for p in os.listdir(path): full_path = os.path.join(path, p) - if os.path.isdir(full_path): + is_dir = os.path.isdir(full_path) + if is_dir: if subdirs_crawl: find(full_path, callback_func, filter_func, ignore_dirs) else: @@ -73,7 +74,7 @@ def find(path, callback_func=lambda x: True, filter_func=lambda x: True, else: filter_result = filter_func(full_path) if filter_result is not None: - callback_func(full_path, filter_result) + callback_func(full_path, filter_result, is_dir) def output_write(f, path, prefix=".", encode=False, tag="", |