Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/
Date: Wed, 19 Oct 2011 21:19:37
Message-Id: de807d14fb994535f1ea529ecef8de0ee9db4136.zmedico@gentoo
1 commit: de807d14fb994535f1ea529ecef8de0ee9db4136
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Wed Oct 19 21:19:09 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed Oct 19 21:19:09 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=de807d14
7
8 Add bindbapi.getfetchsizes() like pordbapi has.
9
10 ---
11 pym/portage/dbapi/bintree.py | 28 ++++++++++++++++++++++++++++
12 1 files changed, 28 insertions(+), 0 deletions(-)
13
14 diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
15 index 62fc623..5c091bd 100644
16 --- a/pym/portage/dbapi/bintree.py
17 +++ b/pym/portage/dbapi/bintree.py
18 @@ -177,6 +177,34 @@ class bindbapi(fakedbapi):
19 self.bintree.populate()
20 return fakedbapi.cpv_all(self)
21
22 + def getfetchsizes(self, pkg):
23 + """
24 + This will raise MissingSignature if SIZE signature is not available,
25 + or InvalidSignature if SIZE signature is invalid.
26 + """
27 +
28 + if not self.bintree.populated:
29 + self.bintree.populate()
30 +
31 + pkg = getattr(pkg, 'cpv', pkg)
32 +
33 + filesdict = {}
34 + if not self.bintree.isremote(pkg):
35 + pass
36 + else:
37 + metadata = self.bintree._remotepkgs[pkg]
38 + try:
39 + size = int(metadata["SIZE"])
40 + except KeyError:
41 + raise portage.exception.MissingSignature("SIZE")
42 + except ValueError:
43 + raise portage.exception.InvalidSignature(
44 + "SIZE: %s" % metadata["SIZE"])
45 + else:
46 + filesdict[os.path.basename(self.bintree.getname(pkg))] = size
47 +
48 + return filesdict
49 +
50 def _pkgindex_cpv_map_latest_build(pkgindex):
51 """
52 Given a PackageIndex instance, create a dict of cpv -> metadata map.