From 4de8b35818cc20a672372a098ae62517bfd4b014 Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Tue, 12 Dec 2006 22:22:44 +0000 Subject: [PATCH] Add --tree option to equery files command. (Bug #62898) svn path=/; revision=327 --- trunk/ChangeLog | 4 ++++ trunk/src/equery/equery | 44 +++++++++++++++++++++++++++++++++------ trunk/src/equery/equery.1 | 3 +++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/trunk/ChangeLog b/trunk/ChangeLog index a802697..c4cb031 100644 --- a/trunk/ChangeLog +++ b/trunk/ChangeLog @@ -1,3 +1,7 @@ +2006-12-12 Paul Varner + * equery: Add --tree option to equery files command. (Bug #62898) + Thanks to scope for the patch. + 2006-12-06 Paul Varner * equery: Modify equery size command to work like the equery list command for pkgspec arguments diff --git a/trunk/src/equery/equery b/trunk/src/equery/equery index 937dd06..50f56f2 100755 --- a/trunk/src/equery/equery +++ b/trunk/src/equery/equery @@ -116,6 +116,7 @@ class CmdListFiles(Command): "showType": 0, "showTimestamp": 0, "showMD5": 0, + "tree": 0, "filter": None } @@ -132,6 +133,8 @@ class CmdListFiles(Command): opts["showTimestamp"] = 1 elif x in ["--type"]: opts["showType"] = 1 + elif x in ["--tree"]: + opts["tree"] = 1 elif x[:9] == "--filter=": opts["filter"] = string.split(x[9:],',') elif x[0] == "/": @@ -223,6 +226,10 @@ class CmdListFiles(Command): (query, opts) = self.parseArgs(args) + # Turn off filtering for tree output + if opts["tree"]: + opts["filter"] = None + if not Config["piping"] and Config["verbosityLevel"] >= 3: print_info(3, "[ Searching for packages matching " + pp.pkgquery(query) + "... ]") @@ -239,13 +246,37 @@ class CmdListFiles(Command): filenames = cnt.keys() filenames.sort() + last=[] for name in filenames: - print_info(0, fileAsStr(name, - cnt[name], - showType=opts["showType"], - showTimestamp=opts["showTimestamp"], - showMD5=opts["showMD5"])) - + if not opts["tree"]: + print_info(0, fileAsStr(name, + cnt[name], + showType=opts["showType"], + showTimestamp=opts["showTimestamp"], + showMD5=opts["showMD5"])) + else: + c = name.split( "/" )[1:] + if cnt[name][0] == "dir": + if len(last) == 0: + last = c + print pp.path(" /" + c[0]) + continue + numol = 0 + for d in c: + if d in last: + numol = last.index(d) + 1 + continue + last = c + if len(last) == 1: + print pp.path(" " + last[0]) + continue + print pp.path(" " * ( numol * 3 ) + "> " + "/" + last[-1]) + elif cnt[name][0] == "sym": + print pp.path(" " * ( bl * 3 ) + "+ ") + pp.path_symlink(c[-1] + " -> " + cnt[name][2]) + else: + bl = len(last) + print pp.path(" " * ( bl * 3 ) + "+ ") + c[-1] + def longHelp(self): return "List files owned by a particular package\n" + \ "\n" + \ @@ -258,6 +289,7 @@ class CmdListFiles(Command): " " + pp.localoption("--timestamp") + " - append timestamp\n" + \ " " + pp.localoption("--md5sum") + " - append md5sum\n" + \ " " + pp.localoption("--type") + " - prepend file type\n" + \ + " " + pp.localoption("--tree") + " - display results in a tree (turns off other options)\n" + \ " " + pp.localoption("--filter=") + " - filter output\n" + \ " " + pp.localoption("") + " is a comma separated list of elements you want to see:\n" + \ " " + " " + pp.localoption("dir") + \ diff --git a/trunk/src/equery/equery.1 b/trunk/src/equery/equery.1 index 5d4366c..f653825 100644 --- a/trunk/src/equery/equery.1 +++ b/trunk/src/equery/equery.1 @@ -106,6 +106,9 @@ output the md5sum of each file .B \-\-type output the type of each file .br +.B \-\-tree +display results in a tree (turns off all other options) +.br .B \-\-filter= filter output based on files type or path .br -- 2.26.2