Lines 81-87
Link Here
|
81 |
self.default_options = { |
81 |
self.default_options = { |
82 |
"showType": 0, |
82 |
"showType": 0, |
83 |
"showTimestamp": 0, |
83 |
"showTimestamp": 0, |
84 |
"showMD5": 0 |
84 |
"showMD5": 0, |
|
|
85 |
"filter" : None |
85 |
} |
86 |
} |
86 |
|
87 |
|
87 |
def parseArgs(self,args): |
88 |
def parseArgs(self,args): |
Lines 97-102
Link Here
|
97 |
opts["showTimestamp"] = 1 |
98 |
opts["showTimestamp"] = 1 |
98 |
elif x in ["--type"]: |
99 |
elif x in ["--type"]: |
99 |
opts["showType"] = 1 |
100 |
opts["showType"] = 1 |
|
|
101 |
elif x[:9] == "--filter=": |
102 |
opts["filter"] = string.split(x[9:],',') |
100 |
else: |
103 |
else: |
101 |
query = x |
104 |
query = x |
102 |
|
105 |
|
Lines 105-110
Link Here
|
105 |
sys.exit(-1) |
108 |
sys.exit(-1) |
106 |
|
109 |
|
107 |
return (query, opts) |
110 |
return (query, opts) |
|
|
111 |
|
112 |
def filterContents(self, cnt, filter): |
113 |
if filter in [None,[]]: |
114 |
return cnt |
115 |
|
116 |
mycnt = {} |
117 |
|
118 |
for mytype in filter: |
119 |
# Filter elements by type (as recorded in CONTENTS). |
120 |
if mytype in ["dir","obj","sym","dev","fifo"]: |
121 |
for mykey in cnt.keys(): |
122 |
if cnt[mykey][0] == mytype: |
123 |
mycnt[mykey] = cnt[mykey] |
124 |
|
125 |
if "cmd" in filter: |
126 |
# List files that are in $PATH. |
127 |
userpath = map(os.path.normpath,os.environ["PATH"].split(os.pathsep)) |
128 |
for mykey in cnt.keys(): |
129 |
if cnt[mykey][0] in ['obj','sym'] \ |
130 |
and os.path.dirname(mykey) in userpath: |
131 |
mycnt[mykey] = cnt[mykey] |
132 |
|
133 |
if "path" in filter: |
134 |
# List only dirs where some files where actually installed, |
135 |
# and also skip their subdirs. |
136 |
mykeys = cnt.keys() |
137 |
mykeys.sort() |
138 |
while len(mykeys): |
139 |
mykey = mykeys.pop(0) |
140 |
if cnt[mykey][0] == 'dir': |
141 |
i = 0 |
142 |
while i < len(mykeys) : |
143 |
if cnt[mykeys[i]][0] != "dir" \ |
144 |
and os.path.dirname(mykeys[i]) == mykey: |
145 |
mycnt[mykey] = cnt[mykey] |
146 |
break |
147 |
i += 1 |
148 |
if i < len(mykeys): |
149 |
while len(mykeys) \ |
150 |
and len(mykey+"/") < len(mykeys[0]) \ |
151 |
and mykey+"/" == mykeys[0][:len(mykey)+1]: |
152 |
mykeys.pop(0) |
153 |
|
154 |
if "conf" in filter: |
155 |
# List configuration files. |
156 |
# XXX: doesn't take CONFIG_PROTECT_MASK into account. Bah... |
157 |
conf_path = gentoolkit.settings["CONFIG_PROTECT"].split(" ") |
158 |
conf_path = map(os.path.normpath, conf_path) |
159 |
for mykey in cnt.keys(): |
160 |
if cnt[mykey][0] == 'obj': |
161 |
for conf_dir in conf_path: |
162 |
if conf_dir+"/" == mykey[:len(conf_dir)+1]: |
163 |
mycnt[mykey] = cnt[mykey] |
164 |
break |
165 |
|
166 |
return mycnt |
108 |
|
167 |
|
109 |
def perform(self, args): |
168 |
def perform(self, args): |
110 |
|
169 |
|
Lines 122-135
Link Here
|
122 |
if Config["verbosityLevel"] >= 1: |
181 |
if Config["verbosityLevel"] >= 1: |
123 |
print "Contents of " + x.get_cpv() + ":" |
182 |
print "Contents of " + x.get_cpv() + ":" |
124 |
|
183 |
|
125 |
cnt = x.get_contents() |
184 |
cnt = self.filterContents(x.get_contents(),opts["filter"]) |
126 |
|
185 |
|
127 |
for name in cnt: |
186 |
mynames = cnt.keys() |
|
|
187 |
mynames.sort() |
188 |
for name in mynames: |
128 |
print fileAsStr(name, |
189 |
print fileAsStr(name, |
129 |
cnt[name], |
190 |
cnt[name], |
130 |
showType=opts["showType"], |
191 |
showType=opts["showType"], |
131 |
showTimestamp=opts["showTimestamp"], |
192 |
showTimestamp=opts["showTimestamp"], |
132 |
showMD5=opts["showMD5"]) |
193 |
showMD5=opts["showMD5"]) |
133 |
|
194 |
|
134 |
|
195 |
|
135 |
def longHelp(self): |
196 |
def longHelp(self): |
Lines 141-149
Link Here
|
141 |
"Note: category and version parts are optional. \n" + \ |
202 |
"Note: category and version parts are optional. \n" + \ |
142 |
"\n" + \ |
203 |
"\n" + \ |
143 |
yellow("<local-opts>") + " is either of: \n" + \ |
204 |
yellow("<local-opts>") + " is either of: \n" + \ |
144 |
" " + yellow("--timestamp") + " - append timestamp\n" + \ |
205 |
" " + yellow("--timestamp ") + " - append timestamp\n" + \ |
145 |
" " + yellow("--md5sum") + " - append md5sum\n" + \ |
206 |
" " + yellow("--md5sum ") + " - append md5sum\n" + \ |
146 |
" " + yellow("--type") + " - prepend file type" |
207 |
" " + yellow("--type ") + " - prepend file type\n" + \ |
|
|
208 |
" " + yellow("--filter=<rules>") + " - filter output\n" + \ |
209 |
" " + yellow(" <rules>")+" is a comma separated list of elements you want to see:\n" + \ |
210 |
" " + " " + yellow("dir") + \ |
211 |
", " + yellow("obj") + \ |
212 |
", " + yellow("sym") + \ |
213 |
", " + yellow("dev") + \ |
214 |
", " + yellow("fifo") + \ |
215 |
", " + yellow("path") + \ |
216 |
", " + yellow("conf") + \ |
217 |
" or " + yellow("cmd") |
147 |
def shortHelp(self): |
218 |
def shortHelp(self): |
148 |
return yellow("<local-opts> ") + turquoise("pkgspec") + " - list files owned by " + turquoise("pkgspec") |
219 |
return yellow("<local-opts> ") + turquoise("pkgspec") + " - list files owned by " + turquoise("pkgspec") |
149 |
|
220 |
|