diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-12-02 23:17:16 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-12-02 23:17:16 +0000 |
| commit | c89b8408c0115e9fccdd4bfe180e93eb746b12cd (patch) | |
| tree | 3f706c5fe4e3d456cbfe24ebd18063820c28446e | |
| parent | 1aff3d1820f8efe90d811d96c0f5b3806f20d325 (diff) | |
| download | python-apt-c89b8408c0115e9fccdd4bfe180e93eb746b12cd.tar.gz | |
* added "{candidate,installed}Downloadable"
| -rw-r--r-- | TODO | 4 | ||||
| -rw-r--r-- | apt/package.py | 21 | ||||
| -rw-r--r-- | apt/progress.py | 2 | ||||
| -rw-r--r-- | debian/changelog | 1 | ||||
| -rw-r--r-- | doc/examples/dependant-pkgs.py | 36 |
5 files changed, 64 insertions, 0 deletions
@@ -0,0 +1,4 @@ +* apt.Package: + - change all candidateInstalledSize() to installSize(useCandidate=True) + same for candidateOrigin() (see downloadable for a example). + - might be better to have "Package.candidate.{downloadable,size,etc} diff --git a/apt/package.py b/apt/package.py index 5642496a..5fb6ade7 100644 --- a/apt/package.py +++ b/apt/package.py @@ -21,6 +21,7 @@ import apt_pkg, string, sys, random + class Package(object): """ This class represents a package in the cache """ @@ -89,6 +90,25 @@ class Package(object): return None candidateVersion = property(candidateVersion) + def _downloadable(self, useCandidate=True): + """ helper, return if the version is downloadable """ + if useCandidate: + ver = self._depcache.GetCandidateVer(self._pkg) + else: + ver = self._pkg.CurrentVer + if ver == None: + return False + return ver.Downloadable + def candidateDownloadable(self): + " returns if the canidate is downloadable " + self._downloadable(useCandidate=True) + candidateDownloadable = property(candidateDownloadable) + + def installedDownloadable(self): + " returns if the installed version is downloadable " + self._downloadable(useCandidate=False) + installedDownloadable = property(installedDownloadable) + def sourcePackageName(self): """ Return the source package name as string """ self._lookupRecord() @@ -298,6 +318,7 @@ if __name__ == "__main__": print "Priority (Installed): %s " % pkg.installedPriority print "Installed: %s " % pkg.installedVersion print "Candidate: %s " % pkg.candidateVersion + print "CandiateDownloadable: %s" % pkg.candidateDownloadable print "CandiateOrigin: %s" % pkg.candidateOrigin print "SourcePkg: %s " % pkg.sourcePackageName print "Section: %s " % pkg.section diff --git a/apt/progress.py b/apt/progress.py index 552c9e75..8c47ab95 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -62,6 +62,8 @@ class FetchProgress(object): dlIgnored : "Ignored"} def __init__(self): + self.eta = "" + self.percent = 0.0 pass def start(self): diff --git a/debian/changelog b/debian/changelog index 402ff2dc..bda57c52 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ python-apt (0.6.16) unstable; urgency=low * added GetPkgAcqFile to queue individual file downloads with the system + * added Package.downloadable -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 1 Dec 2005 14:01:39 +0100 diff --git a/doc/examples/dependant-pkgs.py b/doc/examples/dependant-pkgs.py new file mode 100644 index 00000000..656e38bf --- /dev/null +++ b/doc/examples/dependant-pkgs.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import apt +import sys + +pkgs = set() +cache = apt.Cache() +for pkg in cache: + candver = cache._depcache.GetCandidateVer(pkg._pkg) + if candver == None: + continue + dependslist = candver.DependsList + for dep in dependslist.keys(): + # get the list of each dependency object + for depVerList in dependslist[dep]: + for z in depVerList: + # get all TargetVersions of + # the dependency object + for tpkg in z.AllTargets(): + if sys.argv[1] == tpkg.ParentPkg.Name: + pkgs.add(pkg.name) + +main = [] +universe = [] +for pkg in pkgs: + if "universe" in cache[pkg].section: + universe.append(cache[pkg].sourcePackageName) + else: + main.append(cache[pkg].sourcePackageName) + +print "main:" +print "\n".join(main) +print + +print "universe:" +print "\n".join(universe) |
