summaryrefslogtreecommitdiffstats
path: root/tools/glusterfind/src/utils.py
diff options
context:
space:
mode:
authorMilind Changire <mchangir@redhat.com>2017-06-06 23:43:54 +0530
committerAravinda VK <avishwan@redhat.com>2017-06-12 04:48:55 +0000
commit64588d4f6d69ce6e9b82335d12fa6c42794c38fa (patch)
treec1bcc51f49e5a44328da86a8bff31684bc83abae /tools/glusterfind/src/utils.py
parent33b426aa9f62f6c8abb2b537b7a784c5b8090fb3 (diff)
tools/glusterfind: add --field-separator option
Problem: Default field separator is a space character. This gets in the way if the file name itself has embedded spaces. Solution: Add --field-separator option to "pre" and "query" commands. The field separator string will be used to separate strings in the output lines that get written to the output file. eg. old output: NEW file1.txt RENAME file2 Copy.txt file3.txt with --field-separator as "===" new output: NEW===file1.txt RENAME===file2 Copy.txt===file3.txt Change-Id: I71e878fed58ba1113d97044ac9f6404ee66227c7 BUG: 1453151 Signed-off-by: Milind Changire <mchangir@redhat.com> Reviewed-on: https://review.gluster.org/17481 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'tools/glusterfind/src/utils.py')
-rw-r--r--tools/glusterfind/src/utils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/glusterfind/src/utils.py b/tools/glusterfind/src/utils.py
index 70737be760a..b08233e4a9f 100644
--- a/tools/glusterfind/src/utils.py
+++ b/tools/glusterfind/src/utils.py
@@ -75,7 +75,8 @@ def find(path, callback_func=lambda x: True, filter_func=lambda x: True,
callback_func(full_path, filter_result)
-def output_write(f, path, prefix=".", encode=False, tag=""):
+def output_write(f, path, prefix=".", encode=False, tag="",
+ field_separator=" "):
if path == "":
return
@@ -86,7 +87,7 @@ def output_write(f, path, prefix=".", encode=False, tag=""):
path = urllib.quote_plus(path)
# set the field separator
- FS = "" if tag == "" else " "
+ FS = "" if tag == "" else field_separator
f.write("%s%s%s\n" % (tag.strip(), FS, path))