summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/bintree.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-10-19 14:19:09 -0700
committerZac Medico <zmedico@gentoo.org>2011-10-19 14:19:09 -0700
commitde807d14fb994535f1ea529ecef8de0ee9db4136 (patch)
treef4c116eecaf1a62b6f4b0d31798609fd33796bc3 /pym/portage/dbapi/bintree.py
parentdac6b249202ce69cd21a07cfd908ef31c9f595b9 (diff)
downloadportage-de807d14fb994535f1ea529ecef8de0ee9db4136.tar.gz
portage-de807d14fb994535f1ea529ecef8de0ee9db4136.tar.bz2
portage-de807d14fb994535f1ea529ecef8de0ee9db4136.zip
Add bindbapi.getfetchsizes() like pordbapi has.
Diffstat (limited to 'pym/portage/dbapi/bintree.py')
-rw-r--r--pym/portage/dbapi/bintree.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 62fc62354..5c091bd45 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -177,6 +177,34 @@ class bindbapi(fakedbapi):
self.bintree.populate()
return fakedbapi.cpv_all(self)
+ def getfetchsizes(self, pkg):
+ """
+ This will raise MissingSignature if SIZE signature is not available,
+ or InvalidSignature if SIZE signature is invalid.
+ """
+
+ if not self.bintree.populated:
+ self.bintree.populate()
+
+ pkg = getattr(pkg, 'cpv', pkg)
+
+ filesdict = {}
+ if not self.bintree.isremote(pkg):
+ pass
+ else:
+ metadata = self.bintree._remotepkgs[pkg]
+ try:
+ size = int(metadata["SIZE"])
+ except KeyError:
+ raise portage.exception.MissingSignature("SIZE")
+ except ValueError:
+ raise portage.exception.InvalidSignature(
+ "SIZE: %s" % metadata["SIZE"])
+ else:
+ filesdict[os.path.basename(self.bintree.getname(pkg))] = size
+
+ return filesdict
+
def _pkgindex_cpv_map_latest_build(pkgindex):
"""
Given a PackageIndex instance, create a dict of cpv -> metadata map.