Line
Link Here
|
0 |
-- gentoolkit-0.2.1_rc2/src/equery/equery |
0 |
++ gentoolkit-0.2.1_rc2/src/equery/equery |
Lines 278-284
Link Here
|
278 |
def __init__(self): |
278 |
def __init__(self): |
279 |
self.default_opts = { |
279 |
self.default_opts = { |
280 |
"category": "*", |
280 |
"category": "*", |
281 |
"fullRegex": 0, |
|
|
282 |
"earlyOut": 0, |
281 |
"earlyOut": 0, |
283 |
"nameOnly": 0 |
282 |
"nameOnly": 0 |
284 |
} |
283 |
} |
Lines 305-312
Link Here
|
305 |
skip = 1 |
304 |
skip = 1 |
306 |
elif x in ["-e", "--earlyout"]: |
305 |
elif x in ["-e", "--earlyout"]: |
307 |
opts["earlyOut"] = 1 |
306 |
opts["earlyOut"] = 1 |
308 |
elif x in ["-f", "--full-regex"]: |
|
|
309 |
opts["fullRegex"] = 1 |
310 |
elif x in ["-n", "--name-only"]: |
307 |
elif x in ["-n", "--name-only"]: |
311 |
opts["nameOnly"] = 1 |
308 |
opts["nameOnly"] = 1 |
312 |
else: |
309 |
else: |
Lines 321-336
Link Here
|
321 |
def perform(self, args): |
318 |
def perform(self, args): |
322 |
(query, opts) = self.parseArgs(args) |
319 |
(query, opts) = self.parseArgs(args) |
323 |
|
320 |
|
324 |
if opts["fullRegex"]: |
321 |
q = map(os.path.split, query) |
325 |
q = query |
322 |
for c in q: |
326 |
else: |
323 |
if len(c[0]) and c[0][0] != "/": |
327 |
q = map(lambda x: ((len(x) and x[0] == "/") and "^" or "/") |
324 |
print_error("File names must be either include the full path or not include the path at all") |
328 |
+ re.escape(x) + "$", query) |
325 |
sys.exit(-1) |
329 |
try: |
|
|
330 |
q = string.join(q, "|") |
331 |
rx = re.compile(q) |
332 |
except: |
333 |
die(2, "The query '" + pp.regexpquery(q) + "' does not appear to be a valid regular expression") |
334 |
|
326 |
|
335 |
# Pick out only selected categories |
327 |
# Pick out only selected categories |
336 |
cat = opts["category"] |
328 |
cat = opts["category"] |
Lines 352-364
Link Here
|
352 |
#cnt = pkg.get_contents() |
344 |
#cnt = pkg.get_contents() |
353 |
if not cnt: return |
345 |
if not cnt: return |
354 |
for file in cnt.keys(): |
346 |
for file in cnt.keys(): |
355 |
if rx.search(file) and (opts["category"] == "*" or portage.catpkgsplit(pkg)[0] == opts["category"]): |
347 |
if opts["category"] == "*" or portage.catpkgsplit(pkg)[0] == opts["category"]: |
356 |
if opts["nameOnly"]: |
348 |
(dir, base) = os.path.split(file) |
357 |
x = portage.catpkgsplit(pkg) |
349 |
for c in q: |
358 |
print x[0]+"/"+x[1] |
350 |
if base == c[1] and (c[0] == "" or dir == c[0] or os.path.samefile(dir, c[0])): |
359 |
else: |
351 |
if opts["nameOnly"]: |
360 |
print pkg |
352 |
x = portage.catpkgsplit(pkg) |
361 |
return |
353 |
print x[0]+"/"+x[1] |
|
|
354 |
else: |
355 |
print pkg |
356 |
return |
362 |
|
357 |
|
363 |
class DummyExp: |
358 |
class DummyExp: |
364 |
pass |
359 |
pass |
Lines 369-384
Link Here
|
369 |
#cnt = pkg.get_contents() |
364 |
#cnt = pkg.get_contents() |
370 |
if not cnt: return |
365 |
if not cnt: return |
371 |
for file in cnt.keys(): |
366 |
for file in cnt.keys(): |
372 |
if rx.search(file) and (opts["category"] == "*" or portage.catpkgsplit(pkg)[0] == opts["category"]): |
367 |
if opts["category"] == "*" or portage.catpkgsplit(pkg)[0] == opts["category"]: |
373 |
if opts["nameOnly"]: |
368 |
(dir, base) = os.path.split(file) |
374 |
x = portage.catpkgsplit(pkg) |
369 |
for c in q: |
375 |
s = x[0]+"/"+x[1] |
370 |
if base == c[1] and (c[0] == "" or dir == c[0] or os.path.samefile(dir, c[0])): |
376 |
else: |
371 |
if opts["nameOnly"]: |
377 |
s = pkg |
372 |
x = portage.catpkgsplit(pkg) |
378 |
s += " (" + pp.path(fileAsStr(file, cnt[file])) + ")" |
373 |
s = x[0]+"/"+x[1] |
379 |
print_info(0, s) |
374 |
else: |
380 |
if opts["earlyOut"]: |
375 |
s = pkg |
381 |
raise DummyExp |
376 |
s += " (" + pp.path(fileAsStr(file, cnt[file])) + ")" |
|
|
377 |
print_info(0, s) |
378 |
if opts["earlyOut"]: |
379 |
raise DummyExp |
382 |
|
380 |
|
383 |
try: |
381 |
try: |
384 |
if Config["piping"]: |
382 |
if Config["piping"]: |
Lines 402-408
Link Here
|
402 |
pp.localoption("<local-opts>") + " is either of: \n" + \ |
400 |
pp.localoption("<local-opts>") + " is either of: \n" + \ |
403 |
" " + pp.localoption("-c, --category cat") + " - only search in category " + \ |
401 |
" " + pp.localoption("-c, --category cat") + " - only search in category " + \ |
404 |
pp.pkgquery("cat") + "\n" + \ |
402 |
pp.pkgquery("cat") + "\n" + \ |
405 |
" " + pp.localoption("-f, --full-regex") + " - supplied query is a regex\n" + \ |
|
|
406 |
" " + pp.localoption("-e, --earlyout") + " - stop when first match is found\n" + \ |
403 |
" " + pp.localoption("-e, --earlyout") + " - stop when first match is found\n" + \ |
407 |
" " + pp.localoption("-n, --name-only") + " - don't print the version." |
404 |
" " + pp.localoption("-n, --name-only") + " - don't print the version." |
408 |
|
405 |
|