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/brickfind.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/brickfind.py')
-rw-r--r-- | tools/glusterfind/src/brickfind.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/glusterfind/src/brickfind.py b/tools/glusterfind/src/brickfind.py index 6597aa1ba7c..95b7a3d991d 100644 --- a/tools/glusterfind/src/brickfind.py +++ b/tools/glusterfind/src/brickfind.py @@ -41,12 +41,20 @@ def brickfind_crawl(brick, args): with open(args.outfile, "a+") as fout: brick_path_len = len(brick) - def output_callback(path, filter_result): + def output_callback(path, filter_result, is_dir): path = path.strip() path = path[brick_path_len+1:] - output_write(fout, path, args.output_prefix, - encode=(not args.no_encode), tag=args.tag, - field_separator=args.field_separator) + + if args.type == "both": + output_write(fout, path, args.output_prefix, + encode=(not args.no_encode), tag=args.tag, + field_separator=args.field_separator) + else: + if (is_dir and args.type == "d") or ( + (not is_dir) and args.type == "f"): + output_write(fout, path, args.output_prefix, + encode=(not args.no_encode), tag=args.tag, + field_separator=args.field_separator) ignore_dirs = [os.path.join(brick, dirname) for dirname in @@ -77,6 +85,9 @@ def _get_args(): action="store_true") parser.add_argument("--output-prefix", help="File prefix in output", default=".") + parser.add_argument('--type', help="type: f, f-files only" + " d, d-directories only, by default = both", + default='both') parser.add_argument("--field-separator", help="Field separator", default=" ") |