Lines 88-96
Link Here
|
88 |
)) |
88 |
)) |
89 |
|
89 |
|
90 |
|
90 |
|
91 |
def call_get_functions(xml_tree, meta, got_opts): |
91 |
def call_get_functions(metadata_path, package_dir, QUERY_OPTS): |
92 |
"""Call information gathering funtions and display the results.""" |
92 |
"""Call information gathering functions and display the results.""" |
|
|
93 |
|
94 |
if VERBOSE: |
95 |
print get_overlay_name(package_dir) |
93 |
|
96 |
|
|
|
97 |
try: |
98 |
xml_tree = ET.parse(metadata_path) |
99 |
except IOError: |
100 |
pp.print_error("No metadata available") |
101 |
first_run = False |
102 |
return |
103 |
|
104 |
got_opts = False |
105 |
if (QUERY_OPTS["herd"] or QUERY_OPTS["description"] or |
106 |
QUERY_OPTS["useflags"] or QUERY_OPTS["maintainer"] or |
107 |
QUERY_OPTS["upstream"] or QUERY_OPTS["xml"]): |
108 |
# Specific information requested, less formatting |
109 |
got_opts = True |
110 |
|
94 |
if QUERY_OPTS["herd"] or not got_opts: |
111 |
if QUERY_OPTS["herd"] or not got_opts: |
95 |
herd = get_herd(xml_tree) |
112 |
herd = get_herd(xml_tree) |
96 |
if QUERY_OPTS["herd"]: |
113 |
if QUERY_OPTS["herd"]: |
Lines 275-306
Link Here
|
275 |
return ' '.join(result) |
292 |
return ' '.join(result) |
276 |
|
293 |
|
277 |
|
294 |
|
278 |
def get_package_directory(queries): |
295 |
def get_package_directory(query): |
279 |
"""Find a package's portage directory.""" |
296 |
"""Find a package's portage directory.""" |
280 |
|
297 |
|
281 |
# Find queries' Portage directory and throw error if invalid |
298 |
matches = find_packages(query, include_masked=True) |
282 |
if not QUERY_OPTS["current"]: |
299 |
# Prefer a package that's in the Portage tree over one in an |
283 |
# We need at least one program name to run |
300 |
# overlay. Start with oldest first. |
284 |
if not queries: |
301 |
pkg = None |
285 |
print_help() |
302 |
while list(reversed(matches)): |
286 |
sys.exit(2) |
303 |
pkg = matches.pop() |
287 |
else: |
304 |
if not pkg.is_overlay(): |
288 |
package_dir = [] |
305 |
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 |
|
306 |
|
303 |
return package_dir |
307 |
return pkg.get_package_path() if pkg else None |
304 |
|
308 |
|
305 |
|
309 |
|
306 |
def get_useflags(xml_tree): |
310 |
def get_useflags(xml_tree): |
Lines 334-340
Link Here
|
334 |
|
338 |
|
335 |
|
339 |
|
336 |
def _get_upstream_bugtracker(node): |
340 |
def _get_upstream_bugtracker(node): |
337 |
"""WRITE IT""" |
341 |
"""Extract and format upstream bugtracker information.""" |
338 |
|
342 |
|
339 |
bt_loc = [e.text for e in node.findall("bugs-to")] |
343 |
bt_loc = [e.text for e in node.findall("bugs-to")] |
340 |
|
344 |
|
Lines 342-348
Link Here
|
342 |
|
346 |
|
343 |
|
347 |
|
344 |
def _get_upstream_changelog(node): |
348 |
def _get_upstream_changelog(node): |
345 |
"""WRITE IT""" |
349 |
"""Extract and format upstream changelog information.""" |
346 |
|
350 |
|
347 |
cl_paths = [e.text for e in node.findall("changelog")] |
351 |
cl_paths = [e.text for e in node.findall("changelog")] |
348 |
|
352 |
|
Lines 350-356
Link Here
|
350 |
|
354 |
|
351 |
|
355 |
|
352 |
def _get_upstream_documentation(node): |
356 |
def _get_upstream_documentation(node): |
353 |
"""WRITE IT""" |
357 |
"""Extract and format upstream documentation information.""" |
354 |
|
358 |
|
355 |
doc = [] |
359 |
doc = [] |
356 |
for elem in node.findall("doc"): |
360 |
for elem in node.findall("doc"): |
Lines 365-371
Link Here
|
365 |
|
369 |
|
366 |
|
370 |
|
367 |
def _get_upstream_maintainer(node): |
371 |
def _get_upstream_maintainer(node): |
368 |
"""WRITE IT""" |
372 |
"""Extract and format upstream maintainer information.""" |
369 |
|
373 |
|
370 |
maintainer = node.findall("maintainer") |
374 |
maintainer = node.findall("maintainer") |
371 |
maint = [] |
375 |
maint = [] |
Lines 386-392
Link Here
|
386 |
|
390 |
|
387 |
|
391 |
|
388 |
def _get_upstream_remoteid(node): |
392 |
def _get_upstream_remoteid(node): |
389 |
"""WRITE IT""" |
393 |
"""Extract and format upstream remote ID.""" |
390 |
|
394 |
|
391 |
r_id = [e.get("type") + ": " + e.text for e in node.findall("remote-id")] |
395 |
r_id = [e.get("type") + ": " + e.text for e in node.findall("remote-id")] |
392 |
|
396 |
|
Lines 496-533
Link Here
|
496 |
|
500 |
|
497 |
parse_module_options(module_opts) |
501 |
parse_module_options(module_opts) |
498 |
|
502 |
|
499 |
package_dir = get_package_directory(queries) |
503 |
# Find queries' Portage directory and throw error if invalid |
500 |
if not package_dir: |
504 |
if not queries and not QUERY_OPTS["current"]: |
501 |
raise errors.GentoolkitNoMatches(queries) |
505 |
print_help() |
502 |
|
506 |
sys.exit(2) |
503 |
metadata_path = [os.path.join(d, "metadata.xml") for d in package_dir] |
507 |
|
504 |
|
508 |
if QUERY_OPTS["current"]: |
505 |
# -------------------------------- |
509 |
package_dir = os.getcwd() |
506 |
# Check options and call functions |
510 |
metadata_path = os.path.join(package_dir, "metadata.xml") |
507 |
# -------------------------------- |
511 |
call_get_functions(metadata_path, package_dir, QUERY_OPTS) |
508 |
|
512 |
else: |
509 |
first_run = True |
513 |
first_run = True |
510 |
for p_dir, meta in zip(package_dir, metadata_path): |
514 |
for query in queries: |
511 |
if not first_run: |
515 |
package_dir = get_package_directory(query) |
512 |
print |
516 |
if not package_dir: |
513 |
|
517 |
raise errors.GentoolkitNoMatches(query) |
514 |
if VERBOSE: |
518 |
metadata_path = os.path.join(package_dir, "metadata.xml") |
515 |
print get_overlay_name(p_dir) |
519 |
|
516 |
|
520 |
# -------------------------------- |
517 |
try: |
521 |
# Check options and call functions |
518 |
xml_tree = ET.parse(meta) |
522 |
# -------------------------------- |
519 |
except IOError: |
523 |
|
520 |
pp.print_error("No metadata available") |
524 |
if not first_run: |
521 |
first_run = False |
525 |
print |
522 |
continue |
526 |
|
523 |
|
527 |
call_get_functions(metadata_path, package_dir, QUERY_OPTS) |
524 |
got_opts = False |
528 |
|
525 |
if (QUERY_OPTS["herd"] or QUERY_OPTS["description"] or |
529 |
first_run = False |
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 |