Lines 400-406
Link Here
|
400 |
def __init__(self): |
400 |
def __init__(self): |
401 |
self.default_opts = { |
401 |
self.default_opts = { |
402 |
"displayUSEFlags": 1, |
402 |
"displayUSEFlags": 1, |
403 |
"fancyFormatting": 1 |
403 |
"fancyFormatting": 1, |
|
|
404 |
"dotformat": 0 |
404 |
} |
405 |
} |
405 |
|
406 |
|
406 |
def parseArgs(self, args): |
407 |
def parseArgs(self, args): |
Lines 424-429
Link Here
|
424 |
opts["displayUSEFlags"] = 0 |
425 |
opts["displayUSEFlags"] = 0 |
425 |
elif x in ["-l","--linear"]: |
426 |
elif x in ["-l","--linear"]: |
426 |
opts["fancyFormatting"] = 0 |
427 |
opts["fancyFormatting"] = 0 |
|
|
428 |
elif x in ["-d","--dotformat"]: |
429 |
opts["dotformat"] = 1 |
427 |
else: |
430 |
else: |
428 |
query = x |
431 |
query = x |
429 |
|
432 |
|
Lines 440-460
Link Here
|
440 |
|
443 |
|
441 |
for pkg in matches: |
444 |
for pkg in matches: |
442 |
|
445 |
|
443 |
if Config["verbosityLevel"] >= 3: |
446 |
if (Config["verbosityLevel"] >= 3) and (not opts["dotformat"]): |
444 |
print "Displaying dependencies for " + pkg.get_cpv() + "\n" |
447 |
print "Displaying dependencies for " + pkg.get_cpv() + "\n" |
445 |
|
448 |
|
446 |
if not pkg.is_installed(): |
449 |
if not pkg.is_installed(): |
447 |
continue |
450 |
continue |
448 |
self._graph(pkg, opts) |
|
|
449 |
|
451 |
|
450 |
def _graph(self, pkg, opts, level=0,pkgtbl=[],suffix=""): |
452 |
if opts["dotformat"]: |
|
|
453 |
print "digraph {" |
454 |
pkgtbl=[] |
455 |
|
456 |
self._graph(pkg, opts, 0, pkgtbl) |
457 |
|
458 |
if opts["dotformat"]: |
459 |
print |
460 |
for p in pkgtbl: |
461 |
print "\t%-12i [label=\"%s\"]" % ( hash( p ), p ) |
462 |
print "}" |
463 |
|
464 |
def _graph(self, pkg, opts, level=0, pkgtbl=[], suffix="", from_pkg=""): |
451 |
|
465 |
|
452 |
cpv=pkg.get_cpv() |
466 |
cpv=pkg.get_cpv() |
|
|
467 |
enter_cpv = cpv |
453 |
|
468 |
|
454 |
pfx = "" |
469 |
pfx = "" |
455 |
if opts["fancyFormatting"]: |
470 |
if opts["fancyFormatting"]: |
456 |
pfx = level*" " + "`-- " |
471 |
pfx = level*" " + "`-- " |
457 |
print pfx + cpv + suffix |
472 |
|
|
|
473 |
if opts["dotformat"]: |
474 |
if from_pkg != "": |
475 |
print "\t%-12i -> %i" % ( hash( from_pkg ), hash( cpv ) ) |
476 |
else: |
477 |
print pfx + cpv + suffix |
458 |
|
478 |
|
459 |
pkgtbl.append(cpv) |
479 |
pkgtbl.append(cpv) |
460 |
|
480 |
|
Lines 470-476
Link Here
|
470 |
suffix += " (" + cpv + ")" |
490 |
suffix += " (" + cpv + ")" |
471 |
if len(x[1]) and opts["displayUSEFlags"]: |
491 |
if len(x[1]) and opts["displayUSEFlags"]: |
472 |
suffix += " [ " + string.join(x[1]) + " ]" |
492 |
suffix += " [ " + string.join(x[1]) + " ]" |
473 |
pkgtbl = self._graph(pkg, opts, level+1, pkgtbl, suffix) |
493 |
pkgtbl = self._graph(pkg, opts, level+1, pkgtbl, suffix, enter_cpv) |
474 |
return pkgtbl |
494 |
return pkgtbl |
475 |
|
495 |
|
476 |
def shortHelp(self): |
496 |
def shortHelp(self): |
Lines 483-489
Link Here
|
483 |
"\n" + \ |
503 |
"\n" + \ |
484 |
yellow("<local-opts>") + " is either of: \n" + \ |
504 |
yellow("<local-opts>") + " is either of: \n" + \ |
485 |
" " + yellow("-U, --no-useflags") + " - do not show USE flags\n" + \ |
505 |
" " + yellow("-U, --no-useflags") + " - do not show USE flags\n" + \ |
486 |
" " + yellow("-l, --linear") + " - do not use fancy formatting" |
506 |
" " + yellow("-l, --linear") + " - do not use fancy formatting\n" + \ |
|
|
507 |
" " + yellow("-d, --dotformat") + " - print dependency in dot-format. Tip: pipe into display" |
487 |
|
508 |
|
488 |
class CmdDisplaySize(Command): |
509 |
class CmdDisplaySize(Command): |
489 |
"""Display disk size consumed by a package""" |
510 |
"""Display disk size consumed by a package""" |