Skip to content

Commit

Permalink
New display system
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdubacq committed Mar 18, 2013
1 parent 5a6b60f commit 6e1ab8e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions bin/apt-tree
Expand Up @@ -12,15 +12,13 @@ longoptions=["help",
"indirect", "indirect",
"manual", "manual",
"unneeded", "unneeded",
"signal",
"help-nroff"] "help-nroff"]
argstype=['','','','','','',''] argstype=['','','','','','','']
explanation=['This help text', explanation=['This help text',
'Do not consider Recommends as dependencies', 'Do not consider Recommends as dependencies',
'Display non-trivial dependencies', 'Display non-trivial dependencies',
'Display manually selected packages', 'Display manually selected packages',
'Display packages required but not installed followed by -', 'Display packages required but not installed followed by -'
'Signal non-trivial dependencies with a + sign'
] ]


provided={} provided={}
Expand All @@ -29,7 +27,15 @@ manual={}
evident={} evident={}
nonEvident={} nonEvident={}
unneeded={} unneeded={}
displaytext="\nThe codes for the display is by order of precedence:\
M manually installed\
S mentioned in a non-trivial dependency and installed\
\
s mentioned in a non-trivial dependency and uninstalled"


def outputPackage(code,name):
"""output a package name with appropriate formatting"""
print "%s|%s" % (code,name)


def markEvident(name,why): def markEvident(name,why):
"""mark a package as a direct dependency of another package""" """mark a package as a direct dependency of another package"""
Expand Down Expand Up @@ -109,7 +115,7 @@ def main():
xmanual=0 xmanual=0
xindirect=0 xindirect=0
xunneeded=0 xunneeded=0
signal=0
for o,a in opts: for o,a in opts:
if o in ("-h","--help"): if o in ("-h","--help"):
usage() usage()
Expand All @@ -131,8 +137,6 @@ def main():
xall=0 xall=0
xindirect=1 xindirect=1
xtypes=['Depends','Pre-Depends'] xtypes=['Depends','Pre-Depends']
elif o in ("-s","--signal"):
signal=1
else: else:
assert False, "unhandled option" assert False, "unhandled option"
if xall==1: if xall==1:
Expand Down Expand Up @@ -179,29 +183,26 @@ def main():
forget[pkgname]=True forget[pkgname]=True
if xmanual==1: if xmanual==1:
if pkgname in installed: if pkgname in installed:
if signal==1: outputPackage("M",pkgname)
print pkgname + "+"
else:
print pkgname
else: else:
print pkgname + "-" outputPackage("m",pkgname) # WTF ?
for pkgname in evident: for pkgname in evident:
if (pkgname in forget): if (pkgname in forget):
continue continue
if pkgname not in installed: if pkgname not in installed:
forget[pkgname]=True forget[pkgname]=True
if xunneeded==1: if xunneeded==1:
print pkgname + "-" outputPackage("s",pkgname)
for pkgname in nonEvident: for pkgname in nonEvident:
if (pkgname in forget): if (pkgname in forget):
continue continue
forget[pkgname]=True forget[pkgname]=True
if pkgname in installed: if pkgname in installed:
if xindirect==1: if xindirect==1:
print pkgname outputPackage("S",pkgname)
else: else:
if xunneeded==1: if xunneeded==1:
print pkgname + "-" outputPackage("s",pkgname)


if __name__ == '__main__': if __name__ == '__main__':
main() main()

0 comments on commit 6e1ab8e

Please sign in to comment.