From c0b6c9e6812970ac952593abf3d6b4d810b06c9d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Mar 2005 10:21:47 +0000 Subject: * merged with matts tree, resolved lots of conflicts Patches applied: * apt@packages.debian.org/python-apt--main--0--base-0 tag of apt@arch.ubuntu.com/python-apt--MAIN--0--patch-44 * apt@packages.debian.org/python-apt--main--0--patch-1 Merge michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0 * apt@packages.debian.org/python-apt--main--0--patch-2 0.5.33 * apt@packages.debian.org/python-apt--main--0--patch-3 Add arch-build target to rules * apt@packages.debian.org/python-apt--main--0--patch-4 Fix typo (fund->find) * apt@packages.debian.org/python-apt--main--0--patch-5 Restore Ubuntu changes * apt@packages.debian.org/python-apt--main--0--patch-6 0.5.35 -> hoary * apt@packages.debian.org/python-apt--main--0--patch-7 Fix build-depends, somehow lost in merge * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--base-0 tag of apt@arch.ubuntu.com/python-apt--MAIN--0--patch-44 * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-1 * merged from my mvo tree, removed all non-pkgDepCache releated stuff and cleaned up the code * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-2 * beefed up the example code, added DepCache.Upgrade() * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-3 * implemented the marking interface * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-4 * state information and marking interface * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-5 * fixed wrong types for "UsrSize" and "DebSize" * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-6 * added DepCache.FixBroken() * michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0--patch-7 * example code how a overview about the changes can be computed --- doc/examples/depcache.py | 102 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 26 deletions(-) (limited to 'doc') diff --git a/doc/examples/depcache.py b/doc/examples/depcache.py index 7c8a33ea..92416b3e 100644 --- a/doc/examples/depcache.py +++ b/doc/examples/depcache.py @@ -3,35 +3,85 @@ import apt_pkg -class TextProgress: - def __init__(self): - self.last = 1 - def show(self,Percent): - if self.last < Percent: - print "\r%.2f " % Percent, - self.last = Percent+0.1 - if Percent >= 100: - print "\r100.0 " - self.last = 0 - -def Update(Percent, data): - # data is a TextProgress class - progress = data - progress.show(Percent) - - +# init apt_pkg.init() - -progress = TextProgress() -cache = apt_pkg.GetCache(Update, progress) -print cache.PackageCount +cache = apt_pkg.GetCache() +print "Available packages: %s " % cache.PackageCount iter = cache["base-config"] -print iter +print "example package iter: %s" % iter -depcache = apt_pkg.GetDepCache(cache, Update, progress) -print depcache -print depcache.InstCount +# get depcache +depcache = apt_pkg.GetDepCache(cache) +print "got a depcache: %s " % depcache +print "Marked for install: %s " % depcache.InstCount +# get a canidate version ver= depcache.GetCandidateVer(iter) -print ver +print "Candidate version: %s " % ver + +print "\n\nQuerry interface" +print "%s.IsUpgradable(): %s" % (iter.Name, depcache.IsUpgradable(iter)) + +print "\nMarking interface" +print "Marking '%s' for install" % iter.Name +depcache.MarkInstall(iter) +print "Install count: %s " % depcache.InstCount +print "%s.MarkedInstall(): %s" % (iter.Name, depcache.MarkedInstall(iter)) +print "%s.MarkedUpgrade(): %s" % (iter.Name, depcache.MarkedUpgrade(iter)) +print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter)) + +print "Marking %s for delete" % iter.Name +depcache.MarkDelete(iter) +print "DelCount: %s " % depcache.DelCount +print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter)) + + +iter = cache["3dchess"] +print "\nMarking '%s' for install" % iter.Name +depcache.MarkInstall(iter) +print "Install count: %s " % depcache.InstCount +print "%s.MarkedInstall(): %s" % (iter.Name, depcache.MarkedInstall(iter)) +print "%s.MarkedUpgrade(): %s" % (iter.Name, depcache.MarkedUpgrade(iter)) +print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter)) + +print "Marking %s for keep" % iter.Name +depcache.MarkKeep(iter) +print "Install: %s " % depcache.InstCount + +iter = cache["3dwm-server"] +print "\nMarking '%s' for install" % iter.Name +depcache.MarkInstall(iter) +print "Install: %s " % depcache.InstCount +print "Broken count: %s" % depcache.BrokenCount +print "FixBroken() " +depcache.FixBroken() +print "Broken count: %s" % depcache.BrokenCount + +print "\nPerforming Upgrade" +depcache.Upgrade() +print "Keep: %s " % depcache.KeepCount +print "Install: %s " % depcache.InstCount +print "Delete: %s " % depcache.DelCount +print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize) +print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize) + +print "\nPerforming DistUpgrade" +depcache.Upgrade(True) +print "Keep: %s " % depcache.KeepCount +print "Install: %s " % depcache.InstCount +print "Delete: %s " % depcache.DelCount +print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize) +print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize) + +# overview about what would happen +for pkg in cache.Packages: + if depcache.MarkedInstall(pkg): + if pkg.CurrentVer != None: + print "Marked upgrade: %s " % pkg.Name + else: + print "Marked install: %s" % pkg.Name + elif depcache.MarkedDelete(pkg): + print "Marked delete: %s" % pkg.Name + elif depcache.MarkedKeep(pkg): + print "Marked keep: %s" % pkg.Name -- cgit v1.2.3