Lines 275-306
Link Here
|
275 |
return ' '.join(result) |
275 |
return ' '.join(result) |
276 |
|
276 |
|
277 |
|
277 |
|
278 |
def get_package_directory(queries): |
278 |
def get_package_directory(query): |
279 |
"""Find a package's portage directory.""" |
279 |
"""Find a package's portage directory.""" |
280 |
|
280 |
|
281 |
# Find queries' Portage directory and throw error if invalid |
281 |
matches = find_packages(query, include_masked=True) |
282 |
if not QUERY_OPTS["current"]: |
282 |
# Prefer a package that's in the Portage tree over one in an |
283 |
# We need at least one program name to run |
283 |
# overlay. Start with oldest first. |
284 |
if not queries: |
284 |
pkg = None |
285 |
print_help() |
285 |
while list(reversed(matches)): |
286 |
sys.exit(2) |
286 |
pkg = matches.pop() |
287 |
else: |
287 |
if not pkg.is_overlay(): |
288 |
package_dir = [] |
288 |
break |
289 |
for query in queries: |
|
|
290 |
matches = find_packages(query, include_masked=True) |
291 |
# Prefer a package that's in the Portage tree over one in an |
292 |
# overlay. Start with oldest first. |
293 |
pkg = None |
294 |
while reversed(matches): |
295 |
pkg = matches.pop() |
296 |
if not pkg.is_overlay(): |
297 |
break |
298 |
if pkg: |
299 |
package_dir.append(pkg.get_package_path()) |
300 |
else: |
301 |
package_dir = [os.getcwd()] |
302 |
|
289 |
|
303 |
return package_dir |
290 |
return pkg.get_package_path() if pkg else None |
304 |
|
291 |
|
305 |
|
292 |
|
306 |
def get_useflags(xml_tree): |
293 |
def get_useflags(xml_tree): |
Lines 496-533
Link Here
|
496 |
|
483 |
|
497 |
parse_module_options(module_opts) |
484 |
parse_module_options(module_opts) |
498 |
|
485 |
|
499 |
package_dir = get_package_directory(queries) |
486 |
# We need at least one program name to run |
500 |
if not package_dir: |
487 |
if not queries: |
501 |
raise errors.GentoolkitNoMatches(queries) |
488 |
print_help() |
|
|
489 |
sys.exit(2) |
490 |
|
491 |
# Find queries' Portage directory and throw error if invalid |
492 |
if QUERY_OPTS["current"]: |
493 |
package_dir = [os.getcwd()] |
494 |
else: |
495 |
package_dir = [] |
496 |
for query in queries: |
497 |
first_run = True |
498 |
package_dir = get_package_directory(query) |
499 |
if not package_dir: |
500 |
raise errors.GentoolkitNoMatches(query) |
501 |
metadata_path = os.path.join(package_dir, "metadata.xml") |
502 |
|
502 |
|
503 |
metadata_path = [os.path.join(d, "metadata.xml") for d in package_dir] |
503 |
# -------------------------------- |
504 |
|
504 |
# Check options and call functions |
505 |
# -------------------------------- |
505 |
# -------------------------------- |
506 |
# Check options and call functions |
506 |
|
507 |
# -------------------------------- |
507 |
if not first_run: |
508 |
|
508 |
print |
509 |
first_run = True |
509 |
|
510 |
for p_dir, meta in zip(package_dir, metadata_path): |
510 |
if VERBOSE: |
511 |
if not first_run: |
511 |
print get_overlay_name(package_dir) |
512 |
print |
512 |
|
513 |
|
513 |
try: |
514 |
if VERBOSE: |
514 |
xml_tree = ET.parse(metadata_path) |
515 |
print get_overlay_name(p_dir) |
515 |
except IOError: |
516 |
|
516 |
pp.print_error("No metadata available") |
517 |
try: |
517 |
first_run = False |
518 |
xml_tree = ET.parse(meta) |
518 |
continue |
519 |
except IOError: |
519 |
|
520 |
pp.print_error("No metadata available") |
520 |
got_opts = False |
|
|
521 |
if (QUERY_OPTS["herd"] or QUERY_OPTS["description"] or |
522 |
QUERY_OPTS["useflags"] or QUERY_OPTS["maintainer"] or |
523 |
QUERY_OPTS["upstream"] or QUERY_OPTS["xml"]): |
524 |
# Specific information requested, less formatting |
525 |
got_opts = True |
526 |
|
527 |
call_get_functions(xml_tree, metadata_path, got_opts) |
528 |
|
521 |
first_run = False |
529 |
first_run = False |
522 |
continue |
530 |
|
523 |
|
|
|
524 |
got_opts = False |
525 |
if (QUERY_OPTS["herd"] or QUERY_OPTS["description"] or |
526 |
QUERY_OPTS["useflags"] or QUERY_OPTS["maintainer"] or |
527 |
QUERY_OPTS["upstream"] or QUERY_OPTS["xml"]): |
528 |
# Specific information requested, less formatting |
529 |
got_opts = True |
530 |
|
531 |
call_get_functions(xml_tree, meta, got_opts) |
532 |
|
533 |
first_run = False |